html5-img
1 / 22

Real-Time Dynamic Shadow Algorithms

Real-Time Dynamic Shadow Algorithms. Evan Closson CSE 528. Inspiration. Interested in virtual environments which shadows are a part of. Shadows are cool. John Carmak. Shadows in the new Doom engine. Importance of Shadows in Virtual Environments. You’ve all seen this distinction before.

ros
Download Presentation

Real-Time Dynamic Shadow Algorithms

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. Real-Time Dynamic Shadow Algorithms Evan Closson CSE 528

  2. Inspiration • Interested in virtual environments which shadows are a part of. • Shadows are cool. • John Carmak Shadows in the new Doom engine

  3. Importance of Shadows in Virtual Environments • You’ve all seen this distinction before. • On the left a scene with no shadows. It is hard to determine the spatial location of the models and lights. • With shadows . . .

  4. The Lighting Problem • Shadows are a Global Illumination Model problem. • Many objects must be taken into consideration when calculating the shadow at a specific point. • Ray Tracers and Radiosity Techniques handle shadows well.

  5. Problems With This Model For Real-Time Applications • Speed. Global Illumination Models are slow and it is not feasible with current technology to use such a model in a real- time virtual environment.

  6. Quick Fix Rendering shadows in Real-Time is almost always separated from the lighting model and uses geometric tricks to approximate the shadows. As with most things there is a trade off among these tricks between the accuracy/realism of the shadows and speed.

  7. Real-Time Dynamic Shadow Algorithms • Planar Projected Algorithms - Fast - Very limited use • Shadow Mapping - Robust - Harder to handle omni directional lights • Shadow Volumes - Shadow Volumes are hard to compute efficiently - Handles omni directional lights very well

  8. Planar Projected Shadows • Very Fast • Squishes the Model onto a plane in just one matrix multiplication • Easy To Implement and with good results when casting shadows onto one plane • Can extend to cast onto multiple planes, but each plane will require another rendering of the model. Cube 8 Lights

  9. Shadow Mapping [Lance Williams 78] • Render scene from the point of view of the camera with depth test enabled. • Result is a shadow map from the lights perspective stored in the depth buffer. • Next, render scene from cameras point of view and determine the pixels (X,Y,Z) coordinates with respect to the Lights coordinate system. • Compare the Z value of the pixel with the value stored at position (X,Y) in the depth map. • If the values are equal then the pixel is lit, if it is greater then the pixel is shadowed.

  10. Shadow Mapping Pixel in Shadow Pixel Lit • Pixel in Shadow: The fragments Z in light space is greater then the stored value in the depth map at fragments XY position • Pixel Lit: The fragments Z in light space is equal to the value in the shadow map.

  11. Shadow Mapping • The resolution of the shadow map should be the same as the color buffer or aliasing artifacts can occur. • Must render multiple shadow maps for omni directional lights.

  12. Shadow Volumes • Makes use of the stencil buffer to block out areas in which a shadow is cast. Algorithm • First render scene with only ambient light. • Compute shadow volume. • Render the front facing polygons of the shadow volume and increment the stencil buffer for each successful stencil test • Render the back facing polygons and decrement the stencil buffer for successful stencil tests. • Finally render the scene with diffuse and specular lights in all places that the stencil buffer is equal to 0.

  13. Shadow Volumes • A Shadow Volume is a volume in space for which anything within that volume is in shadow. • It is formed from the light being blocked by an occluder. It is infinite at one end and starts at the occluding object. Note: here the shadow volume is actually capped. • Computing the shadow volume is hard work. Lots of geometric computations.

  14. How The Shadow Volumes Work • If you consider a camera at any point outside of the shadow and a point being shaded. Shoot a ray from the camera to the point. • If the point is in the shadow volume it will have a positive value since the ray incremented the stencil buffer every time it entered the shadow volume(front facing), and decremented it when it left(back facing). • If the camera is within the shadow volume the incrementing and decrementing must be reversed. This however is extra work for a check to determine the location of the camera must be made.

  15. The Future of Shadows • Shadow Algorithm Specific Hardware Acceleration • NVIDIA Shadow Buffer Technology • Used in the GeForce3 • Uses Shadow Map Technique

  16. My Implementations • Planar Projected Shadows • Shadow Volumes Both of these have two versions one with correct support for multiple lights, one optimized for use with one light.

  17. Planar Projected Shadows • Plane Eq: Ax + By + Cz + D = 0 • [x, y, z] is the difference between the center of the model and the light source. Ideally you want to use the distance from each vertex. However it is not as fast since the matrix will have to be computed on a per vertex basis instead of a per model basis. • The vertices of the model are multiplied by the Planar Projection matrix. • You can find this matrix in the Red Book.

  18. Shadow Volumes • There are 2 implementations for shadow volumes. One optimized for one light, and one set up for multiple lights. • My implementations follow the algorithm discussed before except instead of rendering a scene once for ambient light then diffuse and specular I use a shading polygon. • Render a polygon that covers the entire scene and then blend it wherever the stencil buffer is not zero. So all the areas in shadow are blended with a shadow polygon. This will save a complete rendering of the scene, by merging the lighting properties into one pass. • Many complications can arise from finding a good capping value (the distance it extends towards infinity) for the shadow volume. To simplify this for myself I just allow the user to change the current shadow cap. In practice for arbitrary cameras and virtual environments the shadow volume should be capped to correspond with the clipping planes. However this can lead to many artifacts and there are many special cases to account for.

  19. Shadow Volumes

  20. Results: A Few More Pictures Shadow Volumes cast on all objects An omni directional scene for shadow volumes.

  21. Results: A Few More Pictures Notice the self shadowing Shadow Volumes Planar Projected Shadows

  22. Results: A Few More Pictures Two Lights Eight Lights

More Related