1 / 14

Introduction to Lighting

Introduction to Lighting. Glenn G. Chappell CHAPPELLG@member.ams.org U. of Alaska Fairbanks CS 381 Lecture Notes Monday, November 10, 2003. Where Are We?. We have covered: Chapter 1. Intro. to CG. Chapter 2. Basic CG Programming. Chapter 3. GUI’s & picking. Chapter 4. Transformations.

Télécharger la présentation

Introduction to Lighting

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. Introduction to Lighting Glenn G. ChappellCHAPPELLG@member.ams.org U. of Alaska Fairbanks CS 381 Lecture Notes Monday, November 10, 2003

  2. Where Are We? • We have covered: • Chapter 1. Intro. to CG. • Chapter 2. Basic CG Programming. • Chapter 3. GUI’s & picking. • Chapter 4. Transformations. • Chapter 5. 3-D Viewing. • Now we head into Chapter 6 and the last big* topic of the class: lighting. • A.k.a. “shading”. *There will be more little topics, however. CS 381

  3. Introduction to Lighting:Three Issues • Remember the three issues in 3-D CG: • Viewing and Transformations • This is what we have spent the last 4 weeks on. • Hidden-Surface Removal • We still have not taken a close look at this. • However, depth buffering works well, is easy to use, and usually requires little thought. • Lighting • This is what we begin today. CS 381

  4. Introduction to Lighting:Lighting in the Pipeline *Well, most of it goes here, anyway. Model/view Transformation Lighting* Projection Transformation Clipping(view-frustum) Viewport Transformation ObjectCoordinates WindowCoordinates WorldCoordinates EyeCoordinates VertexOperations Rasterization FragmentOperations Vertex enters here To framebuffer Vertices(objectcoord’s) Vertices(windowcoord’s) Fragments Fragments Convert vertex data to fragment data Depth test, etc. CS 381

  5. Introduction to Lighting:How Light Travels • Where does light come from? • Light comes (initially) from a light source. • After that, light generally moves in straight rays. • However, light can change direction, due to: • Reflection. • Bouncing off an object. • Refraction. • Changing direction when the mediumchanges, or when moving from onemedium to another. • Diffraction. • Bending around an object. • The apparent color of an object depends on the light that eventually reaches our eyes. CS 381

  6. Introduction to Lighting:Ray Tracing (?) • Based on this, a reasonable way to determine how light affects a scene is to follow the paths of rays. • We are only interested in the rays that reach our eyes. • So, follow rays backward from the eye, see which objects they came from, reflect/refract/etc., and determine the color. • This is called ray tracing. • Ray tracing makes great images , but it is very slow.  • It also does not work with our polygon-based rendering methods.  • So, instead of doing light “right”, we simplify and approximate. • We simplify a lot. • The actual lighting computations that we end up doing will be quite unrealistic from a physics point of view. • But they will produce pretty decent images. • Now we look at simplified ways of dealing with: • Surfaces. • Light sources. CS 381

  7. Introduction to Lighting:Simplified View of Surfaces • We identify broad categories of surfaces. • Specular Surfaces • These surfaces act like mirrors. • Some light can be absorbed. • Light that does reflect bounces off at a single angle. • Angle of incidence = angle of reflection. • Diffuse Surfaces • These surfaces scatter light in all directions. • We generally assume a perfectly diffuse, or Lambertiansurface, which scatters light equally in all directions. • Translucent Surfaces • These allow some light to penetrateand emerge somewhere else. • In practice, we generally model a surface as some combination of these three. Angle of incidence Angle of reflection CS 381

  8. Introduction to Lighting:Simplified View of Light Sources • A light source is … a source of light. • Light sources emit light. • Other objects are lit by light emitted form light sources. • Light from a source has a 3-component luminance (light color): • R, G, and B, as usual. • We classify light sources as: • Point sources. • A point source has a position (point: x, y, z)in 3-D space. Homogenous form: (x, y, z, 1). • A spotlight in addition only emits light in orclose to a certain direction. • Realistically, incident light intensity is inverselyproportional to the square of the distance of anobject from the source. • Sources “at infinity”. • Such a distant light source has a direction(vector: x, y, z). Homogeneous form: (x, y, z, 0). • Ambient light. • Approximate light bouncing around in the sceneusing dim light coming equally from all directions. CS 381

  9. Introduction to Lighting:What Is Left Out? • Our simplified view of surfaces and light sources does not include: • Shadows. • Light bending due to refraction or diffraction. • Rough surfaces that do not scatter light equally in all directions. • Like just about everything. • But especially: fur, brushed metal. • Shaped light sources. • Like light bulbs. • And we will simplify even further … CS 381

  10. Introduction to Lighting:Towards Practical Lighting • In practice, we want to work with: • A simple description of a light source. • A simple description of the material of a surface. • The normal vector at a vertex. • Then we do lighting computations at each vertex. • Colors in the interior of polygons are determined by interpolating (lirping, usually). • Now we look at how to do some of the actual computations. CS 381

  11. Introduction to Lighting:Computations — Ambient • How to compute the effect of ambient lighting on a vertex color? • We need: • The light color of the ambient light (AR, AG, AB). • The paint color of the material of the surface the vertex lies on (MR, MG, MB). • The resulting color is found via componentwise multiplication: (ARMR, AGMG, ABMB). • This operation is very common in lighting computations. • It is used in diffuse and specular reflection as well (along with some trigonometry). CS 381

  12. Introduction to Lighting:Computations — Diffuse [1/2] • How to compute the effect of diffuse reflection on a vertex color? • We need: • The light color of the direct light (DR, DG, DB). • The paint color of the surface the vertex lies on (MR, MG, MB). • Assume a Lambertian surface. • But now the orientation of the surface matters. • We need a normal vector. • This is a (unit) vector that points straight out from the surface. • The direction of the light source matters, too. • For a source at infinity, the direction is its direction vector (normalized!). • For a positional point source, the direction is the source position minus the vertex position (then normalize!). • A thought: Positional light sources need to be placed in the 3-D world. So we use model/view for them, too. • The distance to the light source matters as well, but we will ignore it for the moment. CS 381

  13. Introduction to Lighting:Computations — Diffuse [2/2] • If a light source illuminates a Lambertiansurface, then the intensity of the reflectedlight is proportional to the cosine of theangle between the surface normal vectorand the light-source direction vector. • This is called the Lambert cosine. • If the vectors both have length 1,then it is just their dot product. • If the dot product is negative, then thelight source does not illuminate the surface. • Put it all together: • Ignore the distance to the light source, for now. • Let k be the Lambert cosine. • If k 0, then the RGB color of the vertex is (kDRMR, kDGMG, kDBMB). • Otherwise, the color is (0, 0, 0). Surfacenormalvector Surfacenormalvector Light-source direction vector CS 381

  14. Introduction to Lighting:What Else Do We Need? • We almost have a workable lighting method. We still need: • Normal vectors (how to compute them?). • A method for computing specular reflection. • A way to take all these separate color computations (ambient, diffuse, specular) and put them together to form a single color for a vertex. • A way to handle translucency. • The good news is that, except for computing normal vectors, all this (ambient, diffuse, specular, translucency) is supported by OpenGL. • So most of the lighting computations can be done by OpenGL, not by us. CS 381

More Related