Illumination Model and Surface Rendering Method Lectured by Hua Yan 对场景的对象进行透视投影,然后在可见面上产生自然光效果,可以实现场景的真实感显示。 光照模型主要用于对象表面某光照位置的颜色计算, 表面绘制是使用光照模型为对象的所有投影位置确定象素颜色。
Contents Light source光源 Basic illumination models基本光照模型 Surface Rendering Method表面绘制方法 Shading着色处理 OpenGL函数(P.510-P.527) …
Light Source light-emitting sources & light-reflecting sources 点光源、平行光、聚光 Point-light source model is a reasonable approximation for sources whose dimensions are small compared to the size of objects in the scene. Such as the sun. Distributed light source model is is a approximation for sources whose area of the source is not small compared to the surfaces in the scene. Such as long fluorescent light.
Diffuse Reflection Specular Reflection Surfaces that are rough, or grainy, tend to scatter the reflected light in all directions. This scattered light is called diffuse reflection. In addition to diffuse reflection, light sources create highlights, or bright spots, called specular reflection.
Basic Illumination Models Ambient Light环境光 Iambdiff = KaIa Ka – ambient-reflection coefficient Ia -- ambient light intensity Ambient light produces a flat uninteresting shading for each surface, scene are rarely rendered with ambient light alone. At least one light source is included in a scene, often as a point source at the viewing position +
Diffuse Reflection & Lambert’s Cosine Law漫反射与朗伯特余弦定律 ILdiff = KdIlcosθ= KdIl(N.L) Kd – diffuse-reflection coefficient Il -- intensity of point light source N L
θ Φ Specular Reflection镜面反射 Ispec = w(θ)IlcosnsΦ =KsIl(V.R) ns V.R=N.H When we look at an illuminated shiny surface, such as polished metal, an apple, or a person’s forehead, we see a highlight, or bright spot, at certain viewing directions. This phenomenon, called specular reflection. It is the result of total, or near total, reflection of the incident light in a concentrated region around the specular-reflection angle. W() 镜面反射系数 Φ为观察方向V与镜面反射方向R的夹角 ns代表镜面反射参数,由观察物体的表面材质决定,光滑表面的ns值大(范围小),而粗糙表面的ns值小(范围大),影响镜面反射的角度范围。 N L R V θ Φ
Phong Model :由物体表面上一点P反射到视点的光强I为环境光的反射光强 、理想漫反射光强 、和镜面反射光的总和。 I= Iambdiff + Ildiff + Ispec History of illumination models 1967年,Wylie等人第一次在显示物体时加进光照效果,认为光强与距离成反比。 1970年,Bouknight提出第一个光反射模型:Lambert漫反射+环境光 1971年,Gouraud提出漫反射模型加插值的思想 1975年,Phong提出图形学中第一个有影响的光照明模型 Warn Model The warn model provides a method for simulating studio lighting effects by controlling light intensity in different directions
Example + + =
环境光 + 境面反射 + 理想漫反射 = Phong光照明模型是真实感图形学中提出的第一个有影响的光照明模型 显示出的物体象塑料,无质感变化 没有考虑物体间相互反射光 镜面反射颜色与材质无关 镜面反射大入射角失真现象 =
Intensity Attenuation强度衰减 f(d) = 1/d2 Compensated attenuation function f(d) = 1/(a0+a1d+a2d2) I=KaIa + f(di)Ili[kd(N.Li) +Ks(N.Hi)ns] As radiant energy from a point light light source travels through space, its amplitude is attenuated by the factor 1/d2, where d is the distance that the light has traveled. This means that a surface close to the light source receives a higher incident intensity from the source than a distant surface. Therefore, to produce realistic lighting effects, our illumination model should take this intensity attenuation into account. Otherwise, we are illuminating all surfaces with the same intensity, no matter how far they might be from the light source. If two parallel surfaces with the same optical parameters overlap, they would be indistinguishable form each other. The two surfaces would be displayed as one surface. If we use the factor 1/d2 to attenuate intensities, it does not always produce realistic pictures. The factor 1/d2 produces too much intensity variations when d is small, and it produce very little variation when d is large. This is because real scenes are usually not illuminated with point light sources, and our illumination model is too simple to accurately describe real lighting effects.
Multiple Light Resources Example -- RGB Model
Transparency Model Diffuse Refraction Specular Refraction formula I = (1-Kt)Irefl+KtItrans Kt -- transparency coefficient (1-Kt) -- opacity factor A transparent surface, in general, produces both reflected and transmitted light. The relative contribution of the transmitted light depends on the degree of transparency of the surface and whether any light sources or illuminated surfaces are behind the transparent surfaces. Both diffuse and specular transmission can take place at the surfaces of a transparent object. Diffuse effects are important when a partially transparent surface, such as frosted glass, is to be modeled. Light passing through such materials is scattered so that a blurred image of background objects is obtained. Diffuse refractions can be generated by decreasing the intensity of the refracted light and spreading intensity contributions at each point on the refracting surface onto a finite area. These manipulations are time-consuming, and most lighting models employs only specular effects. Shell’s law
Snell’s Law
Fog - 雾化 Simple atmospheric effect A little better realism Help in determining distances between viewer and object
Fog - 雾化 Color of fog: color of surface: How to compute f ? 3 ways: linear, exponential, exponential-squared Linear:
Fog Example Often just a matter of Choosing fog color Choosing fog model Turning it on
Surface Rendering Shading(着色处理): do lighting (at vertices) and determine pixel’s colors from these Three types of shading: Flat 平面着色 Gouraud Phong Fast Phong 扁平着色处理以三角形为单位进行颜色计算,然后用这种颜色对三角形进行填充; Goraud着色处理首先计算三角形每个顶点处的光照,然后用顶点颜色通过插值来计算三角形内部各点的光照; Phong着色处理用三角形各顶点处的法向量通过插值的方式计算每个像素处的法向量,然后根据各个像素的法向量计算光照效果。
Surface Rendering Flat(平面绘制):以多边形的一个顶点或中心点计算RGB分量,然后用同种颜色对三角形进行填充 速度快,实现容易 如果用户想看到模型的刻面,可用此方法
Surface Rendering Gouraud:首先计算三角形每个顶点处的光照,然后用顶点颜色通过插值来计算三角形内部各点的光照 大多数图形硬件实现了该方法 速度几乎与flat方法一样 着色效果极大地依赖于所要绘制物体的细节层次 丢失高光,无法捕捉聚光效果以及马赫带效应(一定反差的图像边界部位在视觉上给人以特别白或特别黑的感觉 )
Surface Rendering Phong:用三角形各顶点处的法向量通过插值的方式计算每个像素处的法向量,然后根据各个像素的法向量计算光照效果 计算每个像素点的光照要比计算每个顶点的光照复杂得多且开销大 目前商业化的软件很少采用这种方法
Surface Rendering Example 扁平着色处理以三角形为单位进行颜色计算,然后用这种颜色对三角形进行填充; Goraud着色处理首先计算三角形每个顶点处的光照,然后用顶点颜色通过插值来计算三角形内部各点的光照; Phong着色处理用三角形各顶点处的法向量通过插值的方式计算每个像素处的法向量,然后根据各个像素的法向量计算光照效果。