Title: Single Sample Soft Shadows Using Depth Maps
1Single Sample Soft Shadows Using Depth Maps
- Stefan Brabec and Hans-Peter Seidel
- Max-Planck-Institut für Informatik
2Overview
- Introduction
- Single sample soft shadows withdepth maps
- Implementation
- Results
- Conclusion Future Work
3Introduction
- Good-looking shadows greatly improve quality of
rendered images - For interactive applications mostly hard-shadows
are used
4Hard vs. Soft Shadows
- Hard Shadows
- Point light / directional light
- Fast rendering
- Shadow Volumes, Shadow Mapping
- Soft Shadows
- Area light / volume light
- Slow rendering
- Sampling the light source
5Soft Shadows
- E.g. sampling the area light source
- Needs a number of hard-shadow calculations and
accumulates the results - More samples gives smoother penumbra
many samples expensive rendering
6Soft Shadow Example
1. Initialize FB (white) 2. For each sample point
do 2a. Render scene 2b. Subtract 1/N from
FB only once for each pixel
(stencil) !
Image from ATI Developers Site
7Parkers Method
- Soft shadows for point lights
- Adding an outerhull to an object
- Rays inside outerhull are attenuated
8Parkers Method
- Each ray is attenuated according to distance to
inner object
9Parkers Method
- Pros
- Minimal overhead for ray casting(speed
implementation work) - Cons
- Not suitable for hardware rendering
- Adds only an outer penumbra very thick shadows
10Our Method
- Parkers 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
11Shadow Mapping
- Render depth map from light position
- Render from camera and comparetransformed z
coordinate with depthstored in lights depth map
12Shadow Mapping
13Computing Hard Shadows
- Given two depth maps (light cam)we compute
shadows as
foreach(x,y) P (x,y,depth_camerax,y) P
warp_to_light(P) if( depth_lightPx,Py lt Pz
) pixel is blocked else pixel is lit
14Adding Outer Penumbra
- Adding an outer penumbra regionto this hard
shadow
foreach(x,y) P (x,y,depth_camerax,y) P
warp_to_light(P) if( depth_lightPx,Py lt Pz
) pixel is blocked else pixel is lit
lit or outer penumbra ?
15Adding Outer Penumbra
- Add penumbra by searching forthe nearest hard
shadow - Use (Px,Py) as the starting point
- Search neighborhood fora nearby pixel that is in
hard shadow - When a maximum search radius is reached then
pixel is completely lit
16Adding Outer Penumbra
17Adding Outer Penumbra
- 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
hard shadow found
maximal extend
18Adding Outer Penumbra
larger penumbra
19Adding Outer Penumbra
- Distance receiver/light
- Varying rmax according to this distance
depth map search
20Adding Outer Penumbra
- Distance receiver/occluder
larger penumbra
21Adding Outer Penumbra
- Distance receiver/occluder
- Is known when a (possible) occluderis found
(inside the rmax region) - Dim f based on this distance
- Keep searching in rmax for minimum f
22Adding Outer Penumbra
- Distance receiver/occluder
r
m
a
x
P
depth map search
23Outer Penumbra Algorithm
search(P) rmax Pz fmin 1 search r
inside rmax found blocker at r ? rmax
rmax (Pz - depth_lightat r) f
clamp01(r/ rmax) fmin min(f, fmin ) return
fmin
receiver/light
receiver/occluder
24Adding Inner Penumbra
- Previous slide
- Algorithm that adds a penumbra to the hard
shadow (like Parkers method) - Better
- Penumbra region that also smoothesthe inner
region
25Adding Inner Penumbra
- Search scheme can also be appliedto inner
regions
c is user defined constant where inner and outer
meet (e.g. 0.5)
26Self Shadowing Problem
- Problem when searchingwith constant Pz
- Surface can shadowitself
27Self Shadowing Problem
- Solutions
- Divide scene into disjunct occludersand
receivers - Better additional search criterion
- Assign object IDs (like Hourcade)
- IDs should group logical, spatially
relatedobjects - Outer penumbra search id_light.. ! PID
- Inner penumbra search id_light.. PID
28Self Shadowing Problem
- Object IDs
- May also fail if distinct objects are nearly
adjacent - No self-shadowing with soft shadows
- Use hard shadow for such cases
- No automatic ID assignment (yet)
- Simply used scene graph structure
29Implementation
- Generating the input data
- Render depth id map fromlight source position
- e.g. store (ID mod 256) in stencil bufferand
read back 24/8 packed depth_stencil - Render depth id map fromcamera position
-
30Implementation
- Shadow computation
- Render light camera id/depth map
- read back to host memory
- Perform search
- Result attenuation map(window resolution)
- Use attenuation map to modulate light source
contribution
31Implementation
- Subpixel Accuracy
- Keep fractional partwhen warping P to P
- Reduces quantizationartifacts
32Implementation
- Adaptive Sampling
- Reduce number of searches
- Start with one search per NxN block
- Refine when
- Object IDs differ
- Hard shadow results differ
- If not, interpolate region
- Row / Column refinement
33Implementation
- Example ID of 3 differs from rest
34Results
35Results
36Results
37Results
38Results
39Conclusions
- Good looking, soft penumbra regionsusing only
information obtained froma single light source
sample - Independent of scene complexity
- like shadow mapping
- Runs at interactive frame rates
- Also suitable for ray tracing
40Future Work
- Control of penumbra size
- Frustum settings / rmax affect size
- Better define area light in scene units
- Cases where object ID method fails
- Nearby objects
- Self-shadowing with soft shadows ?
- Speed-Up
- Distance map ?
41Thank You !