Illumination Model 고려대학교 컴퓨터 그래픽스 연구실
Shading Compute the radiance for each object Figure out which pixels to fill Determine a color for each filled pixel
Illumination Components Emission at light sources Scattering at surfaces Wireframe Without Illumination With Illumination
Light Source Model Simple mathematical models Point light Directional light Spot light
Point Light Source Omni-directional point source, ex) bulb Intensity (I) Position (px, py, pz)
Directional Light Source Point light source at infinity, ex) sun Intensity (I) Direction (dx,dy,dz)
Spot Light Source Point light source with direction, ex) Luxo Intensity (I), Position (px, py, pz) Direction (dx, dy, dz)
Light Intensity Function IE: emitted intensity for light sources KA, KD, Ks Ambient / diffuse / specular reflection coefficient IAL: ambient light intensity N: unit normal vector L Unit direction vector to the point light source from a position on the surface IL: the intensity of the point light source V: unit viewing direction vector R: specular reflection vector
Reflectance Model Simple analytic model Diffuse reflection Specular reflection Emission Ambient
Diffuse Reflection Surface reflects equally in all directions With equal intensity
Diffuse Reflection How much light is reflected? N L Depends on angle of incident light dL = dA cos = N L Maximum at the head-on light ( = 0) N L
Specular Reflection Strongest reflection near the mirror angle Examples: mirrors, metals
Specular Reflection How much light is reflected? Depends on Angle of incident light Angle to viewer
Ks: Specular Reflectance Factor Specular Reflection Phong model {cos(a)}n = (VR)n n: exponent Ks: Specular Reflectance Factor
Effects of Exponent Ambient Exponent(n)
Emission Light emitting directly from surfaces ex) light source
Ambient Term Compensated reflection of indirect illumination
Reflectance Model Simple analytic model Diffuse reflection Specular reflection Emission Ambient
Reflectance Model Simple analytic model Diffuse reflection Specular reflection Emission Ambient Affected by the position of the light source Not affected by the position of the light source
Ambient and Diffuse Ambient Diffuse
Surface Illumination Calculation Single light source
Surface Illumination Calculation Multiple light sources Not Affected
Shadows Which light sources are blocked Cast ray towards each light source Li Si = 0 if ray is blocked, Si = 1 otherwise Shadow Term
Transparency Alpha value Back to front How much light can be transmitted? Back to front
Polygon Shading Spatial coherence Illumination calculations for pixels covered by the same primitive
Flat Shading Constant-intensity shading OK for polyhedral objects Not so good for ones with smooth surfaces
Flat Shading Process One illumination calculation per polygon Assign all pixels inside each polygon the same color Polygon Normal Vector
<Gouraud Shading> Intensity-interpolation scheme Produces smoothly shaded polygonal mesh Piecewise linear approximation To capture subtle lighting effects Needs fine mesh Phong shading solves it <Flat Shading> <Gouraud Shading>
Mesh with Shared Normals at Vertices Gouraud Shading Polygonal mesh with the vertex normal vectors Smooth shading over adjacent polygons Curved surfaces Illumination highlights Soft shadows Mesh with Shared Normals at Vertices
Gouraud Shading Process (1/2) One lighting calculation per vertex Assign pixels inside polygon By interpolating colors computed at vertices N1 Viewer L1 Light V1 N2 N3 Polygon Vertex Normal Vector
Gouraud Shading Process (2/2) Bilinearly interpolate colors at vertices Down and across scan lines I1 I I2 I3
Vertex Normal Vector Average of the surface normals For each polygon sharing that vertex N2 N1 N3 N4
Phong Shading Normal-vector interpolation shading Subtle illumination effects in polygon interiors
Phong Shading Process (1/2) One lighting calculation per pixel Approximate surface normals for inside points N1 Viewer L1 Light V1 N2 N3 Polygon
Phong Shading Process (2/2) Bilinearly interpolate surface normals at vertices Down and across scan lines N1 N α β γ N2 N3
Various Shading Results <Wireframe> <Flat> <Gouraud> <Phong>
Ray Casting & Tracing Independent lighting calculation for every pixel
Ray Casting & Tracing
Ray Casting Find surface intersection point Visible surface detection Ray from eye to the screen pixel No reflection or refraction Direct illumination Visible surface detection Shadow calculation
Ray Tracing Recursive ray casting Inter-object light reflection effects Global (mutual) illumination For global reflection and transmission Highly realistic quality vs. computation time Overview Bounce (reflect) or refract the ray Collecting its intensity At each reflection point
Ray Tracing Example <Reflection and refraction ray paths through a scene for a screen pixel>
<Ray Tracing Tree> Left branch: reflection Right branch: transmission (refraction) Terminate when Reaches the defined maximum depth Strikes the light sources Accumulate the intensity From the bottom to top <Ray Tracing Tree>
Summary Polygon shading Ray casting Ray tracing Radiosity Flat shading Gouraud shading Phong shading Ray casting Ray tracing Recursive ray casting Inter-object reflection (global illumination) Highly realistic quality vs. computation time Radiosity Supported by OpenGL
For Implementation
Intensity Calculation For general object, IE = 0 IAL ≠ IE Intensity calculation for RGB channel (IR, IG, IB) KAR, KDR, KSR, KAG, KDG, KSG, KAB, KDB, KSB
Shading Function Example IE = 0, KA = 0.2, KD = 0.4, KS = 0.1, IAL = 0.3, I0 = 0.8, n = 32 N1 N2 N3
Scan-line Shading Example 2 1.5 2 1 N2 1 1 N3 P2 P3
Flat Shading Example N1 P1 N N2 N3 P2 P3
Gouraud Shading Example I4=(I1*1+I2*2)/3 2 I5=(I1*1+I3*1.5)/2.5 1.5 2 1 N2 1 I=(I4*1+I5*2)/3 1 N3 P2 P3 I3 I2
2 1.5 2 1 1 N=(N4*1+N5*2)/3 1 Phong Shading Example N1 P1 N2 N3 P2 P3