Presentation is loading. Please wait.

Presentation is loading. Please wait.

A Real-Time Soft Shadow Volume Algorithm DTU Vision days Tomas Akenine-Möller Department of Computer Engineering Chalmers University of Technology Sweden2003-06-13.

Similar presentations


Presentation on theme: "A Real-Time Soft Shadow Volume Algorithm DTU Vision days Tomas Akenine-Möller Department of Computer Engineering Chalmers University of Technology Sweden2003-06-13."— Presentation transcript:

1 A Real-Time Soft Shadow Volume Algorithm DTU Vision days Tomas Akenine-Möller Department of Computer Engineering Chalmers University of Technology Sweden2003-06-13

2 Copyright 2003 Tomas Akenine-Möller 2 Shadow Generation Why? In computer graphics, shadows are not generated automatically Must create algorithms for this! Shadows help with: –Realism –Atmosphere –Spatial relationships

3 Copyright 2003 Tomas Akenine-Möller 3 Spatial relationships

4 Copyright 2003 Tomas Akenine-Möller 4 Other classical images on the need for shadows Images courtesy of Micheal McCool, University of Waterloo

5 Copyright 2003 Tomas Akenine-Möller 5 Hard vs soft shadows Two different light source types point source umbra area source umbrapenumbra

6 Copyright 2003 Tomas Akenine-Möller 6 Example: hard vs soft Point light source Area light source umbra penumbra umbra

7 Copyright 2003 Tomas Akenine-Möller 7 Ways of thinking about shadows As separate objects (like Peter Pan's shadow) As volumes of space that are dark As places not seen from a light source looking at the scene We base our work on Crow’s shadow volume algorithm (option 2 above) from 1977

8 Copyright 2003 Tomas Akenine-Möller 8 Shadow mapping Shadow mapping is used in Pixar’s rendering SW, but also in real time using graphics hardware Render from light’s view (white is far and black is near) Use pixel shader to determine if point is in shadow Use percentage-closer filtering for better quality Pros and cons: –BAD: Discrete representation –BAD: Incorrect self-shadowing –BAD: frustum limited –GOOD: can reuse SM if geometry & light static –GOOD: can use any shadow casters and receivers

9 Copyright 2003 Tomas Akenine-Möller 9 (Hard) Shadow volumes Very popular method for real time Shadow volume concept Create volumes of space in shadow from each polygon in light. Each triangle creates 3 projecting quads

10 Copyright 2003 Tomas Akenine-Möller 10 Using the Shadow 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

11 Copyright 2003 Tomas Akenine-Möller 11 Soft shadow algorithms in general Fundamental problem in computer graphics Inherently difficult!

12 Copyright 2003 Tomas Akenine-Möller 12 A Real-Time Soft Shadow Volume Algorithm Insight Given that there is geometry inside a wedge, how can we compute the light contribution accurately?

13 Copyright 2003 Tomas Akenine-Möller 13 Visibility computation Really want to compute how much we can see of the light source

14 Copyright 2003 Tomas Akenine-Möller 14 Precomputed coverage in 4D textures

15 Copyright 2003 Tomas Akenine-Möller 15 4D textures used as look-up table Enables –Fast computation –Textured light sources (e.g., fire) Texturing is normally very fast on today’s graphics hardware because of: –Texture caches –Intelligent prefetching

16 Copyright 2003 Tomas Akenine-Möller 16 More examples using textured lights

17 Copyright 2003 Tomas Akenine-Möller 17 The Soft Shadow Volume Algorithm 1st pass: Render hard shadow quads (as usual) –To be sure that we register when we enter/exit umbra 2nd pass: compensate for overstated umbra

18 Copyright 2003 Tomas Akenine-Möller 18 Example of how it works

19 Copyright 2003 Tomas Akenine-Möller 19 Some details on our hardware implementation… Performance was poor when we finally got a higly programmable graphics card –SW rendering > HW rendering! Had to fine tune the implementation: –Tighter wedges for rectangular lights –Optimized pixel shaders –Frame buffer blending –Culling

20 Copyright 2003 Tomas Akenine-Möller 20 Optimized pixel shaders Have implemented both spherical and rectangular light sources Rectangular case: –Create frustum from point-to-be-shaded, p, to light, and clip edge to frustum –Transform so that p is in (0,0,0) and normal of light parallel to z-axis –Use projection matrix to transform to clip- space –Clip in homogeneous space, divide by w –Use 4D texture of clipped endpoints Shaders are about 60 instructions long

21 Copyright 2003 Tomas Akenine-Möller 21 Reserved for overflow Frame buffer blending Need: add and subtract hires-values to V-buffer –Need >8 bits if you want 256 shadow levels –Not available on Radeon 9700 or GeForce FX! Solution: split value across 8-bit components Use 5 bits of overflow: allows 32 overlapping wedges 765 4 321 0 One byte 765 4 321 0 Bit 3 Bit 4 Bit 5 Gives a 12-bit coverage value using 4 bytes To create final value using LUT: –8*XXXXX543+XXXX210=YYYYY543210 Two rendering passes: one for additive and one for subtractive values

22 Copyright 2003 Tomas Akenine-Möller 22 Shadow receiver wedge Pixel shader culling PS only change V-buffer if (x,y,z) is inside wedge  cull everything else! Culling: –Frontfacing (FF) tris of wedge rendered into stencil buffer if tris in front of rendered geometry –Render BF tris where stencil is one, and tris are farther away than rendered geometry –Execute pixel shader that passes these tests FF BF

23 Copyright 2003 Tomas Akenine-Möller 23 Results Optimizations for graphics hardware: –Gives real-time performance –This is the only existing algorithm with this kind of performance, and with high quality (no sampling artifacts) –At least as far as we know… Video

24 Copyright 2003 Tomas Akenine-Möller 24 Two artifacts! Overlapping geometry is handled incorrectly Single silhouette error

25 Copyright 2003 Tomas Akenine-Möller 25 For better quality, use 2x2 area lights… (and 2x2 does not cost 4 times as much!)

26 Copyright 2003 Tomas Akenine-Möller 26 On Shadow Volume Silhouettes (SVS) We use silhouette edges as seen from light Many people believe that a SVS vertex is connected to two edges We prove that SVS vertices can be connected to any even number of edges

27 Copyright 2003 Tomas Akenine-Möller 27 Our soft shadow contributions Work done with Ulf Assarsson (soon PhD!) Publications: –Tomas Akenine-Möller and Ulf Assarsson, “Rapid Soft Shadows on Arbitrary Surfaces using Penumbra Wedges,” Eurographics Workshop on Rendering 2002, pp. 309--318, June 2002. –Ulf Assarsson and Tomas Akenine-Möller, “Optimized and Generalized Real-Time Soft Shadows using Penumbra Wedges,” to appear in The Visual Computer, 2003. –Ulf Assarsson and Tomas Akenine-Möller, “A Geometry-based Soft Shadow Volume Algorithm using Graphics Hardware,” to appear in SIGGRAPH 2003, July 2003. –Ulf Assarsson, Michael Dougherty, Michael Mounier, and Tomas Akenine- Möller, “An Optimized Soft Shadow Volume Algorithm with Real-Time Performance,” to appear in Graphics Hardware 2003. –Tomas Akenine-Möller and Ulf Assarsson, “On Shadow Volume Silhouettes,” submitted to journal of graphics tools, April 2003.

28 Thanks for listening… Over to real-time soft shadow demo… 1024 hard shadow samplesOur algorithm


Download ppt "A Real-Time Soft Shadow Volume Algorithm DTU Vision days Tomas Akenine-Möller Department of Computer Engineering Chalmers University of Technology Sweden2003-06-13."

Similar presentations


Ads by Google