Presentation is loading. Please wait.

Presentation is loading. Please wait.

© 2004 Tomas Akenine-Möller1 Shadow Generation Hardware Vision day at DTU 2004 Tomas Akenine-Möller Lund University.

Similar presentations


Presentation on theme: "© 2004 Tomas Akenine-Möller1 Shadow Generation Hardware Vision day at DTU 2004 Tomas Akenine-Möller Lund University."— Presentation transcript:

1 © 2004 Tomas Akenine-Möller1 Shadow Generation Hardware Vision day at DTU 2004 Tomas Akenine-Möller Lund University

2 © 2004 Tomas Akenine-Möller2 Outline of my presentation Quick review of shadow volume algorithm –Zfail –Zpass A hierarchical shadow volume algorithm –Overall idea –Efficient hardware implementation

3 © 2004 Tomas Akenine-Möller3 The shadow volume algorithm Crow's (1977) idea, shadow volumes define volumes of space in shadow. From the School of Leonardo Da Vinci

4 © 2004 Tomas Akenine-Möller4 Shadow volume concept Create volumes of space in shadow from each polygon in light. Each triangle creates 3 projecting quads

5 © 2004 Tomas Akenine-Möller5 Using the volume To test a point, count the number of polygons between it and the eye. If we look through more frontfacing than backfacing polygons, then in shadow. frontfacing backfacing

6 © 2004 Tomas Akenine-Möller6 Eye Location Problem If the eye location is inside one or more shadow volumes, count is wrong. Eye problem fixed by clearing stencil buffer to # of volumes eye is inside.

7 © 2004 Tomas Akenine-Möller7 Frustum Location Problem Frustum’s near (hither) plane overlaps a shadow volume, frontface counts missed Some form of capping is needed to make the shadow volume whole again (not trivial, nor robust)

8 © 2004 Tomas Akenine-Möller8 Solution: Count Beyond Surface “Z-fail-algorithm” Render to stencil only when shadow volume Z >= stored Z! must cap ends of shadow volumes (or project to infinity, w=0 for vertices)

9 © 2004 Tomas Akenine-Möller9 Why This Works (f - b) in front of plane = (b - f) in back 2-2 = 0 2 = 2 1 = 2-1 red - violet violet - red

10 © 2004 Tomas Akenine-Möller10 Merging shadow volumes Edge shared by two polygons facing the light creates front and backfacing quad. This interior edge makes two quads, which cancel out Instead, use only potential silhouette edges as seen from the light:

11 © 2004 Tomas Akenine-Möller11 Z-pass by example What we have... What we wnat...

12 © 2004 Tomas Akenine-Möller12 Z-fail by example

13 © 2004 Tomas Akenine-Möller13 Are there any work on accelerating shadow volume rendering? When we started with this project, NVIDIA’s UltraShadow technique was the only existing algorithm UltraShadows – two things: –Extra pipes... –Depth bounds Check out EGSR 2004 – several interesting shadow papers: –Lloyd et al, ”CC Shadow Volumes” –Chan and Durand: Hybrid Shadow map and volumes

14 © 2004 Tomas Akenine-Möller14 A Hierarchical Shadow Volume Algorithm Motivation: fillrate problem with shadow volume rendering Correct result:

15 © 2004 Tomas Akenine-Möller15 Only ”dark shadow pixels” require per-pixel processing...

16 © 2004 Tomas Akenine-Möller16 Low-resolution version shadows (8x8 pixels)

17 © 2004 Tomas Akenine-Möller17 Green tiles may contain a shadow boundary - others are correct

18 © 2004 Tomas Akenine-Möller18 Low-res (gray) + per-pixel computed boundaries (dark)

19 © 2004 Tomas Akenine-Möller19 How to detect boundary tiles? 8 8 Z max Z min Axis-aligned screen- space bounding box of a tile { Fundamental observation: A tile can contain a shadow boundary, iff its bounding box is intersected by at least one shadow volume triangle.

20 © 2004 Tomas Akenine-Möller20 Low-resolution rasterizer (for each tile) Delay Shadow volume Temp boundaryTemp stencil Per-pixel rasterization Copy to 2-level stencil Low-resolution rasterizer sv polys (wait until end of sv) Boundary? sv polys Update 2-level stencil YesNo

21 © 2004 Tomas Akenine-Möller21 Two-pass rasterization 1.Low-res rasterization & boundary test classifications ready only when entire shadow volume processed 2.Wait by using a delay stream stores compressed vertices and render states 3.Per-pixel rasterization of boundary tiles skip rasterization to tiles that are fully in shadow or fully lit, because the results are already known

22 © 2004 Tomas Akenine-Möller22 How to detect begin/end of shadow volume? You will have to tell the algorithm about this Send a marker down the pipeline –Beginning of shadow volume –End of shadow volume –Need new API calls E.g. glBeginShadowVolume() glEndShadowVolume()

23 © 2004 Tomas Akenine-Möller23 Stencil buffer updates Could write all 64 values per tile –Bandwidth problem  Two-level stencil buffer saves the day –[S min, S max ] per tile –Always test the higher level first! –Often no need to validate per-pixel values

24 © 2004 Tomas Akenine-Möller24 Speeding up Overlapping Shadow Volumes Several shadow volumes per light source The shadow area grows monotonically when more shadow volumes added –If tile already in shadow, skip rasterization No need to rasterize shadow twice!

25 © 2004 Tomas Akenine-Möller25 New hardware New on-chip buffers –Two-level stencil buffer beneficial for other computations too –Tile classification buffer (cache) need multiple buffers for pipelined operation allocate from external memory, use through cache Delay stream (if not already in there) New logic –Low-res rasterization (trivial) –Bounding box intersection (must be robust!)

26 © 2004 Tomas Akenine-Möller26 Algorithm animation Show animation

27 © 2004 Tomas Akenine-Möller27 Results

28 © 2004 Tomas Akenine-Möller28 The end Questions? Publication: Timo Aila, and Tomas Akenine-Möller, “A Hierarchical Shadow Volume Algorithm”, accepted for Graphics Hardware 2004.

29 © 2004 Tomas Akenine-Möller29 Misc notes A highly tesselated sphere will not add much more BW usage than a sphere with few triangles


Download ppt "© 2004 Tomas Akenine-Möller1 Shadow Generation Hardware Vision day at DTU 2004 Tomas Akenine-Möller Lund University."

Similar presentations


Ads by Google