The Graphics Pipeline and OpenGL I: Transformations!

Similar documents
The Graphics Pipeline and OpenGL I: Transformations!

COMS 4160: Problems on Transformations and OpenGL

CSE 167: Lecture #4: Vertex Transformation. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2012

The Graphics Pipeline and OpenGL IV: Stereo Rendering, Depth of Field Rendering, Multi-pass Rendering!

Game Architecture. 2/19/16: Rasterization

Rasterization Overview

Lecture 2. Shaders, GLSL and GPGPU

Rendering Objects. Need to transform all geometry then

Computer graphics 2: Graduate seminar in computational aesthetics

CSE 167: Introduction to Computer Graphics Lecture #4: Vertex Transformation

C P S C 314 S H A D E R S, O P E N G L, & J S RENDERING PIPELINE. Mikhail Bessmeltsev

Notes on Assignment. Notes on Assignment. Notes on Assignment. Notes on Assignment

CSE 167: Introduction to Computer Graphics Lecture #5: Projection. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2017

The Graphics Pipeline and OpenGL III: OpenGL Shading Language (GLSL 1.10)!

CMSC427 Transformations II: Viewing. Credit: some slides from Dr. Zwicker

Today. Rendering algorithms. Rendering algorithms. Images. Images. Rendering Algorithms. Course overview Organization Introduction to ray tracing

Virtual Cameras and The Transformation Pipeline

Today. Rendering pipeline. Rendering pipeline. Object vs. Image order. Rendering engine Rendering engine (jtrt) Computergrafik. Rendering pipeline

CSE 167: Introduction to Computer Graphics Lecture #5: Rasterization. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2015

CS 130 Final. Fall 2015

Lecture 3 Sections 2.2, 4.4. Mon, Aug 31, 2009

The Graphics Pipeline and OpenGL III: OpenGL Shading Language (GLSL 1.10)!

Head Mounted Display Optics I!

Projection and viewing. Computer Graphics CSE 167 Lecture 4

Lecture 4. Viewing, Projection and Viewport Transformations

CS4620/5620: Lecture 14 Pipeline

Announcements. Submitting Programs Upload source and executable(s) (Windows or Mac) to digital dropbox on Blackboard

Today. Rendering algorithms. Rendering algorithms. Images. Images. Rendering Algorithms. Course overview Organization Introduction to ray tracing

CS451Real-time Rendering Pipeline

CSE 167: Lecture #5: Rasterization. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2012

Shaders. Slide credit to Prof. Zwicker

Overview. By end of the week:

Pipeline Operations. CS 4620 Lecture 14

Spring 2011 Prof. Hyesoon Kim

3D Graphics for Game Programming (J. Han) Chapter II Vertex Processing

CSE 167: Lecture #8: Lighting. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2011

CS230 : Computer Graphics Lecture 6: Viewing Transformations. Tamar Shinar Computer Science & Engineering UC Riverside

OPENGL RENDERING PIPELINE

Computer Viewing. CS 537 Interactive Computer Graphics Prof. David E. Breen Department of Computer Science

Overview. By end of the week:

For each question, indicate whether the statement is true or false by circling T or F, respectively.

Graphics Pipeline 2D Geometric Transformations

Computer Graphics 7: Viewing in 3-D

3D Viewing. CS 4620 Lecture 8

The Traditional Graphics Pipeline

Drawing in 3D (viewing, projection, and the rest of the pipeline)

TSBK03 Screen-Space Ambient Occlusion

Pipeline Operations. CS 4620 Lecture Steve Marschner. Cornell CS4620 Spring 2018 Lecture 11

IMAGE-BASED RENDERING AND ANIMATION

Perspective transformations

CS 112 The Rendering Pipeline. Slide 1

OpenGL Transformations

Advanced Lighting Techniques Due: Monday November 2 at 10pm

CSE528 Computer Graphics: Theory, Algorithms, and Applications

Spring 2009 Prof. Hyesoon Kim

Drawing in 3D (viewing, projection, and the rest of the pipeline)

Viewing with Computers (OpenGL)

Models and Architectures

CSE328 Fundamentals of Computer Graphics

CS 354R: Computer Game Technology

Transforms 3: Projection Christian Miller CS Fall 2011

SUMMARY. CS380: Introduction to Computer Graphics Projection Chapter 10. Min H. Kim KAIST School of Computing 18/04/12. Smooth Interpolation

Geometry: Outline. Projections. Orthographic Perspective

Drawing Fast The Graphics Pipeline

Computer Graphics Seminar

CSC 305 The Graphics Pipeline-1

Models and The Viewing Pipeline. Jian Huang CS456

EE 4702 GPU Programming

Real - Time Rendering. Graphics pipeline. Michal Červeňanský Juraj Starinský

Orthogonal Projection Matrices. Angel and Shreiner: Interactive Computer Graphics 7E Addison-Wesley 2015

GEOMETRIC TRANSFORMATIONS AND VIEWING

Game Graphics & Real-time Rendering

Introduction to Computer Graphics. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2011

Graphics pipeline and transformations. Composition of transformations

Rendering. Converting a 3D scene to a 2D image. Camera. Light. Rendering. View Plane

Wire-Frame 3D Graphics Accelerator IP Core. C Library Specification

Advanced Rendering Techniques

Graphics Programming. Computer Graphics, VT 2016 Lecture 2, Chapter 2. Fredrik Nysjö Centre for Image analysis Uppsala University

3D Viewing. CS 4620 Lecture Steve Marschner. Cornell CS4620 Spring 2018 Lecture 9

COMP Preliminaries Jan. 6, 2015

CS 4620 Program 3: Pipeline

Computer Graphics with OpenGL ES (J. Han) Chapter VII Rasterizer

Drawing in 3D (viewing, projection, and the rest of the pipeline)

Computer Graphics Coursework 1

Introduction to Computer Graphics with WebGL

Ciril Bohak. - INTRODUCTION TO WEBGL

CS 184: Assignment 2 Scene Viewer

S U N G - E U I YO O N, K A I S T R E N D E R I N G F R E E LY A VA I L A B L E O N T H E I N T E R N E T

CSE 167: Introduction to Computer Graphics Lecture #7: Lights. Jürgen P. Schulze, Ph.D. University of California, San Diego Spring Quarter 2015

Homework 1: Getting Started with WebGL and Transformations EE267 Virtual Reality 2018

Real-Time Rendering (Echtzeitgraphik) Michael Wimmer

E.Order of Operations

CSE 167: Lecture #8: GLSL. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2012

CS230 : Computer Graphics Lecture 4. Tamar Shinar Computer Science & Engineering UC Riverside

The Graphics Pipeline

The Traditional Graphics Pipeline

CSE 167: Introduction to Computer Graphics Lecture #9: Visibility. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2018

Surface Graphics. 200 polys 1,000 polys 15,000 polys. an empty foot. - a mesh of spline patches:

CS GPU and GPGPU Programming Lecture 2: Introduction; GPU Architecture 1. Markus Hadwiger, KAUST

graphics pipeline computer graphics graphics pipeline 2009 fabio pellacini 1

Transcription:

! The Graphics Pipeline and OpenGL I: Transformations! Gordon Wetzstein! Stanford University! EE 267 Virtual Reality! Lecture 2! stanford.edu/class/ee267/!!

Logistics Update! all homework submissions: https://gradescope.com/, code: MX6E5M! office hours (instructor): Mondays, 1:50-2:50pm, Packard 236! office hours (CAs): Tuesdays 3-4:30pm, Wednesdays 4:30-6pm, Thursdays 4:30-6pm, all in Packard 001! change of lab times: Fridays at 9am, 12pm, or 2pm please sign up again! sorry, too many people couldn t make the morning slots!

Albrecht Dürer, Underweysung der Messung mit dem Zirckel und Richtscheyt, 1525!

Lecture Overview! what is computer graphics?! the graphics pipeline! primitives: vertices, edges, triangles!! model transforms: translations, rotations, scaling! view transform! perspective transform!

blender.org!

blender.org!

What is Computer Graphics?! at the most basic level: conversion from 3D scene description to 2D image! what do you need to describe a static scene?! 3D geometry and transformations! lights! material properties! most common geometry primitives in graphics:! vertices (3D points) and normals (unit-length vector associated with vertex)! triangles (set of 3 vertices, high-resolution 3D models have M or B of triangles)!

! The Graphics Pipeline! blender.org! geometry + transformations! cameras and viewing! lighting and shading! rasterization! texturing!

Some History! Stanford startup in 1981! computer graphics goes hardware! based on Jim Clark s geometry engine!

Some History!

The Graphics Pipeline! monolithic graphics workstations of the 80s have been replaced by modular GPUs (graphics processing units); major companies: Nvidia, AMD, Intel! early versions of these GPUs implemented fixed-function rendering pipeline in hardware! GPUs have become programmable starting in the late 90s! e.g. in 2001 Nvidia GeForce 3 = first programmable shaders! now: GPUs = programmable (e.g. OpenGL, CUDA, OpenCL) processors!

The Graphics Pipeline! GPU = massively! parallel processor!

OpenGL is our interface to the GPU! The Graphics Pipeline! right: old-school OpenGL state machine! today s lecture: vertex transforms! I had this poster hanging on my dorm wall during undergrad!

WebGL! JavaScript application programmer interface (API) for 2D and 3D graphics! OpenGL ES 2.0 running in the browser, implemented by all modern browsers! overview, tutorials, documentation:!! https://developer.mozilla.org/en-us/docs/web/api/webgl_api!

three.js! cross-browser JavaScript library/api! higher-level library that provides a lot of useful helper functions, tools, and abstractions around WebGL easy and convenient to use! https://threejs.org/! simple examples: https://threejs.org/examples/! great introduction (in WebGL):! http://davidscottlyons.com/threejs/presentations/frontporch14/!

three.js! more in the lab! on Friday! http://davidscottlyons.com/threejs/presentations/frontporch14/!

The Graphics Pipeline! frame buffer: dedicated memory for screen pixels + X! oftentimes have multiple frame buffers (i.e. offscreen buffers)! render into frame buffers, then send to monitor! https://www.ntu.edu.sg/home/ehchua/programming/opengl/cg_basicstheory.html!

The Graphics Pipeline! https://www.ntu.edu.sg/home/ehchua/programming/opengl/cg_basicstheory.html!

The Graphics Pipeline! 1. Vertex Processing: Process and transform individual vertices.! 2. Rasterization: Convert each primitive (connected vertices) into a set of fragments. A fragment can be treated as a pixel in 3D spaces, which is aligned with the pixel grid, with attributes such as position, color, normal and texture.! 3. Fragment Processing: Process individual fragments.! 4. Output Merging: Combine the fragments of all primitives (in 3D space) into 2D color-pixel for the display.! https://www.ntu.edu.sg/home/ehchua/programming/opengl/cg_basicstheory.html!

The Graphics Pipeline! 1. Vertex Processing: Process and transform individual vertices.! 2. Rasterization: Convert each primitive (connected vertices) into a set of fragments. A fragment can be treated as a pixel in 3D spaces, which is aligned with the pixel grid, with attributes such as position, color, normal and texture.! 3. Fragment Processing: Process individual fragments.! 4. Output Merging: Combine the fragments of all primitives (in 3D space) into 2D color-pixel for the display.! https://www.ntu.edu.sg/home/ehchua/programming/opengl/cg_basicstheory.html!

The Graphics Pipeline! vertex shader! fragment shader! transforms & (pervertex) lighting! texturing! (per-fragment) lighting! https://www.ntu.edu.sg/home/ehchua/programming/opengl/cg_basicstheory.html!

Coordinate Systems! right hand coordinate system! a few different coordinate systems:! object coordinates! world coordinates! viewing coordinates! also clip, normalized device, and window coordinates! wikipedia!

Primitives! vertex = 3D point v(x,y,z)! triangle = 3 vertices! normal = 3D vector per vertex describing surface orientation n(n x,n y,n z )! n 2 n 3 v 3 v 2 n 1 v 1

Pixels v Fragments! fragments have rasterized 2D coordinates on screen but a lot of other attributes too (texture coordinates, depth value, alpha value, )! pixels appear on screen! won t discuss in more detail today! https://www.ntu.edu.sg/home/ehchua/programming/opengl/cg_basicstheory.html!

Vertex Transforms! https://www.ntu.edu.sg/home/ehchua/programming/opengl/cg_basicstheory.html!

Vertex Transforms! vertex/normal! transforms! https://www.ntu.edu.sg/home/ehchua/programming/opengl/cg_basicstheory.html!

Vertex Transforms! 1. Arrange the objects (or models, or avatar) in the world (Model Transformation or World transformation).! https://www.ntu.edu.sg/home/ehchua/programming/opengl/cg_basicstheory.html!

Vertex Transforms! 1. Arrange the objects (or models, or avatar) in the world (Model Transformation or World transformation).! 2. Position and orientation the camera (View transformation).! https://www.ntu.edu.sg/home/ehchua/programming/opengl/cg_basicstheory.html!

Vertex Transforms! 1. Arrange the objects (or models, or avatar) in the world (Model Transformation or World transformation).! 2. Position and orientation the camera (View transformation).! 3. Select a camera lens (wide angle, normal or telescopic), adjust the focus length and zoom factor to set the camera's field of view (Projection transformation).! https://www.ntu.edu.sg/home/ehchua/programming/opengl/cg_basicstheory.html!

Vertex Transforms! 1. Arrange the objects (or models, or avatar) in the world (Model Transformation or World transformation).! 2. Position and orientation the camera (View transformation).! 3. Select a camera lens (wide angle, normal or telescopic), adjust the focus length and zoom factor to set the camera's field of view (Projection transformation).! 4. Print the photo on a selected area of the paper (Viewport transformation) - in rasterization stage! https://www.ntu.edu.sg/home/ehchua/programming/opengl/cg_basicstheory.html!

Model Transform! x transform each vertex v = y from object coordinates to world coordinates! z https://www.ntu.edu.sg/home/ehchua/programming/opengl/cg_basicstheory.html!

Model Transform - Scaling! x transform each vertex v = y from object coordinates to world coordinates! z 1. scaling as 3x3 matrix! S(s x,s y,s z ) = s x 0 0 0 s y 0 0 0 s z scaled vertex = matrix-vector product:! Sv = s x 0 0 0 s y 0 0 0 s z x y z = s x x s y y s z z

Model Transform - Rotation! x transform each vertex v = y from object coordinates to world coordinates! z 2. rotation as 3x3 matrix! R z (θ) = cosθ sinθ 0 sinθ cosθ 0 0 0 1 R x (θ) = 1 0 0 0 cosθ sinθ 0 sinθ cosθ R y (θ) = cosθ 0 sinθ 0 1 0 sinθ 0 cosθ rotated vertex = matrix-vector product, e.g.! R z v = cosθ sinθ 0 sinθ cosθ 0 0 0 1 x y z = x cosθ ysinθ xsinθ + ycosθ z

Model Transform - Translation! transform each vertex from object coordinates to world coordinates! v = x y z 3. translation cannot be represented as 3x3 matrix!! x y z + d x d y d z = x + d x y + d y z + d z that s unfortunate L!

Model Transform - Translation! solution: use homogeneous coordinates, vertex is! v = x y z 1 3. translation is 4x4 matrix! T (d) = 1 0 0 d x 0 1 0 d y 0 0 1 d z 0 0 0 1 better J! Tv = 1 0 0 d x 0 1 0 d y 0 0 1 d z 0 0 0 1 x y z 1 = x + d x y + d y z + d z 1

Summary of Homogeneous Matrix Transforms!!!! translation! scale! T (d) = S(s) = 1 0 0 d x 0 1 0 d y 0 0 1 d z 0 0 0 1 s x 0 0 0 0 s y 0 0 0 0 s z 0 0 0 0 1 rotation! R z (θ) = cosθ sinθ 0 0 sinθ cosθ 0 0 0 0 1 0 0 0 0 1 R x = 1 0 0 0 0 cosθ sinθ 0 0 sinθ cosθ 0 0 0 0 1 R y = cosθ 0 sinθ 0 0 1 0 0 sinθ 0 cosθ 0 0 0 0 1 Read more: https://www.ntu.edu.sg/home/ehchua/programming/opengl/cg_basicstheory.html!

Summary of Homogeneous Matrix Transforms!!!! 1 0 0 d x 0 1 0 d y translation T (d) = inverse translation! 0 0 1 d z 0 0 0 1 s x 0 0 0 0 s y 0 0 scale S(s) = inverse scale! 0 0 s z 0 0 0 0 1 T 1 (d) = T ( d) = 1 0 0 d x 0 1 0 d y 0 0 1 d z 0 0 0 1 1/ s x 0 0 0 S 1 (s) = S 1 s 0 1/ s = y 0 0 0 0 1/ s z 0 0 0 0 1 cosθ sinθ 0 0 sinθ cosθ 0 0 0 0 1 0 0 0 0 1 rotation R z (θ) = inverse rotation! R 1 z (θ) = R z ( θ ) = cos θ sin θ 0 0 sin θ cos θ 0 0 0 0 1 0 0 0 0 1 Read more: https://www.ntu.edu.sg/home/ehchua/programming/opengl/cg_basicstheory.html!

Summary of Homogeneous Matrix Transforms!!! successive transforms:! inverse successive transforms:! v' = T S R z R x T v v = ( T S R z R x T ) 1 v' = T 1 R x 1 R z 1 S 1 T 1 v' Read more: https://www.ntu.edu.sg/home/ehchua/programming/opengl/cg_basicstheory.html!

! Vector and Normal Transforms! homogeneous representation of a vector t, i.e. pointing from v 1 to v 2 :! t = (v 2 v 1 ) x (v 2 v 1 ) y (v 2 v 1 ) z (1 1) t x t y t z 0 successive transforms:! this works! t ' = M t = M ( v 2 v 1 ) = M v 2 M v 1 v' 2 v 2 t M t ' v 1 v' 1

! Vector and Normal Transforms! homogeneous representation of a normal (unit length, perpendicular to surface)! n = n x n y n z 0 successive transforms???! n' = M n this does NOT work! (non-uniform scaling is a problem)! v 2 n t M v' 2 n' t ' v 1 v' 1

! Vector and Normal Transforms! homogeneous representation of a normal (unit length, perpendicular to surface)! n = n x n y n z 0 need to use transpose of inverse for transformation! v 2 n t v 1 M n' = ( M 1 ) T n v' 2 n' t ' v' 1

Attention! rotations and translations (or transforms in general) are not commutative!! make sure you get the correct order!!!

View Transform! so far we discussed model transforms, e.g. going from object or model space to world space! https://www.ntu.edu.sg/home/ehchua/programming/opengl/cg_basicstheory.html!

View Transform! so far we discussed model transforms, e.g. going from object or model space to world space! one simple 4x4 transform matrix is sufficient to go from world space to camera or view space! https://www.ntu.edu.sg/home/ehchua/programming/opengl/cg_basicstheory.html!

!!!! View Transform! specify camera by! eye x eye position! eye = eye y eye z reference position! center = up x up vector! up = up y up z center x center y center z

!!!! View Transform! specify camera by! eye x eye position! eye = eye y eye z reference position! center = up x up vector! up = up y up z center x center y center z compute 3 vectors:! z c = x c = eye center eye center up zc up z c y c = z c x c

!! View Transform! view transform M is translation into eye position,! followed by rotation! compute 3 vectors:! z c = x c = eye center eye center up zc up z c y c = z c x c

!! View Transform! view transform M is translation into eye position,! followed by rotation! M = R T ( e) = x x c y x c z x c x y c y y c z y c x z c y z c z z c 0 0 0 0 0 0 1 1 0 0 eye x 0 1 0 eye y 0 0 1 eye z 0 0 0 1 compute 3 vectors:! z c = x c = eye center eye center up zc up z c y c = z c x c

!! View Transform! view transform M is translation into eye position,! followed by rotation! M = R T ( e) = c x x c x y c x z c y x c y y c y z c z x c z y c z z ( ) ( ) ( ) x x c eye x + x y c eye y + x z c eye z y x c eye x + y y c eye y + y z c eye z z x c eye x + z y c eye y + z z c eye z 0 0 0 1

View Transform! in camera/view space, the camera is at the origin, looking into negative z! modelview matrix is combined model (rotations, translations, scales) and view matrix! https://www.ntu.edu.sg/home/ehchua/programming/opengl/cg_basicstheory.html!

View Transform! in camera/view space, the camera is at the origin, looking into negative z! up e z x z x vodacek.zvb.cz!

Projection Transform! similar to choosing lens and sensor of camera specify field of view and aspect! https://www.ntu.edu.sg/home/ehchua/programming/opengl/cg_basicstheory.html!

Projection Transform - Perspective Projection! have symmetric view frustum! fovy: vertical angle in degrees! aspect: ratio of width/height! znear: near clipping plane (relative from cam)! zfar: far clipping plane (relative from cam)! f = cot( fovy / 2) M proj = f aspect 0 0 0 0 f 0 0 zfar + znear 2 zfar znear 0 0 zfar znear zfar znear 0 0 1 0 projection matrix! (symmetric frustum)!

Projection Transform - Perspective Projection! more general: a perspective frustum (truncated, possibly sheared pyramid)! left (l), right (r), bottom (b), top (t): corner coordinates on near clipping plane (at znear)! perspective frustum! M proj = 2 znear r + l 0 0 r l r l 2 znear t + b 0 0 t b t b zfar + znear 2 zfar znear 0 0 zfar znear zfar znear 0 0 1 0 projection matrix! (asymmetric frustum)!

! Projection Transform! possible source of confusion for znear and zfar:! Marschner & Shirley define it as absolute z coordinates, thus znear>zfar and both values are always negative! OpenGL and we define it as positive values, i.e. the distances of the near and far clipping plane from the camera (zfar > znear)!

Modelview Projection Matrix! put it all together with 4x4 matrix multiplications!! v clip = M proj M view M model v = M proj M mv v vertex in clip space! projection matrix! modelview matrix!

Clip Space! https://www.ntu.edu.sg/home/ehchua/programming/opengl/cg_basicstheory.html!

Normalized Device Coordinates (NDC)! not in previous illustration! get to NDC by perspective division! from: OpenGL Programming Guide! v clip = x clip y clip z clip w clip v NDC = x clip / w clip y clip / w clip z clip / w clip 1 vertex in clip space! vertex in NDC!

Viewport Transform! also in matrix form (let s skip the details)! from: OpenGL Programming Guide! v NDC = x clip / w clip y clip / w clip z clip / w clip 1 v window = x window y window z window 1 ( ) ( ) ( 0,1) 0,win _ width 1 0,win _ height 1 vertex in NDC! vertex in window coords!

The Graphics Pipeline Another Illustration!

Note on Rotations with Quaternions! successive rotations around each axis are most common, but sometimes problematic! axis and angle representation is an alternative! can be conveniently represented by quaternion (extension of complex numbers to 3 imaginary values)! get back to that later, so stay tuned!!

The Graphics Pipeline! all vertex transforms from today! https://www.ntu.edu.sg/home/ehchua/programming/opengl/cg_basicstheory.html!

! The Graphics Pipeline! assign fixed color (e.g. red) to each vertex in window coordinates (fragment)! interpolate (i.e. rasterize) lines between vertices (as defined by user)! https://www.ntu.edu.sg/home/ehchua/programming/opengl/cg_basicstheory.html!

and we can almost do this! Nintendo Virtual Boy Game Red Alarm!

Summary! graphics pipeline is a series of operations that takes 3D vertices/normals/ triangles as input and generates fragments and pixels! today, we only discussed a small part of it: vertex and normal transforms! transforms include: rotation, scale, translation, perspective projection, perspective division, and viewport transform! most transforms are represented as 4x4 matrices in homogeneous coordinates à know your matrices & be able to use GLM to create, manipulate, invert them!!

Next Lecture: Lighting and Shading, Fragment Processing! vertex shader! fragment shader! transforms & (pervertex) lighting! texturing! (per-fragment) lighting! https://www.ntu.edu.sg/home/ehchua/programming/opengl/cg_basicstheory.html!

!! Further Reading! good overview of OpenGL (deprecated version) and graphics pipeline (missing a few things) :! https://www.ntu.edu.sg/home/ehchua/programming/opengl/cg_basicstheory.html! textbook: Shirley and Marschner Fundamentals of Computer Graphics, AK Peters, 2009! definite reference: OpenGL Programming Guide aka OpenGL Red Book! WebGL / three.js tutorials: https://threejs.org/!