games101-note-L8 Shading 2 (Shading, Pipeline and Texture Mapping)

Shading 2

Specular Term (Blinn-Phong)

V close to mirror direction ⇔ half vector near normal

Specular Term

Increasing p narrows the reflection lobe
指数p越大镜面反射区域越小

一般p取到100~200

Ambient Term

Shading that does not depend on anything
• Add constant color to account for disregarded illumination and fill in black shadows
• This is approximate / fake!

Ambient Term

Shading Frequencies

Shade each triangle (flat shading)

Flat shading 逐平面
• Triangle face is flat — one normal vector
• Not good for smooth surfaces

Shade each triangle (flat shading)

Shade each vertex (Gouraud shading)

Gouraud shading 逐顶点
• Interpolate colors from vertices across triangle
• Each vertex has a normal vector (how?)

Shade each vertex (Gouraud shading)

Shade each pixel (Phong shading)

Phong shading 逐像素
• Interpolate normal vectors across each triangle
• Compute full shading model at each pixel
• Not the Blinn-Phong Reflectance Model

对比

Defining Per-Vertex Normal Vectors

Best to get vertex normals from the underlying geometry
• e.g. consider a sphere

get vertex normals from the underlying geometry

Otherwise have to infer vertex normals from triangle faces

从这个顶点相邻的几个面的法线来求平均值

infer vertex normals from triangle facesinfer vertex normals from triangle faces

Defining Per-Pixel Normal Vectors

Barycentric interpolation (introducing soon) of vertex normals

Barycentric interpolation

Don’t forget to normalize the interpolated directions

Graphics (Real-time Rendering) Pipeline 图形管线

各个部分内容所对应的渲染管线的流程

Pipeline

mvp transforms

rasterization

Z-Buffer

shading

texture

Texture Mapping

Surfaces are 2D, 纹理是一张图

Surface lives in 3D world space
Every 3D surface point also has a place where it goes in the 2D image (texture).

Surfaces are 2D

Each triangle “copies” a piece of the texture image to the surface.

Each triangle vertex is assigned a texture coordinate (u,v)
每个三角形的顶点都被映射到纹理坐标上

Each triangle vertex is assigned a texture coordinate

纹理可以被多次使用(上下相连的tiled)