Académique Documents
Professionnel Documents
Culture Documents
io
OpenGL Tutorials
Codex
Buffer Object
Memory managed by OpenGL
GL_ARRAY_BUFFER,
GL_ELEMENT_ARRAY_BUFFER, ..
glGenBuffers, glBindBuffer, glBufferData
Framebuffer Object
Specify how draw buffers are stored
glGenFramebuffers glBindFramebuffer
Framebuffer Object 0 is created automatically
Programmable stages
Vertex
Tessellation Control
Tessellation Evaluation
Geometry
Fragment
Compute
Vertex Shading
For each vertex issued by a drawing command a vertex
shader is called
gl_VertexId gl_InstanceID
Output vertex positions in screen space
Mandatory
Tessellation Shading
Two stages : Control and Evaluation
Patches instead of points/lines/triangles
Optional stage
Geometry Shading
Process and emit individual geometry primitives
Optional Stage
gl_PrimitiveIDIn
Fragment Shading
Compute fragment color and depth
Texture sampling
Mandatory Stage
gl_FragCoord
B
A
AB = B-A
AB
AB =
||AB||
BAC = acos(ABAC)
C
ABAC = cos(BAC)
Blinn-Phong Shading
float ndotl = clamp(dot(n, l), 0.0, 1.0);
vec3 h = normalize(l-v);
float ndoth = clamp(dot(n, h), 0.0,
1.0);
vec3 specularColor = specularColor *
pow(ndoth, specularPower);
vec3 color = specularColor +
diffuseColor * ndotl;
Point Light
ep
lp
n
v
l
p
l = lp-p
Directional Light
ld
ep
n
v
l
p
l = -ld
Spot Light
lp
ep
langle
n
ld
l
p
l = lp-p
Geometry Spaces
Forward Shading
Lights[]
Transforms
Rasterization
Uniforms
Material
Transforms
Material
Deferred Shading
G-Buffer
Rasterization
Normals
Material
Depth
Shadow Mapping
lp
ep
langle
dblocker
dlight
p2
p1
Post-FX pipeline
glFramebufferTexture2D T0
glClear
Render
T0
Post-FX pipeline
T0
glFramebufferTexture2D T1
glClear
glBindTexture T0
Render
T0
T1
Post-FX pipeline
T0
T1
glFramebufferTexture2D T0
glClear
glBindTexture T1
Render
T0
T1
T0