光栅化阶段 #
Shading Overview #
- shading 着色
- darkening 明暗
- coloring 着色
Light-Material lnteraction
- Light-material interactions cause each point to have a different color or shade
- Light that strikes an object is partially absorbed and partially scattered(reflected)
- A surface appears red under white light because the red component of the light is reflected and the rest is absorbed
- The reflected light is scattered in a manner that depends on the smoothness and orientation of the surface,The amount reflected determines the color and brightness of the object
简单光照 #
Light Sources(光源)
-
General Light Sources are difficult to work with ,
- because we must integrate light coming from all points on the source
-
Common Using Simple Light Sources Type
-
Point source or parallel source点光源或平行光源*
-
Point source Model with position and color, parallel source is infinite distance away Model with light source direction vector
-
Spotlight聚光灯
- Restrict light from ideal point source
-
-
Ambient light环境光
- Same amount of light everywhere in scene Can model contribution of many sources and reflecting surfaces
-
Surface Types(表面类型~材质属性)
根据反射情况
- The smoother a surface, the more reflected light is concentrated in the direction a perfect mirror would reflected the light
- A very rough surface scatters light in all directions
简单光照模型只考虑光线在物体表面发生一次散射,即直接光照的效果
因此不会产生阴影
Phong Model
Blinn-Phong Model
经验模型 #
反射光 = 环境光 + 漫反射 + 镜面反射
-
环境光:根据入射光模拟
- $L_a = K_aI_a$
-
漫反射
-
兰博顿表面:光在各个方向均匀散射
-
-
漫反射光计算模型
- $L_d=K_dI_dcosθ=K_dI_dl·n$
- 与观察方向无关
- 与光线和法向量的夹角有关
-
-
镜面反射光
-
-
-
-
考虑距离衰减: $I=f(d)(K_dI_dl·n+K_sI_s(v·r)^α)+K_aI_a$
$f(d)=1/d^2$是简便做法
Blinn-Phong 半角优化 #
$h=(l+v)/|l+v|$
Polygon Shading #
- Flat shading: per face using lighting model
- 只用一个顶点计算
-
- Gouraud shading: per vertex using lighting model
- 每顶点都算
-
- Phong shading: per fragment using lighting model
- 顶点着色器计算参数传递给管线
- 片元着色器用光照模型计算颜色
-
Both need data structures to represent meshes so we can obtain vertex normal Phong shading may look smooth while Gouraud shading may show edges
Phong shading requires much more work than Gouraud shading
- Until recently not available in real time systems
- Now can be done using fragment shaders