adrien.io opengl tutorials codex
TRANSCRIPT
-
8/9/2019 adrien.io OpenGL Tutorials Codex
1/22
http://adrien.ioOpenGL Tutorials
Codex
http://adrien.io/ -
8/9/2019 adrien.io OpenGL Tutorials Codex
2/22
Buffer Object
Memory managed by OpenGL
GL_ARRAY_BUFFER,GL_ELEMENT_ARRAY_BUFFER, ..
glGenBuffers, glBindBuffer, glBufferData
-
8/9/2019 adrien.io OpenGL Tutorials Codex
3/22
Vertex Array Object
Specify where data is located and layout
GL_ARRAY_BUFFER,GL_ELEMENT_ARRAY_BUFFER, ..
glGenVertexArrays, glBindVertexArray,glVertexAttribPointer, glEnableVertexAttribArray
-
8/9/2019 adrien.io OpenGL Tutorials Codex
4/22
Framebuffer Object Specify how draw buffers are stored
glGenFramebuffersglBindFramebuffer Framebuffer Object 0is created automatically
Attach Renderbuffer Objects : glFramebufferTextu
Attach Textures : glFramebufferTexture2D Attach to Draw BuffersGL_COLOR_ATTACHMEN Special Attachments Depthand Stencil
Clear buffers before use : glClear
-
8/9/2019 adrien.io OpenGL Tutorials Codex
5/22
Programmable stages
Vertex Tessellation Control Tessellation Evaluation Geometry Fragment
Compute
-
8/9/2019 adrien.io OpenGL Tutorials Codex
6/22
Vertex Shading For each vertex issued by a drawing command a v
shader is called
gl_VertexIdgl_InstanceID
Output vertex positions in screen space
Mandatory
-
8/9/2019 adrien.io OpenGL Tutorials Codex
7/22
Tessellation Shading
Two stages : Control and Evaluation
Patches instead of points/lines/triangles
Optional stage
-
8/9/2019 adrien.io OpenGL Tutorials Codex
8/22
Geometry Shading
Process and emit individual geometry primitives
Optional Stage
gl_PrimitiveIDIn
-
8/9/2019 adrien.io OpenGL Tutorials Codex
9/22
Fragment Shading
Compute fragment color and depth
Texture sampling
Mandatory Stage
gl_FragCoord
-
8/9/2019 adrien.io OpenGL Tutorials Codex
10/22
Texture Units, Samplers, and Tex Only one texture can be bound for each Texture Un
glActiveTextureselects the current Texture Unit
glBindTexturebinds the texture to the current Text
Unit
A sampler uniform is associated to a Texture Unit
Shaders read textures through a sampler.
-
8/9/2019 adrien.io OpenGL Tutorials Codex
11/22
BAC = acos(A
AB
C ABAC = cos
AB = AB||AB||
AB = B-A
-
8/9/2019 adrien.io OpenGL Tutorials Codex
12/22
Blinn-Phong Shading
floatndotl = clamp(dot(n, l), 0.0, 1.0);
vec3h = normalize(l-v);
floatndoth = clamp(dot(n, h), 0.0,1.0);
vec3specularColor = specularColor *pow(ndoth, specularPower);
vec3color = specularColor +diffuseColor * ndotl;
-
8/9/2019 adrien.io OpenGL Tutorials Codex
13/22
Point Light
n
lp
p
ep
v l
l= lp-p
-
8/9/2019 adrien.io OpenGL Tutorials Codex
14/22
Directional Light
n
p
ep
v l
l= -ld
ld
-
8/9/2019 adrien.io OpenGL Tutorials Codex
15/22
Spot Light
n
lp
p
ep
v l
l= lp-p
ld
langle
-lld> cos(la
-
8/9/2019 adrien.io OpenGL Tutorials Codex
16/22
Geometry Spaces
World Space : Useful for transformations and lighting
Object Space : useful for object transformations
Camera Space : Useful for lighting
Light Space : Useful for shadow mapping
-
8/9/2019 adrien.io OpenGL Tutorials Codex
17/22
Forward Shading
Rasterization Uniforms
-
8/9/2019 adrien.io OpenGL Tutorials Codex
18/22
Deferred Shading
Rasterization
G-Buff
Normals Materia
+ +
-
8/9/2019 adrien.io OpenGL Tutorials Codex
19/22
Shadow Mapping
lp
p1
ep
langle
p2
dblocker
dlight
shadow = dblocker < dlight + bias
-
8/9/2019 adrien.io OpenGL Tutorials Codex
20/22
Post-FX pipeline
T0
glFramebufferTexture2DT0
glClear
Render
-
8/9/2019 adrien.io OpenGL Tutorials Codex
21/22
Post-FX pipeline
T0 T1
T0glFramebufferT
glClear
glBindTexture T
Render
-
8/9/2019 adrien.io OpenGL Tutorials Codex
22/22
Post-FX pipeline
T0 T1 T0
T1T0glFrame
glClear
glBindTe
Render