Games202-1 Recap of CG Basics
a). Graphics Pipeline

b). OpenGL

A. Place objects/models
- Model specification(模型信息)
 - Model transformation
 

B. Set up an easel(画架)
- View transformation
 - Create /use a framebuffer
 

C. Attach a canvas to the easel
指定Pass到framebuffer,就和Unity中FS的SV_TARGET一样。
E. you can also paint multiple pictures using the same easel
一个Rendering Pass,使用一个framebuffer,渲染一个或多个texture(shading, depth, etc.)作为输出
即一个framebuffer可以绑定多个纹理(MRT)
Multiple Render Target(MRT)是一种指可以使绘制程序在单帧中同时渲染多个Render Target
D. Paint to the canvas
- This is when vertex / fragment shaders will be used
 
- For each vertex in parallel     
- OpenGL calls user-specified vertex shader: Transform vertex (ModelView, Projection), other ops
 
 - For each primitive, OpenGL rasterizes 
- Generates a fragment for each pixel the fragment covers
 
 
- For each fragment in parallel 
- OpenGL calls user-specified fragment shader: Shading and lighting calculations
 - OpenGL handles z-buffer depth test unless overwritten
 
 
Summary: in each pass
Specify objects, camera, MVP, etc.
Specify framebuffer and input/output textures
Specify vertex / fragment shaders
(When you have everything specified on the GPU) Render
c). Shading Language(GLSL)
c.1). Initializing
Create shader(Vertex and Fragment)
Compile shader
Attach shader to program
Link program
- Use program
 


c.2). Phong Shader in Assignment 0
Vertex Shader

- attribute: 顶点附带的属性,FS中不会出现
 - uniform: 全局变量,由CPU直接传递给GPU
 - varying: 需要插值的变量
 - highp: 高精度
 - gl_Position: 类似于Unity的SV_Position,裁剪空间中的顶点位置;
 
Fragment Shader
