graphics ii 91 547 shadow maps reflections n.
Skip this Video
Loading SlideShow in 5 Seconds..
Graphics II 91.547 Shadow Maps Reflections PowerPoint Presentation
Download Presentation
Graphics II 91.547 Shadow Maps Reflections

Loading in 2 Seconds...

play fullscreen
1 / 31

Graphics II 91.547 Shadow Maps Reflections - PowerPoint PPT Presentation

  • Uploaded on

Graphics II 91.547 Shadow Maps Reflections. Session 5. Shadow Maps. Light Source. Objects. Eye Point. Shadow Maps: The algorithm. 1. Transform the scene objects to the light source coordinates (x’,y’,z’). 2. Disable color buffer writing and render the scene

I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
Download Presentation

PowerPoint Slideshow about 'Graphics II 91.547 Shadow Maps Reflections' - xaria

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.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
shadow maps
Shadow Maps

Light Source


Eye Point

shadow maps the algorithm
Shadow Maps:The algorithm

1. Transform the scene objects to the light source

coordinates (x’,y’,z’).

2. Disable color buffer writing and render the scene

objects into the z - buffer

3. Copy this buffer into a “shadow z - buffer”

4. Transform the scene back to the eye coordinates (x,y,z).

5. Render the scene. At each pixel, if a point on a surface

is deemed to be visible, it is transformed into light source

coordinates: (x,y,z) -> (x’,y’,z’). The x’ and y’ coordinates

are used to index into the shadow z-buffer and z’ is compared

with the z value in the buffer. If z’ is greater than this

value, the point is in shadow and it is rendered as if the

light is turned off.

6. Repeat for other light sources, and accumulate color

shadow maps tradeoffs
Shadow MapsTradeoffs
  • Excellent for situations when shadowing and shadowed objects are both complex
  • Some graphics systems do not provide necessary primitives or buffers
  • Aliasing is a problem
    • Possible solutions
      • Use high - resolution shadow z buffer
      • Jitter shadow texture to smooth out edges
  • Difficult to find appropriate projection when light source is in the middle of scene objects
finite light sources produce soft shadows
Finite light sources produce“soft shadows”

Finite size

light source



simulating finite size light source by multiple point sources dithering
Simulating finite size light source byMultiple point sources: “dithering”

Light source moves in grid


Object (polygon)

Plane of projection

Shadows are “accumulated”

the accumulation buffer
The Accumulation Buffer

Color Planes

Color data

Accumulation Buffer

accumulation buffer use
Accumulation buffer use:

void glAccum(glenum op,glFloat value);


GL_ACCUM reads each pixel from buffer currently selected for

reading and multiplies RGBA values by value and adds

the result to accumulation buffer.

GL_LOAD reads each pixel from the buffer currently selected for

reading, multiplies RGBA values by value and replaces values

in accumulation buffer.

GL_RETURN takes values from the accumulation buffer, mutiplies

them by value, and places them in the color buffer.

GL_ADD, GL_MULT adds or multiplies the value of each pixel in

the accumulation buffer by value and returns it to the

accumulation buffer.

accumulation buffer op gl accum
Accumulation Bufferop = GL_ACCUM


Color Planes

Accumulation Buffer



accumulation buffer op gl load
Accumulation Bufferop = GL_LOAD


Color Planes

Accumulation Buffer


accumulation buffer op gl return
Accumulation Bufferop = GL_RETURN


Color Planes

Accumulation Buffer


accumulation buffer op gl mult
Accumulation Bufferop = GL_MULT


Accumulation Buffer



Direct ray

Eye point



Plane of Reflection

reflection transformations the general case constructing the transformation
Reflection Transformations:the general case - constructing the transformation

Inverse transformation

Reflection across

X - Z Plane

Transformation to

move reflecting

plane to X - Z plane

reflections visibility issues
Reflections:Visibility Issues

Real Cone

Real Ball


Finite Size



Reflected Ball

Not Visible

Reflected Cone

reflections visibility issues1
Reflections:Visibility Issues

“Reflected Cone”

Should not be visible


Finite Size



Real Cone

Should be obstructed by

reflecting object

solution to visibility issues use stencil and z buffer
Solution to visibility issues:use stencil and z buffer

The algorithm:

1. Disable the depth test

2. Set stencil operation to replace with 1

3. Draw the reflecting polygon

4. Set the stencil operation to only draw where stencil=1

5. Multiply reflecting transformation onto modelview matrix

6. Enable depth test, render objects. Clip objects that are on

opposite side of the reflecting plane from eyepoint.

7. Disable stencil test

8. Remove reflection transformation from modelview

9. Disable writing to color buffer

10. Draw the reflecting polygon

11. Enable writing to color buffer

12. Render the scene (unreflected)

calculation of texture coordinates
Calculation of Texture Coordinates

For each vertex, the reflected vector direction is given by:

Let m be defined as:

The texture coordinates are given by:

sphere mapping the opengl algorithm
Sphere Mapping:The OpenGL Algorithm

1. Bind the texture containing the sphere map.

2. Set sphere mapping texture coordinate generation:





3. Enable texture coordinate generation:



4. Draw the object, providing correct normals on a per-

face or per-vertex basis.

obtaining the sphere map manually
Obtaining the Sphere Map Manually

Reflective Sphere at

object location