GAMES101 07 SHADING
07 Shading 着色
解决遮挡(Visibility)与着色的问题———Z-buffering
Blinn-Phong Reflection Model
现在只针对于一个点的着色
1.Painter’s Algorithm
- 遮挡和覆盖overwrite
- 但是对于物体,填充顺序是个问题
- nlog(n)
2.Z-Buffer 深度缓存,n triangle
- idea :存储min.z-value, for every pixel
- Frame buffer
- Depth buffer
- Algorithm 维护当前看到的最浅深度的信息
- initialize depth buffer to infinity
- zbuffer[x,y] denotes the screen’s pixel buffer
- framebuffer[x,y] denotes the information(r,g,b) of the pixel
- for(every triangle)
- for(every sample(x,y,z)in Triangle)
- if(z<zbuffer[x,y])
- framebuffer[x,y]= rgb of sample
- zbuffer[x,y]= z
- if(z<zbuffer[x,y])
- for(every sample(x,y,z)in Triangle)
- Time Complexity= o(n), but cost more space of zbuffer
3. Shading 着色
(Blinn-Phong Reflectance Model) 弄成不同材质
- Perceptual Observation 感知观察,三类不同的光
- Specular highlights 高光
- Diffuse reflection 漫反射
- Ambient lighting 环境光照
- Shading is Local(局部)
- copute light at a specific shading point
- inputs:
- viewer direction, v
- surface normal, n 法向量
- Light direction, I
- surface parameters, like color shiness, etc.
- well, no shadow will be generated.(shading $\neq$ shadow)
- Diffuse Reflection 漫反射的散射和吸收,对局部光照来说,对四面八方的反射一样
- Lambert’s cosine law: $cos\theta =<I,n>$光通量: $\Phi =S*cos\theta$
- Light Falloff 光衰减: 距离的平方反比
- Lambertian Diffuse Shading: $L_d = k_d (I/r^2)max(0,<n,l>)$ ( $k_d$ is diffuse coefficient(color))
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Chuan 川 Charles!
评论