1 / 14

Chapter 5: Lighting and Shading

Chapter 5: Lighting and Shading. Rendering for Visual Realism Ambient Illumination Diffuse Reflection Specular Reflection Light Source Attenuation Gouraud Shading Phong Shading. Rendering for Visual Realism Mach Banding.

zoltan
Télécharger la présentation

Chapter 5: Lighting and Shading

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Chapter 5: Lighting and Shading • Rendering for Visual Realism • Ambient Illumination • Diffuse Reflection • Specular Reflection • Light Source Attenuation • Gouraud Shading • Phong Shading Chapter 5: Lighting and Shading

  2. Rendering for Visual Realism Mach Banding Producing realistic images frequently requires overcoming the physical limitations of technology and accommodating the sensitivities of human visual perception. For example, the figure at left represents 16 vertical bars, each colored with a slightly different shade of yellow. The figure at left is exactly the same, but with the borders between the vertical bars removed. The striping effect seen here, known as Mach banding, is caused by the eye’s tendency to overreact to discontinuities in intensity. Chapter 5: Lighting and Shading

  3. Rendering for Visual Realism The Complexity of Illumination Models As we advance to the lighting and shading effects of an illumination model, many complex facts must be determined: • How does the light strike the object? • What material properties does the object have? • Are the items between the object and the viewer transparent? If so, what refractive qualities do they have? • Is the object reflective? If so, what neighboring items reflect off the surface of the object? • Do any items cast shadows across the object? • Are any neighboring items so brightly colored that the lighting causes their colors to “bleed” onto the object? Chapter 5: Lighting and Shading

  4. Ambient Illumination To avoid having the parts of an object facing away from a light source appearing completely black, it is necessary to model ambient illumination, like the light that is scattered back onto the object from its surroundings. The equation for the illumination due to ambient light may be approximated as: where Ia is the intensity of the ambient light (assumed to be constant for all objects), and ka is the ambient reflection coefficient for the particular material of each object. (Note: This simplistic model will be replaced when we examine radiosity in Chapter 11.) Image with ambient illumination only Chapter 5: Lighting and Shading

  5. Diffuse Reflection To illuminate an object so that its brightness varies according to the direction of the light source, we can model diffuse reflection, using , the angle between the normal vector to the surface and the vector from the surface to the light, as a parameter. The equation for the illumination due to diffuse reflection may be approximated as: where Ip is the intensity of the light source (assumed to be constant for all objects), and kd is the diffuse reflection coefficient for the particular material of each object. Image with diffuse reflection only Chapter 5: Lighting and Shading

  6. Diffuse Reflection Combining Ambient Illumination and Diffuse Reflection High diffuse/med. ambient High diffuse/low ambient Dramatically different images are produced by combining ambient illumination with diffuse reflection, using the formula: Low diffuse/low ambient Med. diffuse/med. ambient High diffuse/high ambient Chapter 5: Lighting and Shading

  7. Specular Reflection Until now, our illumination model is not affected by the viewer’s position. This changes when we consider specular reflection, the degree to which the object’s shiny surface reflects light into the viewer’s eyes. The formula becomes: where ks is the specular reflection coefficient for the particular material of each object, n is the specular reflection exponent (which indicates how focused reflected highlights are on each object’s surface), and  is the angle between the light’s reflection vector off of the surface and the vector from the surface to the viewer. Image with specular reflection only Chapter 5: Lighting and Shading

  8. Specular Reflection Effects of Specular Coefficient and Exponent INCREASING SPECULAR COEFFICIENT Notice the smaller “hot spots” on the shinier objects. INCREASING SPECULAR EXPONENT Chapter 5: Lighting and Shading

  9. Light Source Attenuation The illumination model doesn’t handle attenuation, the tendency for illumination to dissipate with the distance from the light source. An attenuation factor, fatt, can be inserted into the formula as follows: fatt is usually constant, inverse linear in the distance from the light, or inverse quadratic in the distance from the light. Linear/Near Linear/Far Linear/Medium Constant Quadratic/Near Quadratic/Medium Quadratic/Far Chapter 5: Lighting and Shading

  10. Gouraud Shading Our illumination model permits us to shade objects, assuming that we know the scene’s lighting conditions, the objects’ material properties and location, and (most difficult of all) normal vectors at every point on the object. • The Gouraud Smooth Shading Algorithm: • Calculates average vertex normal vectors. • Performs illumination calculation to get vertex colors. • Interpolates vertex colors across each polygonal face. • Tends to suffer from Mach banding. • May miss highlights within a polygonal face. Chapter 5: Lighting and Shading

  11. Gouraud Shading The Algorithm Approximate the normal vector at each vertex by averaging the normal vectors at each face containing that vertex. Compute the shading at each vertex using the illumination model. For each scanline, interpolate the shading for the endpoints by using the calculated shading for the vertices. Then interpolate the shading for the internal scanline points by using the endpoint shading values. Continue this process for the entire face. Chapter 5: Lighting and Shading

  12. Phong Shading • The Phong Smooth Shading Algorithm: • Calculates average vertex normal vectors. • Interpolates vertex normal vectors across the face. • Performs illumination calculation at each pixel. • Produces more accurate highlights. • Yields fewer Mach Band effects. Chapter 5: Lighting and Shading

  13. Phong Shading The Algorithm Approximate the normal vector at each vertex by averaging the normal vectors at each face containing that vertex. For each scanline, interpolate the normal vector for the endpoints by using the normal vector approximations for the vertices. Then interpolate the normal vectors for the internal scanline points by using the endpoint normal vectors. Continue this process for the entire face. Use the illumination model to compute the shading at each point in the face. Chapter 5: Lighting and Shading

  14. Non-photorealistic Shading Programmable shaders enable real-time lighting models that are realistic, as well as real-time lighting models that produce non-photorealistic shading effects. A Phong-shaded object. A color Phong-shaded object. Metal milling is simulated by mapping stripes of varying intensity along the parametric axis of maximum curvature and linearly interpolating the colors between the stripe centers. Cool-to-warm hue shift, with highlights, but without edge lines. Cool-to-warm hue shift, with highlights and edge lines. White object with color simulated via 2 color lights, one adding warmth at original light position and one adding cool at its negative position. Edge lines are drawn wherever normal vectors experience dramatic shifts between adjacent pixels. Shifting the colors to a cool-to-warm undertone by adding a blue-to-yellow tone. Chapter 5: Lighting and Shading

More Related