• Like
  • Save
Shadow Techniques for Real-Time and Interactive Applications
Upcoming SlideShare
Loading in...5
×

Shadow Techniques for Real-Time and Interactive Applications

  • 987 views
Uploaded on

PhD defense

PhD defense

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
987
On Slideshare
0
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
0
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. Shadow Techniques for Real-Time and Interactive Applications Stefan Brabec Promotionskolloquium MPI Informatik, Saarbrücken, Germany 3.2.2004
  • 2. Importance of Shadows
    • Shadows play important role in understanding the spatial relationship of objects in the scene
      • Occluder
      • Receiver
      • Light source
    • Good looking shadows give more realistic images
    Leonardo Da Vinci
  • 3. Shadows in Computer Graphics
    • Efficient methods for computing shadows are still a challenging task in computer graphics
    • Early work on shadow techniques [Arthur Appel, IBM Research, 1968]
  • 4. Shadows in Computer Graphics
    • Many algorithms proposed to compute shadows
    • But only a few techniques are suitable for real-time or interactive applications
    Discontinuity Meshing [Heckbert92]
  • 5. Shadows for Real-Time Applications
    • Refresh rate ~ 30 to 60 fps
      • Games
      • VR Simulations
      • Virtual TV Set
    • Only hardware-accelerated methods
      • CPU resources dedicated for other tasks
        • Sound, physics, AI, input
    Doom3
  • 6. Shadows for Interactive Applications
    • Refresh rate ~ 10 to 30 fps
      • CAD/CAM
      • Digital Content Creation (DCC)
      • VR Interaction
    • Hybrid approaches possible
      • Combined CPU & GPU shadow technique
    SolidWorks
  • 7. Shadows for Non-Interactive Applications
    • New group of applications
      • Hardware-accelerated rendering methods for offline rendering (preview, production)
      • Example: Alias Maya6 hardware-renderer
    Maya Software Maya OpenGL
  • 8. Computing Shadows
    • To compute shadows we need to analyse the spatial relationship of
      • Receiver
      • Light source
      • Occluders
    • Result: intensity distribution on receiver
  • 9. Related Work
    • Algorithms for computing hard shadows
      • Projected Shadows [Blinn88]
      • Shadow Maps [Williams78]
      • Shadow Volumes [Crow77]
    • Algorithms for computing soft shadows
      • Plateaus [Haines01]
      • Smoothies [Chan03]
      • Penumbra Wedges [Akenine-M öller /Assarsson02/03]
      • Convolution [Soler98]
  • 10. Shadow Mapping [Williams78]
    • Image-based method
      • Compute shadow map from light view (depth buffer)
      • Compute final image
        • compare actual vs. stored depth
  • 11. Shadow Mapping
    • Well suited for hardware-accelerated rendering [Segal92]
      • Like texture mapping but with depth values
        • Depth textures, texture compare mode
      • First realized in SGI’s Infinite Reality
        • Now available on all consumer-cards
  • 12. Shadow Mapping
    • But: shadow quality may suffer from sampling artifacts
    Blocky shadow edges due to limited shadow map resolution
  • 13. Improve Sampling Rate
    • Related work
      • Perspective Shadow Maps [Stamminger02]
        • Shadow mapping in post-perspective space
      • Adaptive Shadow Maps [Fernando01]
        • Hierarchical shadow map refinement
    • Our approach
      • Optimize light frustum for current camera view
  • 14. Practical Shadow Mapping
    • Render scene with projected texture
      • Control texture encodes cells in shadow map
    • Read back image
      • Find those cells which are actually used
  • 15. Practical Shadow Mapping
    • Fit light frustum to visible cells
      • Axis-aligned bounding box
      • Minimum-area bounding rectangle
    • Generate shadow map using the optimized frustum
    map regions used regions new map frustum
  • 16. Practical Shadow Mapping optimized shadow map normal shadow map
  • 17. Practical Shadow Mapping
    • Control texture can also be used to improve depth sampling
    • Reduces artifacts due to limited numerical precision
    Self shadowing Missing shadows
  • 18. Practical Shadow Mapping
    • Adjust z-range (near/far) for visible objects
    z-range relevant z-range Normal approach: Near & far plane encloses all objects ! Better: Near & far plane encloses all from camera visible objects !
  • 19. Practical Shadow Mapping
    • Use 1D control texture that maps light distance to color (z-ramp)
      • Detect relevant z-range e.g. [0.42;0.72]
    0 range used 1
  • 20. Practical Shadow Mapping
    • Problem:
      • Objects in front of near plane are shadow casters !
    • Solution:
      • Clamp depth values
        • One bit for objects in front enough (blocked: yes/no)
      • Possible on many cards using depth replace operation
      • Direct support on GeForceFX
  • 21. Practical Shadow Mapping
    • Can even go further and optimize depth distribution between near and far plane
      • Histogram equalization
      • Improves depth contrast
    Red: original distribution Green: normalized distribution z
  • 22. Practical Shadow Mapping
    • Summary
      • Various ways to optimize light source’s viewing frustum
      • Better shadow quality
      • Most steps are hardware-accelerated
        • Read-back of control image is main bottleneck
    • Extensions
      • Full hardware implementation
      • Combine with other methods
        • Perspective Shadow Maps
  • 23. Shadow Mapping
    • Previous slides:
      • Concentrated on quality improvements for the classical shadow map approach
    • But: there are special situations where the standard approach fails
      • E.g. spotlight with extreme cut-off angle
  • 24. Shadow Mapping
    • How to capture depth information for the complete environment ?
      • Needed when using omni-directional light sources
    • Simple solution:
      • Use six shadow maps (cube map texture)
      • Needs 6+1 rendering passes !
  • 25. Dual-Paraboloid Shadow Mapping
    • Idea: Use dual-paraboloid mapping for shadow maps
      • Proposed by [Heidrich98b] for environment mapping
      • One map covers one hemisphere
        • Only two maps for full environment (two paraboloid maps attached back-to-back)
      • Good sampling ratio
        • No singularity as e.g. with spherical maps
  • 26. Dual-Paraboloid Shadow Mapping
    • Perfectly reflecting paraboloid as seen by an orthographic camera
    • Maps a 3D direction onto a 2D point on the paraboloid
    • By adding euclidian distance to light source we get a 3D-3D transformation
      • Parabolic coordinates for shadow map lookup
      • Euclidian distance for shadow test
  • 27. Dual-Paraboloid Shadow Mapping
    • Full environment in 2+1 passes
    first hemisphere second hemisphere final image with two shadow maps applied 1 2 3
  • 28. Dual-Paraboloid Shadow Mapping
    • Implementation
      • Fully hardware-accelerated
      • Use vertex shader for paraboloid transformation
        • Cannot change pixel position in fragment stage
        • Need highly tesselated scenes to get along with linear interpolation
  • 29. Dual-Paraboloid Shadow Mapping
    • Summary
      • Can use shadow mapping for
        • Omni-directional light sources (2+1 passes)
        • Hemispherical light sources (1+1 passes)
      • Hardware-accelerated
        • Need vertex transformation and shadow mapping
      • High tesselation requiered
    • Extensions
      • May use adaptive tesselation
        • Displacement mapping
  • 30. Shadow Volumes [Crow77]
    • Object-space algorithm
      • Compute regions of shadow in 3D
        • Per-pixel correct shadow information
        • Cast shadows onto arbitrary receiver geometry
      • Mostly used in games for selected shadow casters
        • Characters etc.
  • 31. Shadow Volumes
    • Extend occluder polygons to form semi-infinite volumes
      • Light source is center-of-projection
      • Everything behind occluder is in shadow
    occluder light shadow region lit
  • 32. Shadow Volume Rendering
    • Stencil-based shadow volumes [Heidmann ‘91] Real shadows real time
      • count in-out events using the stencil buffer
  • 33. Shadow Volume Rendering
    • Problem:
      • High number of rendering passes for many light sources
    initialize z-buffer shadow volumes light contribution ambient contribution repeat for all lights final image
  • 34. Combined Shadow Mask
    • Idea
      • Reduce rendering passes by storing intermediate results as shadow mask
    repeat shadow volumes L i shadow volumes L i+1 shadow volumes L i+N shadow mask light contribution L i ....L i+N times
  • 35. Combined Shadow Mask
    • Example
      • Use N=4 and store shadow mask as RGBA screen-space texture map
      • Apply contribution for each light using custom fragment shader
      • Sum is also at higher precision (float) as when using framebuffer accumulation
  • 36. Combined Shadow Mask
    • Efficiently used this approach for rendering architectural scenes
  • 37. Combined Shadow Mask
    • Shadow mask can also be used to store parts of the illumination
      • Include monochromatic goniometric diagrams
        • Describes non-uniform intensity distribution
      • Lookup cube map for non shadowed pixel
      • Mask is value in [0;1]
      • Nearly for free, since texture lookup is not the bottleneck
    -X +X -Z +Z +Y -Y
  • 38. Combined Shadow Mask
    • Example with goniometric diagrams
  • 39. Combined Shadow Mask
    • Summary
      • Storing intermediate results reduces number of scene rendering passes
      • Shadow mask texture can be used to store parts of the illumination
      • Contribution of light sources is accumulated at higher precision
    • Extensions
      • Can be combined with all shadow volume variants
  • 40. Shadow Volumes
    • Previous slides
      • Reduced cost of rendering shadow volumes
    • Another big problem
      • Generation of shadow volumes can be quite expensive
        • Usually done on CPU
        • Need to synchronize CPU and GPU
          • Shadow volumes should be ready when GPU gets ready to render them
  • 41. Shadow Volume Generation
    • Trivial way: one volume for each polygon
      • Number of shadow volumes puts heavy load on GPU (fill-rate) !
    • Better: silhouette-based approach
      • Need to check each edge with each light for front/back-facing condition
    Mesh as seen by light source Silhouette
  • 42. Shadow Volume Generation
    • Checking the front/back facing condition is normally a trivial task
    • Silhouette detection is not trivial for complex vertex shaders !
    • How do we handle GPU transformation ?
  • 43. Shadow Volume Generation
    • From some OpenGL discussion forum:
  • 44. Silhouette Detection on GPU
    • Use graphics hardware to compute silhouettes
    • State-of-the-art hardware allows computation in object space
      • Floating point calculations
      • Floating point textures
      • Powerful, programmable vertex and fragment processing units
  • 45. Silhouette Detection on GPU
    • Restriction on input data
      • Triangle meshes
      • Closed meshes with two triangles per edge
      • Connectivity is known (pre-computed)
    Example: This is not a closed mesh, but since we are only focusing on one edge of this mesh its ok.
  • 46. Silhouette Detection on GPU
    • Need all data in global coordinate system
      • Assign each vertex a unique identifier
      • Render one point per vertex and store away world/eye space position
    P 0 P 1 P 2 P 3 P 4 position texture P 0 P 1 P 2 P 3 P 4 P N
  • 47. Silhouette Detection on GPU
    • Process edges
      • Unique identifier per edge
      • Each edge has vertex indices for
        • Its endpoints
        • Adjacent triangles
    E 0_idx P 0_idx P 1_idx P 3_idx P 4_idx glBegin(GL_POINTS) ; glAttrib(P0_idx, P3_idx, P1_idx, P4_idx); glVertex1f(E0_idx); glEnd();
  • 48. Silhouette Detection on GPU
    • Check front/back face condition for each edge
    E 0_idx P 0_idx P 1_idx P 3_idx P 4_idx input data 4 texture lookups for world space positions P 0 P 1 P 3 P 4 registers P 3 P 0 P 1 P 4 N 1 = (P 3 –P 0 )x(P 1 –P 0 ) N 2 = (P 4 –P 0 )x(P 3 –P 0 ) front & back facing ? position texture P 0 P 1 P 2 P 3 P 4 Light Store silhouette flag (yes/no) at edge index E 0 E 1 E 2 E 3 E 4 E M edge texture
  • 49. Shadow Volume Rendering
    • Final step
      • Use position texture for world space lookup
      • Use edge texture for silhouette condition
        • If not a silhouette edge move outside view (will be culled away early)
      • Render quad for each edge
    P 0 L P 3 P 0- L P 3- L
  • 50. Shadow Volumes on GPU
    • Example with three lights and dynamic vertex deformation
  • 51. Shadow Volumes on GPU
    • Summary
      • Fully hardware-accelerated implementation, including silhouette detection
        • Supports custom vertex shaders
        • Works for multiple lights in parallel
      • No CPU resources needed
        • Just pre-processing
      • Relies on recent hardware capabilities
        • Render-to-vertex-array or
        • Texture-lookup in vertex shader
    • Extensions
      • Include culling methods to reduce fill rate
  • 52. Soft Shadow Techniques
    • Up to now
      • Computing hard shadows
        • Point, directional, and spot lights
        • Relatively easy since only binary result (lit or shadow)
    • Next
      • Computing soft shadows
        • Linear or area light sources
        • Complex visibility function
  • 53. Soft Shadow Maps
    • Generate soft shadows for linear lights
      • Light source represented by line segment
      • Good approximation for long, thin lamps
      • Penumbra region when occluder edge is not parallel to light source
    Point Light Source Linear Light Source
  • 54. Soft Shadow Maps
    • Visibility of Light Source
      • 100% to 0% for [p1,p2]
      • 0% for [p2,q2]
      • 0% to 100% for [q2,q1]
    • Idea
      • normal shadow maps for umbra and completely lit regions
      • linear interpolation of visibility for penumbra regions
        • Stored as visibility map
  • 55. Soft Shadow Maps
    • Visibility Map
      • additional shadow map channel (percentage visibility)
      • two-channel shadow map for each sample point
  • 56. Soft Shadow Maps
    • Generating the Visibility Map
      • triangulate depth discontinuities
      • warp resulting skin polygons to other view
  • 57. Soft Shadow Maps
    • Generating the Visibility Map
      • render skin polygons to visibility map
      • Gouraud-Shading (linear interpolation)
        • “ white” for vertices on receiver
        • “ black” for vertices on occluder
      • completely lit regions
        • default visibility 0.5
      • completely shadowed regions
        • first shadow map channel
  • 58. Soft Shadow Maps
    • Generating the visibility map
    depth map edge detection triangulate render+shade visibility map to 3D warp
  • 59. Soft Shadow Map Algorithm shade(p) { if( depth 1 (p) > S 1 [p] ) l 1 = 0; else l 1 = V 1 [p] * illum(p,L 1 ); if( depth 2 (p) > S 2 [p] ) l 2 = 0; else l 2 = V 2 [p] * illum(p,L 2 ); return l 1 +l 2 ; } S 1 V 1 S 2 V 2
  • 60. Soft Shadow Maps
    • Summary
      • Efficient way to compute soft shadows for linear light sources
        • E.g. using only two sample points
      • Hardware-accelerated
        • Only depth triangulation done on CPU
    • Extensions
      • Extend to work for area lights
        • Area approximation [Ying02]
      • Perform depth triangulation on GPU
        • Possible with render-to-vertex-array
  • 61. Single Sample Soft Shadows
    • Algorithm that approximates soft shadows using only one sample point on the light
    • Is this information sufficient to produce good looking soft shadows ?
  • 62. Single Sample Soft Shadows
    • Based on [Parker98] method for ray tracing
      • Adding an outer hull to an object
      • Rays inside outer hull are attenuated according to the distance to object
  • 63. Single Sample Soft Shadows
    • Our method
      • Parker’s idea adapted for hardware rendering
        • Use sampled input data (depth maps)
          • Shadow map algorithm
        • Concept of extended occluders
          • Search for hard shadow/lit regions
      • But:
        • Penumbra for outer and inner regions
  • 64. Single Sample Soft Shadows
    • Searching for blocked pixels
      • Transform pixel position to light source coordinate system
      • If pixel is lit (shadow test) search neighborhood for nearest blocked pixel
      • Limit search by
  • 65. Single Sample Soft Shadows
    • Assign attenuation value
      • f rises up from 0 (no illum) to 1 (full illum)
    • To do
      • Define properties that affect size of penumbra
      • Integrate those into the search scheme
    maximal extend hard shadow found
  • 66. Single Sample Soft Shadows
    • Distance receiver/light
      • Varying r max according to this distance
    P ` r m a x 2 r m a x 1 depth map search larger penumbra
  • 67. Single Sample Soft Shadows
    • Distance receiver/occluder
      • Problem: need to find occluder first
        • searching r max region
      • Dim f based on this distance
      • Keep searching in r max for minimum f
    larger penumbra
  • 68. Single Sample Soft Shadows
    • Adopted Parker’s scheme to add an outer penumbra to an umbra region
      • Gives unrealistic thick shadows
    • Can add inner penumbra by reverse search:
    c is user defined constant where inner and outer meet (e.g. 0.5) f  [0.0;c) f  [c;1.0] Attenuation depth_light[…] – depth_light[P` x , P` y ] P` z - depth_light[…] r`max = rmax * lit pixels blocked pixels Search for pixel is blocked pixel is lit Search when Inner Penumbra Outer Penumbra
  • 69. Single Sample Soft Shadows
    • Implementation
      • Depth map generation on graphics card
      • Search done on CPU
        • Read-back is bottleneck
      • Attenuation applied as texture map
      • Still very fast
    ~20 fps (P4 + GF4) Light depth map: 512x125 Window resolution: 512x512
  • 70. Single Sample Soft Shadows
    • Summary
      • Fast soft shadow approximation using a single light source sample
      • Generation of input data on GPU
      • Simple search scheme
    • Extensions
      • Search on GPU
      • Optimized CPU search
        • Shadow width maps [Kirsch03]
      • Include shape of area light
  • 71. Conclusions & Future Work
    • Conclusions
      • Efficient and robust hard shadows can be computed using state-of-the-art hardware
      • Real-time soft shadows are currently based on rough approximations
        • Fake penumbra using point light sources
    • Future work
      • Real-time soft shadows is the main research direction
      • Need better algorithms for special situations
        • E.g. hair, fur, particles
  • 72. Thank You !