Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Shadow Rendering Techniques: Hard and Soft Author: Jamiur Rahman Supervisor: Mushfiqur Rouf Department of CSE BRAC University.

Similar presentations


Presentation on theme: "1 Shadow Rendering Techniques: Hard and Soft Author: Jamiur Rahman Supervisor: Mushfiqur Rouf Department of CSE BRAC University."— Presentation transcript:

1 1 Shadow Rendering Techniques: Hard and Soft Author: Jamiur Rahman Supervisor: Mushfiqur Rouf Department of CSE BRAC University

2 2 Chapters Shadows: Hard and Soft Shadows: Hard and Soft Hard Shadow Rendering Techniques Hard Shadow Rendering Techniques Soft Shadow Rendering Techniques Soft Shadow Rendering Techniques Recent Works Recent Works

3 3 Shadows A point is in shadow if the light got blocked between the light source and point A point is in shadow if the light got blocked between the light source and point Light Source Viewer Point is in shadow Occluder Point is lit

4 4 Shadows Terminology: Umbra and Penumbra Terminology: Umbra and Penumbra (area) light source receiver shadow occluder umbra penumbra umbra – fully shadowed region penumbra – partially shadowed region

5 5 “Hard” and “Soft” Shadows Depends on the type of light sources Point or Directional (“Hard Shadows”, umbra) Area (“Soft Shadows”, umbra, penumbra), more difficult problem pointdirectional area

6 6 “Hard” and “Soft” Shadows Hard shadow Soft shadow – point light source – area light source

7 7 Hard Shadow Rendering Techniques

8 8 Planar Shadows The simplest algorithm – shadowing occurs when objects cast shadows on planar surfaces (projection shadows) The simplest algorithm – shadowing occurs when objects cast shadows on planar surfaces (projection shadows) shadow light y y=0 shadow light y n.x + d =0

9 9 Planar Shadows Special case: the shadow receiver is an axis plane Special case: the shadow receiver is an axis plane Just project all the polygon vertices to that Just project all the polygon vertices to that plane and form shadow polygons plane and form shadow polygons shadow light y y=0 v p Given: - Light position l - Plane position y = 0 - Vertex position v Calculate: p

10 10 Planar Shadows We can use similar triangles to solve p We can use similar triangles to solve p shadow light y y=0 v p x p x -l x l y v x -l x l y -v y = p x = l y v x – l x v y l y - v y l Same principle applied to different axis planes

11 11 Planar Shadows Basic algorithm Basic algorithm Render scene (full lighting) Render scene (full lighting) For each receiver polygon For each receiver polygon Compute projection matrix M Compute projection matrix M Mult with actual transformation (modelview) Mult with actual transformation (modelview) Render selected (occluder) geometry Render selected (occluder) geometry Darken/Black Darken/Black

12 12 Shadow Volumes [Crow77] Shadow algorithms for computer graphics [Crow77] Shadow algorithms for computer graphics Compute regions of shadow in 3D Compute regions of shadow in 3D Object-space algorithm Object-space algorithm Cast shadows onto arbitrary receiver geometry (polygons) Cast shadows onto arbitrary receiver geometry (polygons) From the School of Leonardo Da Vinci

13 13 Shadow Volumes Extend occluder polygons to form semi-infinite volumes Extend occluder polygons to form semi-infinite volumes Light source is center-of-projection Light source is center-of-projection Everything behind occluder is in shadow Everything behind occluder is in shadow Test if point is in at least one volume ! Test if point is in at least one volume ! Extend to reach outside of view frustum Extend to reach outside of view frustum Light Source Shadow Region Occluder

14 14 Shadow Volumes Shadow Volumes illustrated (2D) Shadow Volumes illustrated (2D) shadowing object shadow volume (infinite extent) partially shadowed object light source eye position surface inside shadow volume (shadowed) surface outside shadow volume (illuminated)

15 15 Shadow Volumes Shadow volume generation Shadow volume generation Trivial way Trivial way One volume for each polygon One volume for each polygon Better Better Silhouette-based approach Silhouette-based approach Goal: one shadow volume Goal: one shadow volume Selected occluders only Selected occluders only

16 16 Shadow Volumes Use stencil buffer as counter Use stencil buffer as counter 1. Render scene (ambient color) 2. Render front-facing parts of shadow volumes with stencil operation increment (enter) 3. Render back-facing parts of shadow volumes with stencil operation decrement (exit) 4. Render scene (fully lit) with stencil test equal zero

17 17 Shadow Maps [Williams78] Casting curved shadows on curved surfaces [Williams78] Casting curved shadows on curved surfaces Image-space algorithm Image-space algorithm Well suited for hardware implementation Well suited for hardware implementation Real-Time Luxo Jr. …uses three dynamic shadow maps (OpenGL, GeForce3)

18 18 Shadow Map Basic idea: objects that are not visible to the light are in shadow Basic idea: objects that are not visible to the light are in shadow How to determine whether an object are visible to the eye? How to determine whether an object are visible to the eye? Use z-buffer algorithm, but now the “eye” is light, i.e., the scene is rendered from light’s point of view Use z-buffer algorithm, but now the “eye” is light, i.e., the scene is rendered from light’s point of view This particular z-buffer for the eye is called shadow map This particular z-buffer for the eye is called shadow map

19 19 Shadow Maps Basic Algorithm Basic Algorithm Render scene as seen from light source Render scene as seen from light source Save back depth buffer (2D shadow map) Save back depth buffer (2D shadow map) Render scene from viewer’s position Render scene from viewer’s position Transform pixel coordinates to light source space Transform pixel coordinates to light source space Compare z with z value stored in shadow map Compare z with z value stored in shadow map Pixel is in shadow if z(light) < z(viewer) Pixel is in shadow if z(light) < z(viewer)

20 20 Shadow Maps Shadow map Final scene

21 21 1st Pass View from light Depth Buffer (shadow map)

22 22 2nd Pass Visible surface depth

23 23 2nd Pass Non-green in shadow Final Image

24 24 Soft Shadow Techniques Sampling the Light Source Sampling the Light Source Soft Shadow Maps [Heidrich00] Soft Shadow Maps [Heidrich00]

25 25 Sampling the Light Source Use arbitrary hard shadow algorithm Use arbitrary hard shadow algorithm Select point sample on area light source Select point sample on area light source Render hard shadows Render hard shadows Sum up weighted result (e.g. accumulation buffer) Sum up weighted result (e.g. accumulation buffer)

26 26 Sampling the Light Source Ground plane shadow texture Ground plane shadow texture 1. Initialize FB (white) 2. For each sample point do 2a. Render scene 2a. Render scene 2b. Subtract 1/N from FB only once for each pixel (stencil) ! 2b. Subtract 1/N from FB only once for each pixel (stencil) ! 1. Initialize FB (white) 2. For each sample point do 2a. Render scene 2a. Render scene 2b. Subtract 1/N from FB only once for each pixel (stencil) ! 2b. Subtract 1/N from FB only once for each pixel (stencil) ! Image from ATI Developer’s Site

27 27 Sampling the Light Source Image from ATI Developer’s Site Result Result

28 28 Soft Shadow Maps [Heidrich00] Soft shadow maps for linear lights [Heidrich00] Soft shadow maps for linear lights

29 29 Soft Shadow Maps [Heidrich00] Soft penumbra regions for linear light sources Soft penumbra regions for linear light sources Based on “traditional” shadow map algorithm Based on “traditional” shadow map algorithm Suitable for hardware and software rendering Suitable for hardware and software rendering Very small number of light source samples Very small number of light source samples Soft shadows at real-time / interactive frame rates Soft shadows at real-time / interactive frame rates

30 30 Soft Shadow Maps Visibility of light source Visibility of light source 100% to 0% for [p1,p2] 100% to 0% for [p1,p2] 0% for [p2,q2] 0% for [p2,q2] 0% to 100% for [q2,q1] 0% to 100% for [q2,q1] Idea Idea Normal shadow maps for umbra and completely lit regions Normal shadow maps for umbra and completely lit regions Linear interpolation of visibility for penumbra regions Linear interpolation of visibility for penumbra regions

31 31 Soft Shadow Maps Linear interpolation of visibility Linear interpolation of visibility Rational function: Rational function: Approximation: valid because large penumbra regions when Approximation: valid because large penumbra regions when Receiver Light Source Occluder

32 32 Soft Shadow Maps Visibility map: Visibility map: Additional shadow map channel (percentage visibility) Additional shadow map channel (percentage visibility) Two-channel shadow map for each sample point Two-channel shadow map for each sample point

33 33 Soft Shadow Maps Generating the visibility map Generating the visibility map Triangulate depth discontinuities (shadow map) Triangulate depth discontinuities (shadow map) Warp resulting skin polygons to other view Warp resulting skin polygons to other view

34 34 Soft Shadow Maps Generating the visibility map Generating the visibility map Render skin polygons to visibility map Render skin polygons to visibility map Gouraud-shading (linear interpolation) Gouraud-shading (linear interpolation) “White” for vertices on receiver “White” for vertices on receiver “Black” for vertices on occluder “Black” for vertices on occluder Completely lit regions Completely lit regions Default visibility 0.5 Default visibility 0.5 Completely shadowed regions Completely shadowed regions First shadow map channel First shadow map channel

35 35 Soft Shadow Maps

36 36 Soft Shadow Maps

37 37 Recent Works

38 38 Real-Time Hair Simulation and Visualisation for Games Real-Time Hair Simulation and Visualisation for Games Lund University Graphics Group (LUGG) in cooperation with Digital Illusions CE AB, Stockholm (An EA Company)Digital Illusions CE AB, Stockholm With self shadowWithout self shadow “Deep Shadow Maps” by Tom Lokovic Eric Veach, Pixar Animation Studios

39 39Acknowledgments “Shadow Techniques for Interactive and Real- Time Applications” By Stefan Brabec,MPI, Germany (PhD thesis) “Alias-Free Shadow Maps” By Timo Aila and Samuli Laine, Helsinki University of Technology/TML and Hybrid Graphics Ltd., Finland “Shadow Mapping and Shadow Volumes: Recent Developments in Real-Time Shadow Rendering” By University of British Columbia, Canada “Deep Shadow Maps” Tom Lokovic and Eric Veach, Pixar Animation Studios Lund University Graphics Group (LUGG), Sweden

40 40 Thank you !


Download ppt "1 Shadow Rendering Techniques: Hard and Soft Author: Jamiur Rahman Supervisor: Mushfiqur Rouf Department of CSE BRAC University."

Similar presentations


Ads by Google