visibility/occlusion - z buffering
Painter's Algorithm
- Paint from back to front, overwrite in the same framebuffer
距离观测者举例 —— 深度
shortcoming - 相叠时无法计算(如上图)
z - buffer
idea
- store current min z-value for each sample(pixel)
- Needs an addition buffer for depth values
-- frame buffer store color values
-- depth buffer(z-buffer) stores depth(深度图、深度缓存)
Important :for simplicity wo suppose z is always positive
(smaller z --> closer、larger z --> further)
z-buffer example
for(each triangle T)
for(each sample(x, y, z) in T)
if(z < zbuffer(x, y)) //closest sample so far
framebuffer(x, y) = rgb; //update color
zbuffer(x, y) = z; //update depth
else
; // do nothing, this sample is occluded
Complexity
- O(n) for no triangles(assuming constant coverage) 只需记录每个像素的最小值
Drawing triangles in different orders? ==> no connection with orders!
Most important visibility algorithm
- Implemented in hardware for all GPUs
Summary
Shading 着色 对不同的物体应用不同的材质
Perceptual Observation
- Specular highlights --> 高光
- Diffuse reflection --> 漫反射
- Ambient lighting --> 环境光照
Inputs :
- View direction V
- surface normal n
- light direction I ( for each of many lights)
- surface parameters ( color、shininess ...)
Note : shading(着色) ≠ shadow(阴影) shading is local
Blinn-Phong reflectance model
① Diffuse reflection
已知点光源和shading poin距离
Ld --> diffusely reflected light
Kd --> diffuse cofficient(color) 不同吸收率产生不同的颜色
--> energy received by the shading point
Noted that shading independent of view angle.
Result
经验模型,并非完全是物理模型
参考链接:https://www.bilibili.com/video/BV1X7411F744?p=7(GAMES101-现代计算机图形学入门-闫令琪)