CAP5937 - Realtime Graphics for Simulation and Games

Lecture 7: Lighting and Shadows

J. Michael Moshell

This lecture is based on Chapter 6 of the Trujillo textbook, as well as extra material about shadow algorithms.

Query 7.1. What is the Ramp lighting model? See if you can figure out why a ramp model would take less time to execute than a model based on RGB lighting? It would seem that to compute the R G and B components of the diesplayed color, you have to multiply the material color's R, G and B values (at screen location (x,y) inverse projection-mapped onto the object's surface texture map) times two numbers: W the weight, and some value representing its illumination.

W is a number containing the cosine terms associated with the specular or diffuse model, as well as the interpolation values for Gouraud shading. Of course W's cosine terms are much more cheaply computed for Gouraud than for Phong shading, but D3D doesn't know Phong anyhow.
Why should it matter if the three components are multiplied by the same or different values?
 

The following query should be review for you; it's about how to efficiently implement bilinear interpolation such as is used in the Gouraud rendering technique.

Query 7.2: Show how, within a  two dimensional loop over  0<=i<=m  and 0<=j<=n, the expression

v = a*i + b*j + k

can be evaluated for an average cost of only slightly over one addition per pixel.
 

Query 7.3. Does it matter to which frame an ambient light source is added?
 

Point Lights


Query 7.4. Page 302: "More calculation is necessary to render scenes that contain point lights." More than what?
 

Query 7.5. Run the firefly demo. Why can you see the point source? Explain what you see happening to the inside of the cup.

Query 7.6. You don't really have the information to answer this one yet, but give it a good guess. Why does the Firefly demo use two moving frames, 'dummyframe' and 'lightframe'? A single frame can contain both a translation and a rotation, but they've broken the transformations into two frames (other than the world frame) here.

The SpaceStation Demo shows directional lights and a few other whiz-bang features such as rolling the camera's UP vector.

The SpaceDonut Demo shows the wierd system called parallel point lights, which sort of 'radiate outward' from a point (or actually, I should make a query:0

Query 7.7. Describe  the effect of parallel point lights more carefully than the text's (non)-description. If light REALLY flowed in a particular direction (and its anti-direction) from a single point, what would the illumination pattern look like? So what is really going on here?

Spotlights are pretty straightforward too. So, let's pose a thought question.

Query 7.8. Case 1: a scene containing m point lights and n mesh objects. Case 2: scene containing m spotlights and n mesh objects. Discuss the cost of rendering Case 1 versus Case 2. In other words, how are spotlights implemented and what does it cost? You can either deduce the answer, or go look it up in your old graphics textbook if you have one.
 

Shadows.

Direct 3D shadows are just sneaky tricks to make things go fast. But it's interesting to consider how it might work. You specify a light source, a mesh to be shadowed, and a point and surface normal for the plane onto which the shadow is to be cast.

Query 7.9. What happens? Does Direct3D then perform a polygon scan conversion on every triangle in the mesh being shadowed? I sorta doubt it. Experiment with shadowing. Substitute a simple object such as the sphere, for the fork and examine its shadow with no spinning going on. What does it actually do?

See if you can identify which of the techniques described in the Foley & Van Dam handout, are in use here. You might try adding a second point light source and positioning it to produce a penumbra effect, to see what happens when two shadows partially overlap.

To the syllabus
To lecture 6
To lecture 8