Presentation is loading. Please wait.

Presentation is loading. Please wait.

Computer Graphics: Programming, Problem Solving, and Visual Communication Steve Cunningham California State University Stanislaus and Grinnell College.

Similar presentations


Presentation on theme: "Computer Graphics: Programming, Problem Solving, and Visual Communication Steve Cunningham California State University Stanislaus and Grinnell College."— Presentation transcript:

1 Computer Graphics: Programming, Problem Solving, and Visual Communication Steve Cunningham California State University Stanislaus and Grinnell College PowerPoint Instructor’s Resource

2 Lighting and Shading Making images with a more naturalistic appearance

3 Two Parts to This Chapter Lighting –Defining lights and materials to compute the colors for objects Shading –Defining how colors change across a polygon as it is displayed

4 Lighting Model We will use the local lighting model: all light comes from lights defined within the scene Light is seen to have three components: –Ambient light –Diffuse light –Specular light All light uses the RGB color model

5 Ambient Light This is light that is simply present in the scene, without reference to any source Ambient light models the overall light that is reflected among objects It is represented by a simple color value

6 Diffuse Light Diffuse light is light that comes directly from a light source and is then sent to the viewer by the object Its color depends on the nature of the object –The light is absorbed by the object’s material and only certain wavelengths are re-radiated

7 Specular Light Specular light is light that is reflected from a light source directly by an object It does not interact with the object and is generally the color of the light source The main characteristic of specular light is that it makes things look shiny

8 Each Light Has a position in space Has a color for each kind of light –Ambient color –Diffuse color –Specular color May have other properties –Spotlight –Directional light

9 Light Processes -- Ambient Light is simply present but involves objects Total ambient light A is a scene-defined ambient value L 0 plus the sum of the individual ambient lights Individual light contributions come from ambient light L A and material ambient value C A

10 Light Processes -- Diffuse Diffuse light depends on the direction of light because of area seen by light

11 Light Processes -- Diffuse (2) The area visible to light depends on the cosine of the angle to the light -- the dot product of the light and normal vectors The eye direction does not matter! With light diffuse value L D and materials diffuse value C D total diffuse light D is given by

12 Light Processes -- Specular Specular light depends on the angle between the eye and the reflection of a light

13 Light Processes -- Specular (2) Specular light also depends on the shininess M of the surface; this is modeled by a cosine function Since the cosine is the dot product ER, for light specular value L S, material value C S, and material shininess M, we have

14 Colored Lights A white cube, shown with three lights of different colors, illustrates how the light determines the color

15 Normals Normals are part of the geometry in the scene graph shape node Can be computed as the cross product of two adjacent edges If several polygons meet at a vertex, the normals for each polygon can be averaged Normals can also be computed exactly from directional derivatives if the object geometry is analytic

16 Effect of Shininess Higher values of the shininess coefficient M lead to smaller and brighter shiny spots From lower (left) to higher(right) values, we have

17 Defining Materials To define the material properties for your objects, you simply define the color for each lighting component and the value of the shininess These are all RGBA colors Materials are part of the appearance in the shape node

18 How Do You Use Lighting? In order to use lighting, you must have two things –You must have normals for each vertex of your objects –You must define the material for each object When you enable lighting, the lighting calculations we saw above will be done to create the color for each object

19 Light Properties Position - point in space Color - RGB values for each light component Directional (option) - direction of light Spotlight (option) - direction and cutoff Attenuation (option) - dropoff of values with distance

20 Lights in the Scene Graph As far as the scene graph is concerned, a light is just another piece of geometry However, the position and direction of a light are affected by any transformations in effect when they are set, so the usual practice is to define lights at the top of the scene graph, before any modeling transformations

21 Lights and Visual Communication You can enable or disable lights as you want to provide emphasis or to show things in different ways

22 Lights and Visual Communication (2) Using lighting can be effective in communicating information, as this lighted map of South Africa shows

23 Shading Computing the color of each part of a graphic object, especially a polygon We have properties at each vertex, and shading uses these to compute the color at each pixel in the object OpenGL offers only flat and smooth shading Other kinds are possible with more work

24 Flat and Smooth Shading Flat shading simply applies a single color to an entire polygon –Color can be set or can be computed from shading Smooth shading interpolates vertex colors across the polygon –Vertex colors can be set or computed

25 Shading Examples Flat shading on each polygon Smooth shading on each polygon

26 Shading Tradeoff Smooth shading on larger polygons vs flat shading on smaller polygons Tradeoff is both time and appearance

27 Other Shading Models Phong shading: interpolate the normals across a polygon and compute the color for each pixel directly Smooth (left) and Phong (right) compared

28 Anisotropic Shading Our original lighting model required that the reflection was the same in all directions In some real materials it is not, and anisotropic shading deals with that

29 Other Techniques Bump mapping

30 Global Illumination For simple computer graphics, we usually only deal with local illumination and let all light come only from lights Global illumination considers not only how light comes into a scene, but also how light is reflected within a scene More complex, but more realistic Two main algorithms: radiosity and photon mapping

31 A Radiosity Example

32 A Photon Mapping Example


Download ppt "Computer Graphics: Programming, Problem Solving, and Visual Communication Steve Cunningham California State University Stanislaus and Grinnell College."

Similar presentations


Ads by Google