1 / 41

Basic Shadow Methods

Basic Shadow Methods. Jim X. Chen George Mason University. Light source. Light. Creator. Receiver. Shadow. Observation: Shadows are places light does not reach. Light source. Creator and receiver. Creator. Receiver. Definitions. Light sources Shadow creator(occluder)s and receivers.

aabsher
Download Presentation

Basic Shadow Methods

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. Basic Shadow Methods Jim X. Chen George Mason University CS 752 Interactive Graphics Software

  2. Light source Light Creator Receiver Shadow Observation: Shadows are places light does not reach. CS 752 Interactive Graphics Software

  3. Light source Creator and receiver Creator Receiver Definitions • Light sources • Shadow creator(occluder)s and receivers CS 752 Interactive Graphics Software

  4. Shadows CS 752 Interactive Graphics Software

  5. Shadow Volume • Shadow planes • Volume formed from shadow planes • Open and infinite • Inside in shadow - outside in light • Must be clipped and capped CS 752 Interactive Graphics Software

  6. Light Cap Side Shadow Volume Dark Cap (at infinity) Shadow Volume • A point is shadowediff it is in at least one shadow volume CS 752 Interactive Graphics Software

  7. Ray Tracing Shadows • Ray tracing casts shadow feelers to a point light source. • Many light sources are illuminated over a finite area. • The shadows between these are substantially different. • Area light sources cast soft shadows • Penumbra • Umbra CS 752 Interactive Graphics Software

  8. Soft Shadows CS 752 Interactive Graphics Software

  9. Soft Shadows • Umbra – No part of the light source is visible. • Penumbra – Part of the light source is occluded and part is visible (to a varying degree). • Which part? How much? What is the Light Intensity reaching the surface? CS 752 Interactive Graphics Software

  10. Anti-Aliasing • Supersampling • Jittering – Stochastic Method eye CS 752 Interactive Graphics Software

  11. Supersampling • 1 sample per pixel CS 752 Interactive Graphics Software

  12. Supersampling • 16 samples per pixel CS 752 Interactive Graphics Software

  13. Supersampling • 256 samples per pixel CS 752 Interactive Graphics Software

  14. Monte Carlo Integration • For each hit point, use a bundle of rays and take the average - Expensive • Monte Carlo Approach • Using a randomly chosen ray at each hit point • Average the value from each ray CS 752 Interactive Graphics Software

  15. Result: Hard Shadow - Cube Without antialiasing With antialiasing CS 752 Interactive Graphics Software

  16. Result: Soft Shadow - Ball Hard shadow Soft shadow CS 752 Interactive Graphics Software

  17. More Shadow Algorithms • Fake Shadow • Vertex Projection • Shadow Z-Buffer • Shadow Volume • … CS 752 Interactive Graphics Software

  18. Fake Shadow • No exact calculation • Approximation of shadow position and shape • Estimated by center or anchor of object • Pro: simple, fast • Contra: flat ground, only ground shading, not exact, rotate limitations CS 752 Interactive Graphics Software

  19. Vertex Projection • Object projected to ground • Exact mathematical calculation • Pro: still simple, exact, no rotate limitations • Contra: flat ground, only ground shading CS 752 Interactive Graphics Software

  20. Projection Shadows • Project creator geometry onto receiver plane [Blinn] • Projection matrix M • p=Mv l=(lx,ly,lz) y v p y=0 CS 752 Interactive Graphics Software

  21. Projection Shadows • Render projected polygons to an image (render-to-texture) • Apply image as a texture onto the receivers • Compute texture coords on the fly • Use projective texturing • Advantage: • Texture can be projected onto multiple shadow receivers • Do not need to regenerate texture if static scene • Limitation: objects can either cast or receive a shadow, not both CS 752 Interactive Graphics Software

  22. Shadow Z-buffer CS 752 Interactive Graphics Software

  23. Shadow Z-buffer • Based on hidden surfaces • Light’s point of view rendering into Z-Buffer • Camera’s point of view rendering, lookup in Z-Buffer • Transformation between camera and light view • Z-value compare - shadowed or lit CS 752 Interactive Graphics Software

  24. Shadow Z-buffer • Render the scene twice • First from the light source • Need z-buffer only • Second from the camera • Each time we scan a pixel P (xv,yv,zv) transform P to light space (xs,yz,zs) and test zs against stored value in z-buffer from light • If less than or equal to this value it is lit CS 752 Interactive Graphics Software

  25. Shadow Z-buffer • “Less than or equal” test is imprecise • it is only accurate in the image space of the light • self-shadowing: small fudge factor • Imagine a shadow throw over complex objects or long distances • point-sampling: area-sampling CS 752 Interactive Graphics Software

  26. Shadow Volume Techniques CS 752 Interactive Graphics Software

  27. Shadow Volumes • Just like a polygon - you are inside a volume if you need to cross a surface to exist it • General idea of shadow volumes is count the number of shadow planes you cross • +1 for front facing • -1 for back facing • If total is >0 you are in shadow • Special case if the eye itself is in shadow CS 752 Interactive Graphics Software

  28. Shadow Volumes • Two stages: 1) Preprocessing • Find all planes of the shadow volume and their plane equations 2) At run-time • Determine shadow plane count per pixel • Use a scan-line method OR stencil test CS 752 Interactive Graphics Software

  29. Using Stencil Test • Three steps: • silhouette generation • drawing of shadow volume(s) • rendering the shadow CS 752 Interactive Graphics Software

  30. Shadow Volume Stencil Test • A stencil buffer is screen sized buffer (1-8bit) that stores a flag about a rendering operation • E.G. stencil[x,y] is negated if zbuffer[x,y] is less than current z value (i.e. stencil is set if and only if z buffer test passes) • Many uses in graphics CS 752 Interactive Graphics Software

  31. Shadow Volume Stencil Test • Render the scene into the RGB and z-buffer • Turn z-buffer writing off, then render all shadow polygons with the stencil buffer • Increment stencil count for front-facing • Decrement for back facing • Re-render scene with lighting OFF and only render pixels where stencil is non-zero CS 752 Interactive Graphics Software

  32. Shadow Volumes cont. • Step 1: Silhouette generation • boundaries between adjacent front-facing and back-facing polygons  silhouette • adding light vertex to silhouette vertexes  shadow planes • shadow planes together with object  shadow volume CS 752 Interactive Graphics Software

  33. Shadow Volumes cont. • Step 2: Drawing of Shadow volume • rendered in stencil buffer CS 752 Interactive Graphics Software

  34. Shadow Volumes cont. • Step 3: Rendering the Shadow • stencil buffer holds shadow • render a polygon using stencil buffer bits • shadow for one light created • Repeat for next light from step 1 CS 752 Interactive Graphics Software

  35. Shadow Volumes cont. • Pro: • greatly improved realism • hardware support of stencil buffer • Contra: • high requirement on fill-rate • sharp shadow • additional scene management CS 752 Interactive Graphics Software

  36. Shadow Volume BSP Trees • Instead of calculating shadows in imagecalculate in object space • Break up objects into shadowed and un-shadowed objects • Saves time shading pixels • More polygons (potentially many more) • Precision problems CS 752 Interactive Graphics Software

  37. Starting the SVBSP Tree CS 752 Interactive Graphics Software

  38. Continuing the SVBSP Tree CS 752 Interactive Graphics Software

  39. Finishing the SVBSP Tree • Can continue until ALL polygons are in the SVBSP tree • Usually put shadow casting polygons in the tree first, and then filter remaining polygons down the tree to see if they are lit or un-lit • A polygon that ends up at an in-node is stored there as shadowed but doesn’t force the tree to be expanded CS 752 Interactive Graphics Software

  40. Summary Projected Polygons Good: Simple, quick, and all hardware can do it. Bad: Can only cast shadows to a plane. Project to Create a Texture Good: Semitransparent, can reuse texture created, and can project shadow onto any surfaces. Bad: Objects either cast or receive shadows, not both. CS 752 Interactive Graphics Software

  41. Summary, continued Shadow Maps Good: Anything to anything, constant cost regardless of complexity, map can sometimes be reused. Bad: Only feasible on some hardware, frustum limited. Shadow Volumes Good: Anything can shadow anything, including self- shadowing, and the shadows are crisp. Bad: shadow polygons must be generated and rendered (lots of polygons & fill), CPU intensive. CS 752 Interactive Graphics Software

More Related