shadows shadow mapping l.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
Shadows: Shadow Mapping PowerPoint Presentation
Download Presentation
Shadows: Shadow Mapping

Loading in 2 Seconds...

play fullscreen
1 / 20

Shadows: Shadow Mapping - PowerPoint PPT Presentation


  • 463 Views
  • Uploaded on

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.

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

PowerPoint Slideshow about 'Shadows: Shadow Mapping' - carmela


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
shadows shadow mapping

Shadows: Shadow Mapping

Justin Reynolds

CS 134

problems with common shadow techniques
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
another technique shadow mapping
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.
visualizing the shadow mapping technique i
Visualizing the ShadowMapping Technique (I)
  • A fairly complex scene with shadows

the pointlight source

the shadow mapping concept
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.
visualizing the shadow mapping technique ii
Visualizing the ShadowMapping Technique (II)
  • The scene from the light’s point-of-view

FYI: from theeye’s point-of-viewagain

the shadow mapping concept ii
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
visualizing the shadow mapping technique iii
Visualizing the ShadowMapping Technique (III)
  • The depth buffer from the light’s point-of-view

FYI: from thelight’s point-of-viewagain

visualizing the shadow mapping technique iv
Visualizing the ShadowMapping Technique (IV)
  • Projecting the depth map onto the eye’s view

FYI: depth map forlight’s point-of-viewagain

the shadow mapping concept iii
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
visualizing the shadow mapping technique v
Visualizing the ShadowMapping Technique (V)
  • Projecting light’s planar distance onto eye’s view
visualizing the shadow mapping technique vi
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

back to the shadow mapping discussion
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
shadow mapping algorithm
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

issues with shadow mapping
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
blocky shadow edge artifacts
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.

conclusions
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