Computer Graphics Ken-Yi Lee National Taiwan University (the slides are adapted from Bing-Yi Chen and Yung-Yu Chuang)
Illumination and Shading Illumination Models Phong Illumination Model Shading Models for Polygons Shadows Transparency Global Illumination Recursive Ray Tracing Radiosity The Rendering Pipeline
Illumination Models Interaction of light with the surface. Viewing Objects (Shape & Color) Light Sources Reflectance
Light Source Models Real light sources are complicated. General light sources are difficult to work with. The number of light paths between a light source and a point on the surface may not be only one but infinity.
Simple Light Source Models Point Light Position and Color (Intensity) Directional light Direction and Color (Intensity) Spotlight Direction, Cone angle, Color (Intensity), etc. Ambient Light Color (Intensity) Less parameters Efficient computation Less parameters Efficient computation
Illumination Models Interaction of light with the surface. Reflectance Light Sources
Interaction of Light with a Point Incident Light Reflected Light Normal Surface Refracted Light Absorption Reflection Refraction
Reflectance Models smooth surfacerough surface
Simple Reflectance Models Specular Reflectance Diffuse Reflectance (Lambertian)
[Recap] Illumination Models Interaction of light with the surface. Viewing Objects (Shape & Color) Light Sources Reflectance
Direct/Indirect Lighting Direct LightingDirect + Indirect Lighting
Local/Global Illumination Local Illumination Only consider the relationship between light sources and a single primitive When you calculate the illumination, you won’t need the information of any other primitive. Global Illumination Consider the relationship between light sources and all primitives When you calculate the illumination, you should take other primitives into account.
Phong Illumination Model A local illumination model that can be computed rapidly Three components: Ambient (Indirect lighting) Diffuse Specular ambientdiffuse specular
Ambient Component The component approximates the indirect lighting by a constant. : ambient light intensity (color) : ambient reflection coefficient (0 ~ 1) : color of the object Light Source PropertyMaterial Property
Diffuse Component The component describes the diffuse reflection of rough surfaces. : intensity (color) of the point light source : diffuse reflection coefficient (0 ~ 1) : color of the object θ N Lambertian Cosine Law
Examples Diffuse reflection component with different ambient and diffuse reflection components with different and
Specular Reflectance
Specular Component The component describes the specular reflection of smooth (shiny/glossy) surfaces. : intensity (color) of the point light source : specular reflection coefficient (0 ~ 1) : shininess N R V L
Shininess ( ) n=1 n=2 n=3 n=10
Examples
Comparison diffusediffuse + specular
Phong Illumination Model ambientdiffuse specular ambientdiffusespecular
Light Source Attenuation Light source attenuation determines how fast the light intensity (color) decreases with distance. : attenuation factor : constant, linear, and quadratic attenuation coefficient : distance from light source to object
Phong Illumination Model N R V L θ
Reflection Vector ( )
The Halfway Vector ( ) (Blinn-Phong)
Multiple Light Sources If there are light sources, then
Shading Models for Polygons Why we need shading ? Shading models: Flat Shading Gouraud Shading Phong Shading
Flat Shading Same normal, light vector and view vector across whole polygon Compute illumination only once for each polygon
Gouraud Shading Interpolate the intensities computed at vertices
Intensity Interpolation
Comparison Flat Shading Gouraud Shading
Smoothed Normal Vector Gouraud Shading Phong Shading
Interpolate the normal vectors of vertices, and compute illumination at each pixel
Normal Interpolation
Gouraud v.s. Phong Shading GouraudPhongGouraudPhong
Flat Shading
Gouraud Shading
Phong Shading
Texture Mapping = Pattern Mapping
Bump Mapping & Displacement Mapping Copyright©2003, Microsoft
The Rendering Pipeline Local Illumination Pipelines z-buffer and Gouraud shading z-buffer and Phong shading list-priority algorithm and Phong shading
Rendering Pipeline for z-buffer & Gouraud shading (OpenGL) Viewing transformation db traversal Modeling transformation Trivial accept / reject LightingClipping Divide by W, map to 3D viewport RasterizationDisplay
Rendering Pipeline for z-buffer & Phong shading (OpenGL with GLSL) Viewing transformation db traversal Modeling transformation Trivial accept / reject Clipping Divide by W, map to 3D viewport Rasterization (with lighting) Display
Rendering Pipeline for list-priority algorithm & Phong shading Viewing transformation db traversal Modeling transformation Trivial accept / reject Clipping Divide by W, map to 3D viewport Rasterization (with lighting) Display Preliminary visible-surface determination New db New db traversal
Global Effects Some global effects are very important to visual quality. Therefore, we may want to utilize the existing rendering pipeline (local illumination model) to add (approximated) global effects. Use multiple passes with per-pixel buffers Common global effects : Shadow Transparency
Shadows How to determine ? Shadow mapping Not accurate enough Shadow volumes Performance issues
Scan-Line Generation of Shadows Viewer Light Current scan line A A’A’ B a b c d
Shadow Volumes Light Object A B C shadow polygons
Shadow Volumes z x A B C V
Transparency Blending Z-buffer Turn off
Global Illumination Popular methods: Ray Tracing Static view View-dependent effect Radiosity Static light (diffuse scene) from Wikipedia
Ray Tracing
Recursive Ray Tracing Only consider three directions: Perfect reflected ray Perfect refracted ray Shadow ray Perfect reflected ray Shadow ray Perfect refracted ray
Reflection
Ray Tracing Results
Monte Carlo Ray Tracing Randomly select one direction: Tracing ray Shadow ray
Ray Tracing Results
Radiosity Split the scene into many patches Simulate light transmission between every patch pair. Assume diffuse reflectance
The Radiosity Equation (1) : radiosity of patch : rate at which light is emitted from patch : reflectivity of patch : form factor (configuration factor) : area of patch since thus
The Radiosity Equation (2) rearranging terms therefore progressive refinement
Computing Form Factors visible or invisible 1 0
Hemisphere
Hemicube
Rendering Pipeline for radiosity & Gouraud shading (OpenGL) Viewing transformation db traversal Modeling transformation Trivial accept / reject Clipping Divide by W, map to 3D viewport RasterizationDisplay Vertex intensity calculation using radiosity method New db New db traversal
Rendering Pipeline for ray tracing db traversal Modeling transformation Ray tracingDisplay