Shadows Shadows

Shadows Shadows

Shadows Shadows Acknowledgement: Images and many slides from presentations by Mark J. Kilgard and other Nvidia folks, from slides on developer.nvidia.com Practical & Robust Stenciled Shadow Volumes for Hardware-Accelerated Rendering, Cass Everitt & Mark J. Kilgard, GDC 2002 Shadow Mapping with Today’s OpenGL Hardware, Mark Kilgard, CEDEC 2001, Tokyo, Japan Robust Stencil Shadow Volumes, Mark Kilgard, CEDEC 2001, Tokyo, Japan Shadow Mapping, Cass Everitt Reflections, Shadows,Transparency, and Fog, Mark Kilgard, GDC 2000 Tutorial Shadow Mapping with Todays OpenGL Hardware, Mark Kilgard, GDC 2000 Tutorial Shadows T Important visual cue S All real world scenes have shadows S Occlusion from light’s point-of-view instead of viewer’s R Cue for light-object-object relationships CS 4451 Fall 2002 1 Shadows Local Illumination & Shadows T Typically lack shadow support S Ignore occlusion of lights that creates shadows T Global lighting models account for shadows S Too expensive for interactive use T Interactive shadow algorithms typically operate independent of local lighting models Interactive Shadow Simplifications T True shadows are expensive, cut corners S Simple geometry tricks R Projection R Volume intersection S Pre-compute static shadow results where possible S Make simplifying assumptions R Treat area light sources as points S Exploit hardware features such as stencil CS 4451 Fall 2002 2 Shadows Common Real-time Shadow Techniques Projected Projected Shadow planar volumes shadows Hybrid approaches Light maps Problems with Common Techniques T Mostly tricks with lots of limitations S Light maps R totally unsuited for dynamic shadows S Projected planar shadows R well works only on flat surfaces S Stenciled shadow volumes R determining the shadow volume is hard work S Shadow Maps R only works with spotlight frustums R shadow acne artifacts CS 4451 Fall 2002 3 Shadows Pre-computed Shadow Textures (Light maps, 8.5 in book) T Lightmaps are static shadow textures S Compute lightmaps off-line with radiosity solver R local lighting models evaluated on tight grid can work too S Lightmaps with soft shadows can be built faster with convolution approach, accelerated using the Fast Fourier Transform [Soler & Silion 98] S Pre-computed shadow textures work well for building interior with lots of diffuse surfaces Aside: Stencil Buffers T An extra test for fine-grain pixel control S Standard OpenGL and DirectX 6 feature S Per-pixel test similar to depth buffering R Tests fragment against pixel’s stencil value, rejects fragments that fail R Also, can modify pixel’s stencil buffer value based on stencil/depth test results S Hardware accelerates stencil testing R Typically free when depth testing too CS 4451 Fall 2002 4 Shadows Stencil Testing T Similar to Depth Testing but S Compares current reference value to pixel’s stencil buffer value S Same comparison functions as depth test T Stencil values controlled by stencil ops S “stencil” side effects of stencil & depth tests S Possible operations R Increment, Decrement R Keep, Replace, Zero, Invert Projected Planar Shadows CS 4451 Fall 2002 5 Shadows Projected Planar Shadows T Classic computer graphics trick S Given R Ground plane equation, Ax + By + Cz + D = 0 R Light position (x, y, z, w) S Construct projective transform that “squishes” vertices into ground plane based on light position R Concatenate this with view transform S Rendering 3D object creates shadow-like pile of polygons in ground plane Projected Planar Shadow Issues T Shadow must be cast on infinite planes T “Pile of polygons” creates Z-fighting artifacts S Polygon offset fixes this, but disturbs Z values T Difficult to blend shadow with ground texture S Just blending creates “double blends” S Specular highlights can show in shadow T Stencil testing can fix most of these issues CS 4451 Fall 2002 6 Shadows Projected Planar Shadow Artifacts Bad Good extends off ground region Z fighting double blending Shadow Volumes CS 4451 Fall 2002 7 Shadows The Shadow Volume Concept T Volumetric shadows, not just planar S A single point light source splits the world in two R shadowed regions R unshadowed regions S A shadow volume is the boundary between these shadowed and unshadowed regions S First described by [Crow 77] Visualizing the Shadow Volume T Occluders and light source cast out a shadow volume S Objects within the volume should be shadowed Light source CS 4451 Fall 2002 8 Shadows Shadow Volume Result T Objects within the volume are shadowed Shadow Volume Algorithm T High-level view of the algorithm S Given the scene and a light source position, determine the shadow volume S Render the scene in two passes R Draw scene with the light enabled, updating only fragments in unshadowed region R Draw scene with the light disabled, updated only fragments in shadowed region S But how to control update of regions? CS 4451 Fall 2002 9 Shadows 2D Cutaway of a Shadow Volume Surface outside Shadowing shadow volume object (illuminated) Light source Shadow volume (infinite extent) Eye position (note that shadows Partially Surface inside are independent of shadowed shadow volume the eye position) object (shadowed) Counting Shadow Volume Enter/Leaves With a Stencil Buffer T Render scene to initialize depth buffer S Depth values indicate the closest visible fragments T Use a stencil enter/leave counting approach S Draw shadow volume twice using face culling R 1st pass: render front faces and increment when depth test passes R 2nd pass: render back faces and decrement when depth test passes S Don’t update depth or color T Afterward, pixel’s stencil is non-zero if pixel in shadow, and zero if illuminated CS 4451 Fall 2002 10 Shadows Why Eye-to-Object Stencil Enter/Leave Counting Approach Works Light Shadowing object source zero +1 zero +2 +2 Eye +1 +3 position Illuminated, Behind Shadow Volumes Light Shadowing object source zero +1 zero + + + - - - Unshadowed object +2 +2 Eye +1 +3 position Shadow Volume Count = +1+1+1-1-1-1 = 0 CS 4451 Fall 2002 11 Shadows Shadowed, Nested in Shadow Volumes Light Shadowing object source zero +1 zero + + + - +2 +2 Shadowed Eye +1 object +3 position Shadow Volume Count = +1+1+1-1 = 2 Illuminated, In Front of Shadow Volumes Light Shadowing object source zero +1 zero +2 +2 Shadowed Eye +1 object +3 position Shadow Volume Count = 0 CS 4451 Fall 2002 12 Shadows Problems Created by Near Plane Clipping Missed shadow volume intersection due to near clip plane clipping; Far clip leads to mistaken count plane zero +1 +1 +2 zero +3 +2 Near clip plane Visualizing the Stencil Buffer Counts Shadowed scene Stencil buffer contents Stencil counts beyond 1 are possible for multiple or complex occluders. red = stencil value of 1 green = stencil value of 0 GLUT shadowvol example credit: Tom McReynolds CS 4451 Fall 2002 13 Shadows Computing Shadow Volumes T Harder than you might think S Easy for a single triangle, just project out three infinite polygons from the triangle, opposite the light position S For complex objects, projecting object’s 2D silhouette is a good approximation (flat objects are easy) S Static shadow volumes can be pre-compiled Stenciled Shadow Volumes in Practice (1) Scene with shadows. Yellow Same scene visualizing light is embedded in the green the shadow volumes. three-holed object. Pinf is used for all the following scenes. CS 4451 Fall 2002 14 Shadows Stenciled Shadow Volumes in Practice (2) Details worth noting . Hard case: The shadow volume Fine details: Shadows from the front-facing hole of the A, N, and T letters on would definitely intersect the knight’s armor and shield. the near clip plane. Stenciled Shadow Volumes in Practice (3) Alternate view of same scene Shadow volumes from the with shadows. Yellow lines alternate view. indicate previous view’s view frustum boundary. Recall shadows are view-independent. CS 4451 Fall 2002 15 Shadows Shadow Volume Issues T Practical considerations [Bergeron 86] S If eye is in shadow volume, need to determine this and flip enabled & disabled lighting passes S Shadow volume only as good as its tessellation R Shadows tend to magnify limited tessellation of curved surfaces S Must cap the shadow volume’s intersection with the near clipping plane S Open models and non-planar polygons Reconstructing Shadow Volume From a Depth Buffer T Very clever idea [McCool 98] S Render scene from light source with depth testing S Read back the depth buffer S Use computer vision techniques to reconstruct the shadow volume geometry from the depth buffer image S Very reasonable results for complex scenes CS 4451 Fall 2002 16 Shadows Multiple Lights and Shadow Volumes T Requires still more rendering passes, but can work! Shadows from different light sources overlap correctly Shadow Volumes from Area Light Sources T Make soft shadows S Shadow volumes work for point light sources S Area light sources are common and make soft shadows S Model an area light source as a collection of point light sources [Brotman & Badler 84] S Use accumulation buffer or additive blending to accumulate soft shadow S Linear cost per shadow volume sample CS 4451 Fall 2002 17 Shadows Soft Shadow Example T Eight samples (more would be better) Note the banding artifacts Combined Shadow Algorithm Example: Shadow Volume + Planar Projection just logo shadow volume logo lacks shadow on the teapot just planar projected teapot lacks shadows shadow on the floor combined approach CS 4451 Fall 2002 18 Shadows Shadow Volume Advantages T Omni-directional approach S Not just spotlight frustums as with shadow maps T Automatic self-shadowing S Everything

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    29 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us