1 / 14

Shadows

Shadows. David Luebke University of Virginia. More On Textures. Multitexturing Modern hardware can read from multiple textures at once, even with mipmapping Detail texturing Light mapping Bump mapping Normal maps versus bump maps Can have detail bump maps Environment mapping. Shadows.

binta
Download Presentation

Shadows

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. Shadows David Luebke University of Virginia

  2. More On Textures • Multitexturing • Modern hardware can read from multiple textures at once, even with mipmapping • Detail texturing • Light mapping • Bump mapping • Normal maps versus bump maps • Can have detail bump maps • Environment mapping

  3. Shadows • An important visual cue, traditionally hard to do in real-time rendering • Outline: • Notation • Planar shadows • Soft shadows • Projective shadows • Shadow volumes • Shadow maps • Shadow optimizations

  4. Notation • Light source • Point vs area • Occluders & receivers • Identify ahead of time? • Self-shadowing? • Shadow • Umbra • Penumbra • Soft vs hard shadows

  5. Planar Shadows • Old trick: project the occluder geometry to a plane and render over ground plane • Can do with a matrix • Z-bias issues • Semiopaque shadows harder • Stencil and Z-buffer tricks • Another option: generate textured rectangle • Problems • Light source inside object (Antishadows) • Only planar receivers  no self-shadowing

  6. Planar Soft Shadows • Basic idea: • Sample light source multiple times, average results (accumulation buffer) into a texture • Gooch et al: move plane up and down • Nested shadows fewer passes

  7. Projective Shadows • Render scene from light’s point of view • Render all occluders as black • Can turn off depth buffer etc • Project onto receiver polygons using projective texture mapping • Works for curved surfaces • Designer separates occluders and receivers  no self-shadowing

  8. Shadow Volumes • Basic idea: • Create polygonal objects to represent shadowed volumes • Make clever use of stencil buffer so that these objects affect what lighting is done

  9. Shadow Volumes • Details of the basic algorithm: • Compute shadow volumes • View-independent! • Clear stencil buffer • Render the scene without diffuse/spec lighting • “Render” front faces of shadow volumes • Turn off color, depth updates (but leave depth test on) • Visible polygons increment pixel stencil buffer count • “Render” back faces of shadow volumes • Turn off color, depth updates (but leave depth test on) • Visible polygons decrement pixel stencil buffer count • Render scene with only diffuse/spec lighting • Only update pixels where stencil = 0

  10. Shadow Volumes • Refinements (see book) • NV30, XBox supports signed stencil addition • Two-sided lighting determines whether polygon adds or subtracts 1 from stencil buffer • One-pass algorithm! But a little slower in practice? • What if you’re inside a shadow volume? • Invert meaning of stencil test • What if near clip intersects shadow plane? • Carmack, others: use z-fail test • Clever extensions in NV2X help this idea out • Creating shadow volumes: vertex program! • ATI: clever degenerate-edge trick again

  11. Shadow Volumes • Advantages: • Robust • Self-shadowing • GPU • Disadvantages: • Geometry limited • Stencil polys • Multi-pass scene geometry • Stencil test – per pixel expense • Hard shadows

  12. Shadow Maps • Idea: • Render scene from light source, read Z-buffer • Result: discretized image (shadow map) telling distance of objects to light source • Render scene normally • At each pixel, calculate distance D to light • Compare to distance S stored in shadow map • If D=S, surface lit by light, else in shadow

  13. Shadow Maps • The basic algorithm • Render scene with ambient lighting only • Read Z-buffer, transform values into coordinate system of light • Use comparison to set alpha buffer • Render w/ diffuse and specular components, multiplying by alpha

  14. Shadow Maps • Advantages: • Hardware-accelerated general shadow algorithm • Supports self-shadowing • Cost is linear in # lights and # polygons • Disadvantages: • Self-shadow aliasing • Biasing and other techniques can help, but not fix • Shadow map resolution critical! • Solution: perspective shadow maps

More Related