1 / 20

Shadows: Shadow Mapping

Shadows: Shadow Mapping. Justin Reynolds CS 134. Problems with Common Shadow Techniques. Various limitations Projected planar shadows Only works well on flat surfaces Stenciled shadow volumes Determining the shadow volume is hard work. Another Technique: Shadow Mapping.

carmela
Download Presentation

Shadows: Shadow Mapping

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: Shadow Mapping Justin Reynolds CS 134

  2. Problems with CommonShadow Techniques • Various limitations • Projected planar shadows • Only works well on flat surfaces • Stenciled shadow volumes • Determining the shadow volume is hard work

  3. Another Technique:Shadow Mapping • Image-space shadow determination • Lance Williams published the basic idea in 1978 • Completely image-space algorithm • Means no knowledge of scene’s geometry is required • Must deal with aliasing artifacts • Well known software rendering technique • Pixar’s RenderMan uses the algorithm • Basic shadowing technique for toy story, etc.

  4. Visualizing the ShadowMapping Technique (I) • A fairly complex scene with shadows the pointlight source

  5. The Shadow Mapping Concept • Depth testing from the light’spoint-of-view • Two pass algorithm • First, render depth buffer from the light’s point-of-view • The result is a “depth map” or “shadow map” • Essentially a 2D function indicating the depth of the closest pixels to the light • This depth map is used in the second pass • The depth map is often stored as a texture in the graphics card memory.

  6. Visualizing the ShadowMapping Technique (II) • The scene from the light’s point-of-view FYI: from theeye’s point-of-viewagain

  7. The Shadow Mapping Concept (II) • Shadow determination with thedepth map • Second, render scene from the eye’s point-of-view • For each rasterized fragment • Determine fragment’s XYZ position relative to the light • This light position should be setup to match the frustum used to create the depth map • Compare the depth value at light position XY in the depth map to fragment’s light position Z

  8. Visualizing the ShadowMapping Technique (III) • The depth buffer from the light’s point-of-view FYI: from thelight’s point-of-viewagain

  9. Visualizing the ShadowMapping Technique (IV) • Projecting the depth map onto the eye’s view FYI: depth map forlight’s point-of-viewagain

  10. The Shadow Mapping Concept (III) • The Shadow Map Comparison • Two values • A = Z value from depth map at fragment’s light XY position • B = Z value of fragment’s XYZ light position • If B is greater than A, then there must be something closer to the light than the fragment • Then the fragment is shadowed • If A and B are approximately equal,the fragment is lit

  11. Visualizing the ShadowMapping Technique (V) • Projecting light’s planar distance onto eye’s view

  12. Visualizing the ShadowMapping Technique (VI) • Comparing light distance to light depth map Green is where the light planar distance and the light depth map are approximately equal Non-green is where shadows should be

  13. Visualizing the ShadowMapping Technique (VII) • Complete scene with shadows

  14. Back to the ShadowMapping Discussion . . . • Assign light-space texture coordinates via texgen • Transform eye-space (x, y, z, w) coordinates to the light’s view frustum (match how the light’s depth map is generated) • Further transform these coordinates to map directly into the light view’s depth map • Expressible as a projective transform • Load this transform into the 4 eye linear plane equations for S, T, and Q coordinates • (s/q, t/q) will map to light’s depth map texture

  15. Shadow Mapping Algorithm procedure SHADOWMAPPING Render depth buffer (Z-buffer) from lights point of view, resulting in a shadow map or depth map Now, render scene from the eye’s point of view for all rasterized fragments do Determine fragment’s xyz position relative to the light That is transform each fragment’s xyz into the light’s coordinate system A = depth map(x,y) B = z-value of fragment’s xyz light position if A < B then fragment is shadowed else fragment is lit end if end for

  16. Issues with ShadowMapping • Not without its problems • Prone to aliasing artifacts • Stitching / Z-fighting • Depth bias is not completely foolproof • Requires extra shadow map rendering pass and texture loading • Higher resolution shadow map reduces blockiness • but also increase texture copying expense

  17. Stitching (Z-fighting) Example

  18. Blocky Shadow Edge Artifacts Notice that shadow edge is well defined in the distance. Light position out here pointing towards the viewer. Blocky shadow edge artifacts.

  19. Anti-Aliasing Example

  20. Conclusions • Shadow mapping offers real-time shadowing effects • Independent of scene complexity • Very compatible with multi-texturing • Does not mandate multi-pass as stenciled shadow volumes do • Ideal for shadows from spotlights • Consumer hardware shadow map support here today • GeForce3 and above, Xbox • Dual-texturing technique supports legacy hardware • Same basic technique used by Pixar to generate shadows in their computer-generated movies

More Related