Presentation is loading. Please wait.

Presentation is loading. Please wait.

Shadow Maps & Smoothies CS 446: Real-Time Rendering & Game Technology David Luebke University of Virginia.

Similar presentations


Presentation on theme: "Shadow Maps & Smoothies CS 446: Real-Time Rendering & Game Technology David Luebke University of Virginia."— Presentation transcript:

1 Shadow Maps & Smoothies CS 446: Real-Time Rendering & Game Technology David Luebke University of Virginia

2 2 David Luebke Real-Time Rendering Demo Today: Travis Sluka Tuesday: John Dimeo

3 3 David Luebke Real-Time Rendering Shadow Maps Idea: –Render scene from light source, read Z-buffer –Result: discretized image ( shadow map ) telling distance of objects to light source –Render scene normally At each pixel, calculate distance D to light Compare to distance S stored in shadow map If D=S, surface lit by light, else in shadow

4 4 David Luebke Real-Time Rendering Shadow Maps The basic algorithm (w/o hardware) –Render scene with ambient lighting only –Read Z-buffer, transform values into coordinate system of light –Use comparison to set alpha buffer –Render w/ diffuse and specular components, multiplying by alpha

5 5 David Luebke Real-Time Rendering Shadow Maps Advantages: –Hardware-accelerated general shadow algorithm –Supports self-shadowing –Cost is linear in # lights and # polygons Disadvantages: –Self-shadow aliasing Biasing and other techniques can help, but not fix –Shadow map resolution critical! Solution: perspective shadow maps

6 6 David Luebke Real-Time Rendering Recap: Shadow Maps The basic idea: –Render scene from light source, read Z-buffer –Result: discretized image ( shadow map ) telling distance of objects to light source –Render scene normally At each pixel, calculate distance D to light Compare to distance S stored in shadow map – Use projective texturing to compute texcoords If D=S, surface lit by light, else in shadow – Comparison on CPU (store result in α) or in hardware Show NVIDIA shadowcast demo

7 7 David Luebke Real-Time Rendering Smoothies Many, many refinements on shadow algorithms out there To give you a feel for the range of solutions, I’ll present one recent paper – Rendering Fake Soft Shadows with Smoothies –Eric Chan & Fredo Durand (MIT) –Slides borrowed from their NVIDIA-U talk

8 Rendering Fake Soft Shadows with Smoothies Laboratory for Computer Science Massachusetts Institute of Technology Eric Chan Frédo Durand

9 Goals: Interactive framerates Hardware-accelerated Good image quality Dynamic environments Applications: Game engines (e.g. Doom 3) Interactive walkthroughs Challenge: balancing quality and performance Real-Time Shadows NVIDIA

10 Two Algorithms from the 1970’s Shadow volumes (Crow 1977) Object-space Accelerated by hardware stencil buffer Large fillrate consumption Shadow maps (Williams 1978) Image-space Fast and simple Supported in hardware Undersampling artifacts NVIDIA

11 Soft Shadow Volumes Penumbra wedges: Shadow polygons wedges Compute penumbra with pixel shaders Accurate approximation Papers: Assarsson et al. (EGRW 2002, SIGGRAPH 2003, HWWS 2003) But: much higher fillrate needed Assarsson and Akenine-Möller wedge

12 Soft Shadow Maps Ideas: Filtering Stochastic sampling Image warping Examples: Percentage closer filtering (Reeves et al., SIGGRAPH 1987) Deep shadow maps (Lokovic and Veach, SIGGRAPH 2000) Image-based soft shadows (Agrawala et al., SIGGRAPH 2000) Multisampling hard shadows (Heckbert and Herf, TR 1997) But: need dense sampling to minimize artifacts Agrawala et al.

13 Soft Shadow Maps (cont.) Approximations Examples: Convolution (Soler and Sillion, SIGGRAPH 1998) Linear lights (Heidrich et al., EGRW 2000) Outer surfaces (Parker et al., TR 1998) Plateaus (Haines, JGT 2001) Penumbra maps (Wyman and Hansen, EGSR 2003) Soler and Sillion

14 Overview Extend basic shadow map approach Use extra primitives (smoothies) to soften shadows light’s view (blockers only)light’s view (blockers + smoothies)

15 Fake Soft Shadows Shadows not geometrically correct Shadows appear qualitatively like soft shadows Hard shadowsFake soft shadows

16 Contributions Smoothie shadow algorithm: Creates soft shadow edges Hides aliasing artifacts Efficient (object / image space) Hardware-accelerated Supports dynamic scenes

17 1. Create Shadow Map Render blockers into depth map light’s view observer’s view

18 2. Identify Silhouette Edges Find blockers’ silhouette edges in object space object-space silhouettes observer’s view light’s view

19 3. Construct Smoothies Blocker only: silhouette vertex silhouette edges blocker exterior

20 3. Construct Smoothies (cont.) Blocker + smoothies: silhouette vertex silhouette edges smoothie edge smoothie corner t t blocker exterior

21 3. Construct Smoothies (cont.) Smoothie edges are rectangles in screen space with a fixed width Smoothie corners connect adjacent smoothie edges t t geometryshading

22 4. Render Smoothies Store depth and alpha values into smoothie buffer Smoothie Buffer (depth)Smoothie Buffer (alpha) light’s viewpoint

23 5. Compute Shadows Compute intensity using depth comparisons smoothie light source blocker receiver

24 5. Compute Shadows Image sample behind blocker (intensity = 0) smoothie light source blocker receiver completely in shadow

25 5. Compute Shadows Image sample behind smoothie (intensity =  ) partially in shadow smoothie light source blocker receiver

26 5. Compute Shadows Image sample illuminated (intensity = 1) illuminated smoothie light source blocker receiver

27 Computing Alpha Values Intuition: Alpha defines penumbra shape Should vary with ratio b/r blocker smoothie  receiver light source r b

28 Computing Alpha Values (cont.) Linearly interpolate alpha Remap alpha at each pixel using ratio b/r:  ’ =  / (1 – b/r) original  remapped  result

29 Multiple Blockers and Receivers

30 Multiple Receivers light’s view same thickness Smoothie buffer (linearly-interpolated  ) 1 2

31 Multiple Receivers (cont.) light’s view Smoothie buffer (remapped  ) different thickness 1 2

32 Multiple Receivers (cont.) Final image observer’s view different thickness

33 Multiple Blockers What happens when smoothies overlap? smoothie overlap

34 Multiple Blockers (cont.) Minimum blending: just keep minimum of alpha values smoothieray tracer

35 Comparison to Penumbra Maps Penumbra maps (Wyman and Hansen, EGSR 2003) Same idea, different details Smoothie depth: Extra storage + comparison Handles surfaces that act only as receivers cones and sheetsquads blockers onlyblockers + smoothies Geometry: Store depth: Penumbra MapsSmoothies

36 Results System information: 2.6 GHz Intel Pentium 4 NVIDIA Geforce FX 5800 Ultra

37 Video

38 Hiding Aliasing (256 x 256) shadow mapbicubic filter smoothie (t = 0.02)smoothie (t = 0.08) 16 ms129 ms 19 ms

39 Hiding Aliasing (1024 x 1024) shadow mapbicubic filter smoothie (t = 0.02)smoothie (t = 0.08) 17 ms142 ms 22 ms24 ms

40 Comparison to Ray Tracer smoothieray tracer increasing size of light source

41 Video original md2shader demo courtesy of Mark Kilgard

42 Discussion Shadow maps: Assumes directional light or spotlight Discrete buffer samples Shadow volumes: Assumes blockers are closed triangle meshes Silhouettes identified in object space Smoothies: Rendered from light’s viewpoint Occupy small screen area inexpensive

43 Summary Contribution: Simple extension to shadow maps Shadows edges are fake, but look like soft shadows Fast, maps well to graphics hardware

44 Trends in Real-Time Shadows Architectures and algorithms go together Currently, architectures algorithms: Store per-pixel data at full precision But also, algorithms architectures: Shadow maps Shadow volume depth bounds Aggressive early z and stencil reject

45 Acknowledgments Hardware, drivers, and bug fixes Mark Kilgard, Cass Everitt, David Kirk, Matt Papakipos (NVIDIA) Michael Doggett, Evan Hart, James Percy (ATI) Writing and code Sylvain Lefebvre, George Drettakis, Janet Chen, Bill Mark Xavier Décoret, Henrik Wann Jensen Funding ASEE NDSEG Fellowship

46 Other Cool Shadow Stuff l Deep shadow maps –Instead of storing a depth at each pixel –Store a series of depths w/ reduction of light transmitted –Important for complex self-shadowing models n Hair, clouds –Not real-time (yet…) l Final examples of cool shadow stuff: Deep Shadow Maps, Lokovic & Veach, SIGGRAPH 2000

47 Other Cool Shadow Stuff l Deep shadow maps –Instead of storing a depth at each pixel –Store a series of depths w/ reduction of light transmitted –Important for complex self-shadowing models n Hair, clouds –Not real-time (yet…) l Final examples of cool shadow stuff: With self-shadowing

48 Other Cool Shadow Stuff l Deep shadow maps –Instead of storing a depth at each pixel –Store a series of depths w/ reduction of light transmitted –Important for complex self-shadowing models n Hair, clouds –Not real-time (yet…) l Final examples of cool shadow stuff: Without self-shadowing

49 Other Cool Shadow Stuff l Deep shadow maps –Instead of storing a depth at each pixel –Store a series of depths w/ reduction of light transmitted –Important for complex self-shadowing models n Hair, clouds –Not real-time (yet…) l Final examples of cool shadow stuff: A cloud with pipes (duh)

50 Other Cool Shadow Stuff l Perspective shadow maps –Avoid shadow map aliasing by composing perspective projection of camera into shadow map l Final examples of cool shadow stuff: A scene rendered w/ 512x512 shadow map

51 Other Cool Shadow Stuff l Perspective shadow maps –Avoid shadow map aliasing by composing perspective projection of camera into shadow map l Final examples of cool shadow stuff: The shadow map. Note wasted resolution.

52 Other Cool Shadow Stuff l Perspective shadow maps –Avoid shadow map aliasing by composing perspective projection of camera into shadow map –Must be recomputed each frame l Final examples of cool shadow stuff: 512x512 perspective shadow map

53 Other Cool Shadow Stuff l Perspective shadow maps –Avoid shadow map aliasing by composing perspective projection of camera into shadow map –Must be recomputed each frame l Final examples of cool shadow stuff: The perspective shadow map uses resolution more effectively

54 Other Cool Shadow Stuff l Perspective shadow maps –Avoid shadow map aliasing by composing perspective projection of camera into shadow map –Must be recomputed each frame l Final examples of cool shadow stuff: Perspective Shadow Maps, Stamminger & Drettakis, SIGGRAPH 2002


Download ppt "Shadow Maps & Smoothies CS 446: Real-Time Rendering & Game Technology David Luebke University of Virginia."

Similar presentations


Ads by Google