1 / 43

Shadows

Shadows. Dr. Scott Schaefer. Shadows. Shadows provide clues about depth Make scenes appear more realistic. Shadows. Shadows provide clues about depth Make scenes appear more realistic. Shadow Algorithms. Simple/Planar Shadows Shadow Maps Shadow Volumes. Simple/Planar Shadows.

hermanson
Download Presentation

Shadows

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. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Shadows Dr. Scott Schaefer

  2. Shadows • Shadows provide clues about depth • Make scenes appear more realistic

  3. Shadows • Shadows provide clues about depth • Make scenes appear more realistic

  4. Shadow Algorithms • Simple/Planar Shadows • Shadow Maps • Shadow Volumes

  5. Simple/Planar Shadows • Projection of an object onto a planar surface (floor/wall) • Build projection matrix from light to wall • Draw object in black using projection matrix Image taken from http://developer.nvidia.com/object/robust_shadow_volumes.html

  6. Simple/Planar Shadows • Fast and simple • Does not account for self-shadowing • Only works for planar surfaces (nothing else has shadows cast on it) Image taken from http://developer.nvidia.com/object/robust_shadow_volumes.html

  7. Shadow Maps

  8. Shadow Maps • Render scene from light’s perspective

  9. Shadow Maps • Render scene from light’s perspective Shadow Map

  10. Shadow Maps • Render scene from light’s perspective • Render scene from viewer’s perspective

  11. Shadow Maps • Render scene from light’s perspective • Render scene from viewer’s perspective • For every pixel • Transform to world space • Compare distance to value in shadow map

  12. Shadow Maps • Render scene from light’s perspective • Render scene from viewer’s perspective • For every pixel • Transform to world space • Compare distance to value in shadow map

  13. Shadow Maps • Render scene from light’s perspective • Render scene from viewer’s perspective • For every pixel • Transform to world space • Compare distance to value in shadow map In shadow!

  14. Shadow Maps • Render scene from light’s perspective • Render scene from viewer’s perspective • For every pixel • Transform to world space • Compare distance to value in shadow map In shadow!

  15. Shadow Maps • Render scene from light’s perspective • Render scene from viewer’s perspective • For every pixel • Transform to world space • Compare distance to value in shadow map Not in shadow!

  16. Shadow Maps Image taken from http://www.cse.ohio-state.edu/~haleyb/Hardware/ggDepthBuffer.jpg

  17. Shadow Maps • Advantages • Simple to implement • Does not depend on scene complexity (except to render shadow map) • Disadvantages • Fixed resolution image leads to artifacts • Omni-directional light sources require 6 shadow maps to cover every direction

  18. Perspective Shadow Maps • Shadow maps are limited by screen resolution and depend on object distance! Small distance

  19. Perspective Shadow Maps • Shadow maps are limited by screen resolution and depend on object distance! Huge distance

  20. Perspective Shadow Maps • Distort viewing transformation from light’s perspective to create a more uniform sampling from viewer’s perspective Image taken from “Perspective Shadow Maps”

  21. Perspective Shadow Maps • Distort viewing transformation from light’s perspective to create a more uniform sampling from viewer’s perspective Image taken from “Perspective Shadow Maps”

  22. Anatomy of a Shadow Surface outsideshadow volume (illuminated) Shadowingobject Lightsource Shadowvolume (infinite extent) Eye position (note that shadows are independent of the eye position) Surface insideshadow volume (shadowed) Partially shadowed object

  23. Shadow Volumes • Build polygons for shadow volumes explicitly • Render shadow volume polygons from viewer’s perspective and count inside/outside shadows Image taken from “Practical & Robust Stenciled Shadow Volumes for Hardware-Accelerated Rendering”

  24. Eyeposition Shadow Volumes Lightsource Shadowing object

  25. Eyeposition Shadow Volumes Lightsource Shadowing object zero +1 zero +2 +2 +1 +3

  26. + + + Eyeposition - - - Shadow Volumes Lightsource Shadowing object zero +1 zero Unshadowedobject +2 +2 +1 +3 Shadow Volume Count = +1+1+1-1-1-1 = 0

  27. + + + Eyeposition - Shadow Volumes Lightsource Shadowing object zero +1 zero Shadowedobject +2 +2 +1 +3 Shadow Volume Count = +1+1+1-1 = 2

  28. Eyeposition Shadow Volumes Lightsource Shadowing object zero +1 zero Unshadowedobject +2 +2 +1 +3 Shadow Volume Count = 0

  29. Implementing Shadow Volumes • For each surface, find silhouette edges • Build shadow volume (viewer independent) by extending away from light Image taken from “Practical & Robust Stenciled Shadow Volumes for Hardware-Accelerated Rendering”

  30. Implementing Shadow Volumes • Use stencil buffer to count intersections with shadow volume • Render front faces and increment if closer to viewer • Render back faces and decrement if closer to viewer • Don’t update color or depth values!!!! • If stencil buffer is non-zero, then pixel in shadow Stencil value 1 Stencil value 0 Image taken from “Practical & Robust Stenciled Shadow Volumes for Hardware-Accelerated Rendering”

  31. Shadow Volumes: Examples Images taken from “Practical & Robust Stenciled Shadow Volumes for Hardware-Accelerated Rendering”

  32. Shadow Volumes: Examples Image taken from “Doom 3”

  33. Problems with Shadow Volumes Far clipplane zero +1 +1 +2 zero +3 +2 Near clipplane

  34. Problems with Shadow Volumes Missed shadow volume intersection due to near clip plane clipping; leads to mistaken count Far clipplane zero +1 +1 +2 zero +3 +2 Near clipplane

  35. Eyeposition Problems with Shadow Volumes Lightsource Shadowing object Shadow test fails! Shadow Volume Count = 0

  36. Shadow Volumes • Advantages • Omni-directional light sources • Proper self-shadowing behavior • Pixel perfect shadows • Disadvantages • Surfaces can only use planar polygons • Silhouette computation uses CPU • Heavy on fill-rate • Near/Far clipping planes lead to problems

  37. Soft Shadows • Point lights cause hard shadows • Lights are not infinitely small points in reality • Area light sources cause soft shadows http://graphics.ucsd.edu/~henrik/images/cbox.html

  38. Soft Shadows • Point lights cause hard shadows • Lights are not infinitely small points in reality • Area light sources cause soft shadows http://graphics.ucsd.edu/~henrik/images/cbox.html

  39. Soft Shadows • Simulate area lights with lots of points lights Expensive The cluster of point lights. Image taken from “Practical & Robust Stenciled Shadow Volumes for Hardware-Accelerated Rendering”

  40. Soft Shadows • Simulate area lights with lots of points lights • Blur shadows in image space Cheap, inaccurate http://www.gamedev.net/reference/articles/article2193.asp

  41. + Eyeposition - - Solution: Invert Depth Test Lightsource Shadowing object Shadowed object Shadow Volume Count = -1+1-1=-1

  42. + Eyeposition - - Solution: Invert Depth Test Lightsource Shadowing object Now have problem with far clipping plane Shadowed object Shadow Volume Count = -1+1-1=-1

More Related