Translucent Shadow Maps

Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

Eurographics Symposium on Rendering 2003

Per Christensen and Daniel Cohen-Or (Editors)

Translucent Shadow Maps

Carsten Dachsbacher† and Marc Stamminger‡

Computer Graphics Group, Department of Computer Science, University of Erlangen-Nuremberg, Germany

Abstract
Shadow maps are a very efficient means to add shadows to arbitrary scenes. In this paper, we introduce Translu-
cent Shadow Maps, an extension to shadow maps which allows very efficient rendering of sub-surface scatter-
ing. Translucent Shadow Maps contain depth and incident light information. Sub-surface scattering is computed
on-the-fly during rendering by filtering the shadow map neighborhood. This filtering is done efficiently using a
hierarchical approach. We describe optimizations for an implementation of Translucent Shadow Maps on contem-
porary graphics hardware, that can render complex translucent objects with varying light and material properties
in real-time.
Categories and Subject Descriptors (according to ACM CCS): I.3.7 [Computer Graphics]: Color, shading, shadow-
ing, and texture

1. Introduction softness in their appearance. Researchers early recognized


that for realistic rendering of natural objects sub-surface
Shadow maps are widely used for adding shadow to ar-
11
scattering is essential. However, the correct simulation is
bitrary scenes in real-time computer graphics. Each texel
challenging and requires complex computations. Jensen et
of the shadow map texture – rendered with a virtual cam-
al.6, 4 described an approximation that breaks the computa-
era placed at the lights’ position – stores the distance of
tion down to a radiosity-like 2D-integral over the object sur-
the closest surface to the light source. This information is
face, which allows faster, but not yet interactive rendering.
used in the rendering pass of the final image to determine
whether a point lies in shadow by comparing its light source The idea of Translucent Shadow Maps is to extend a
with the shadow map distance, which can be achieved on shadow map so that all information to compute translucency
modern graphics hardware as a simple texture lookup and is is available. A pixel in the Translucent Shadow Map stores
thus very cheap. But also in offline rendering systems like not only the depth and thus 3D-position of the sample, but
RenderMan shadow maps are widely used due to their effi- also the irradiance entering the object at that position and
ciency and generality.8 the surface normal. The translucency integral from Jensen6
can then be computed as a filter on the color values, where
In this paper, we extend the binary shadow map lookup
the filter weights depend on the corresponding depth and
to a shadow map filter that implements sub-surface scatter-
normal values. By using a hierarchical filtering technique
ing. As sub-surface scattering all light reflection processes
based on mip-maps, this filtering can be computed in real
are summarized that happen underneath an optical bound-
time in a fragment program on contemporary graphics hard-
ary surface. By this, the lighting on soft objects, in particular
ware, where our implementation is restricted to parallel light
shadows, is blurred, and thin object parts become translu-
sources.
cent. Bidirectional reflection distribution functions (BRDFs)
cannot model this behavior, their definition assumes that the
reflection point is the point of incidence. Thus, many com- 2. Previous Work
puter generated objects look too harsh and lack a natural
The light scattering in translucent materials can be treated
like global illumination in other, usually less dense
† e-mail: [email protected] participating media, e.g. by Monte-Carlo or finite element
‡ e-mail: [email protected] based global illumination algorithms 1, 5, 10 . In Hanrahan et

c The Eurographics Association 2003.


197
Dachsbacher et al / Translucent Shadow Maps

al.3 , a model has been presented that adds sub-surface scat- object to xout . This 4D-function does not only depend on
tering effects for the special case of layered surfaces. Jensen ||xout − xin ||, but also on the angle between xout − xin and the
at al.6 presented a more general model for light reflection on surface normal in xin :
solid translucent objects, based on BSSRDFs (bidirectional Z
surface scattering distribution function), which are a gen- B(xout ) = E(xin )Rd (xin , xout )dxin (2)
S
eralization of BRDFs with possibly distinct light incidence
and exitance points. The higher dimensionality of BSSRDFs In this integral it is assumed that the path from xin to xout
compared to BRDFs results in longer computation times, is completely within the object, which is in general the case
but the method is still much faster than a full Monte-Carlo only for convex objects. So errors occur for concave objects,
simulation. A more rapid, hierarchical evaluation technique however, in practice this kind of error is often visually not
for this model was introduced by Jensen et al.4 . The separa- important. Finally the light leaves the object, again weighted
tion of incident light computation and BSSRDF integration by Ft :
as well as a hierarchical integration technique dramatically 1
L(xout , ωout ) = Ft (η, ωout )B(xout ) (3)
reduce computation time to a few seconds. Although this π
strategy is similar to the method presented in this paper, we
accomplish this concept in a completely different way. By The simulation path is also depicted in Fig. 1.
using a shadow map as intermediate irradiance representa-
tion, we are restricted to illumination from point or parallel
light sources, however, the computation of the irradiance and
the hierarchical integration are even more simplified and can
be completely passed to the graphics processing unit (GPU).
Another accelerated computation technique for Jensen’s
BSSRDF model has been presented by Lensch et al.7 . In
this paper, the authors use a mixture of radiosity-like fi-
nite element computations and texture filtering to evaluate
the BSSRDF integral. The method requires significant pre-
computation for a texture atlas, form factors, and filter ker-
nels. After this, the models can be rendered interactively
with moving light sources at several frames per second. Figure 1: Computing translucency by integration.

3. Translucent Shadow Maps


In the original sub-surface model of Jensen6 sub-surface With Translucent Shadow Maps (TSMs), the simulation
scattering is described as a sum of a single and a multiple is separated (Fig. 2). The first phase (Equ. 1) is computed
scattering term. As in Lensch et al.7 we restrict ourselves during the generation of the TSM. Additionally to depth, a
to multiple scattering effects. This is arguable for materials TSM stores irradiance E(xin ) and the surface normal N(xin )
with high albedo – like marble, milk or skin – because sin- with every pixel (see Fig. 3). The surface normal is required
gle scattering has only small contribution to the re-emitted later to compute Rd . Note, that E(xin ) is wavelength depen-
radiance in these cases6 . Note that in the case of multiple dent, thus we store a red, green and blue color component
scattering any relation between directions of incident light which allows us to use arbitrary textured surfaces.
and exitance is lost, which makes it easier to handle.
The sub-surface scattering in highly scattering material
can be separated into three phases. First, the light incident
at a surface point xin is scattered into the material according
to the Fresnel term Ft . For an irradiance impulse I(ωin ) from
a point or parallel light source this is simply:
E(xin ) = Ft (η, ωin )|N(xin ) · ωin |I(ωin ), (1)
where η is the optical density of the material. The Fresnel Figure 2: The Translucent Shadow Map stores irradiance
term Ft can be well approximated as proposed by Schlick9 . samples (left). The radiance leaving the object is then com-
Second, light diffuses through the material. This diffu- puted by filtering these irradiance samples (right).
sion process is approximated by the diffuse sub-surface re-
flectance function Rd (xin , xout ) with xin , xout ∈ S, which can
be compared with the geometric term in radiosity. Rd de- Having this information, the integral in Equ. 2 can be
scribes the transport of incident light at xin through the computed during rendering of the user’s view as a filter

c The Eurographics Association 2003.


198
Dachsbacher et al / Translucent Shadow Maps

tion by splitting up the evaluation of the sub-surface scat-


tering into two independent steps: the local response and
the global response (see Fig. 6). The latter is evaluated
as described above and represents sub-surface scattering at
larger distances. This can be either done per fragment or per
vertex (and interpolated across polygons during rendering)
since this appears as a smooth function. The local response,
which describes the short distance sub-surface light trans-
Figure 3: The Translucent Shadow Map contains irradi- port, could be evaluated exactly the same way, but we apply
ance, depth, and surface normal. simplifications to speed up the rendering: for the calcula-
tion of the transmitted light in this case we ignore the dif-
ference of the depth values associated with the sample texel
and xout . This results in a very simple filter with a fixed sam-
of the TSM color values, with weights given by Rd . For
pling scheme. All texels in the neighborhood of xout (in light
the evaluation of Rd , xin is computed from the TSM depth
space) with a depth value in a certain proximity to the depth
value and the required normal N(xin ) is taken from the TSM
value of xout are weighted and summed up. Samples outside
(Fig. 4).
this depth proximity are handled by the global response.
The filter weights heavily depend on ∆z. For large ∆z, the
weigths are small and decrease only slowly with (∆x, ∆y). reduced scattering coefficient σ0s
If ∆z is small, the central weights are large and decrease absorption coefficient σa
quickly. Generally, the filter must be large enough to cover relative refraction index η
all regions where Rd is significantly large – for natural ma- Fresnel transmittance factor Ft (η, ω)
terials this can be in the order of centimeters. Because large in- and out-scattering location xin , xout
filters are expensive, we use a hierarchical filter based on a in- and out-scattering direction ωin , ωout
mip-map of the TSM. In our filter sample pattern of 21 sam- surface normal at xin Nin
ple positions, shown in Fig. 4, sampling density decreases
with the distance to the origin. The outer samples represent α0 e−σtr dr
Rd (xin , xout ) = [zr (σtr dr + 1) 0 3
a larger filter area, thus their irradiance, depth and normal 4π σt dr
values area are taken at coarser mip-map levels (see Fig. 4). e−σtr dv
The pattern reflects the fact that Rd decreases rapidly with +zv (σtr dv + 1) ]
σt0 dv3
the sample distance. The pattern is based on heuristics; as
shown above, the filter value distribution heavily depends on zr = 1/σt0 zv = zr + 4AD
∆z, so there is no globally optimal pattern. dr = ||xr − xout ||, withxr = xin − zr · Nin
dv = ||xv − xout ||, withxv = xin + zv · Nin
N ∆y
1 + Fdr 1
x in
A = D= 0
1 − Fdr 3σt
1.440 0.710
R ∆z Fdr = − 2 + + 0.668 + 0.0636η
η η
∆x
σ0
q
x out σtr = 3σa σt0 σt0 = σa + σ0s α0 = s0
σt
∆x/∆y

Figure 4: Filtering the TSM. Left: computing R, ∆x and ∆y Figure 5: Quantities and equations describing the BSSRDF
from the TSM. Right: Sampling pattern. diffusion term.

The TSM of an object also contains background pix-


els, i.e. pixels not showing the object. In order to avoid
4. Implementation
that invalid values from these pixels diffuse into the result
through the mip-map filter, we add an alpha image. For back- For the implementation of the Translucent Shadow Maps we
ground pixels, this alpha image, irradiance, and normal are used OpenGL and the extensions introduced with the Di-
set to zero, otherwise pixels get an alpha of one. After mip- rectX9 generation of graphic processing units, namely pro-
mapping, we weight all mip-mapped values by 1/α, result- grammable vertex and fragment processing.
ing in an average value for non-background pixels only.
In the first rendering pass of each frame the Translucent
As in Lensch et al.7 we further optimize the computa- Shadow Map is generated. We use two simultaneous render

c The Eurographics Association 2003.


199
Dachsbacher et al / Translucent Shadow Maps

targets: in the first one we store the amount of light pene- xout . Note that small values of T are treated in the local
trating the materials boundary (in the red, green and blue response and are excluded in this context by adapting the
component). This fraction is described by the Fresnel term lookup texture appropriately.
which we approximate as proposed by Schlick9 . The sec-
The third texture coordinate R enumerates the 21 samples
ond render target contains the distance from the light source
from our hierarchical sampling scheme. Each sample has
to the visible surfaces, thus the light space depth-buffer,
constant offset relative to (u, v)T and a particular mip-map
which corresponds to a standard shadow map. Furthermore
bias value for the TSM lookup. If our light source is parallel,
the 2D-projection of the (normalized) surface normals onto
(rx , ry ) is constant for every sample and can thus be assumed
the plane orthogonal to the lights’ direction is stored as color.
to be constant within each texture slice with R = const. This
Since visible surfaces (in the Translucent Shadow Map) are
quantization trick is not possible with point lights, in this
oriented towards the light direction, this information suffices
case more intricate computations become necessary.
to reconstruct the surface normal.
All this ends up in a three dimensional texture consist-
In the subsequent rendering passes we evaluate the local
ing of 21 slices. Each slice contains for a particular sam-
and global response for each surface point xout rendered in
ple of our sampling scheme the filter value Rd (xin , xout ) for
the camera view. The point’s coordinates are transformed
all possible quantized normals (first slice dimension) and rz
into light space to determine its texture coordinates (u, v)T in
(second slice dimension).
the Translucent Shadow Map and its distance d to the light
source. The texture slices of the material property 3D texture con-
tain only low frequency color gradients. Therefore, a low
The local response is determined by an image filter with
resolution 3D texture of the size 64 × 64 × 32 for each type
a size of 7 × 7 texels where the neighborhood of (u, v)T
of material proved to be sufficient. Note that the third di-
serves as input. The incoming radiance at the neighboring
mension of the texture has an extent of 32, which is the
texels only contributes to the outgoing radiance, if the texel’s
next power of two to 21. It is generated in a pre-processing
depth values lies within a certain proximity to d. If the stored
step during initialization in approximately 150ms on a Pen-
depth value at (u, v)T is significantly smaller than d, then the
tium 4 processor with 2.4GHz, so material properties can be
currently processed surface point is shadowed by the sur-
changed interactively with almost no delay.
face part represented by this texel. All contributing texels
are summed up using constant, precomputed weights, ignor-
ing depth difference. In the rendering passes for the local re- Model FPS #Vertices #Triangles
sponse we also calculate the local illumination depending on
the Fresnel term for reflected light. All this work is done by a Simple Cube 99.7 8 12
vertex and a fragment program. The number of required ren- Triceratops 80.0 2832 5660
dering passes depends on the deployed graphics hardware. Horse-10k 50.2 5068 10132
Horse-100k 10.0 48485 96966
For the global response the incoming light from the hemi-
Bunny-10k 30.5 5187 10370
sphere (pointing inward the object) of xout needs to be cal-
Bunny-70k 11.9 35947 69451
culated. The sub-surface light transport from a surface point
Bird-54k 15.3 27002 54000
xin to xout is evaluated according to the formulae in Fig. 5.
Bird-100k 9.6 48668 97332
It depends on the vector R = xin − xout and the normal
Max Planck 14.2 25044 49999
N = (nx , ny , nz )T at xin . Although this function could be
Max Planck II 5.7 100086 199996
computed per fragment, we use a pre-computed, quantized
version, which can be quickly evaluated as a texture lookup. Table 1: This table lists the frames per second at a resolution
Considering the fact that only textures up to a dimension of of 512 × 512 and the number of vertices and triangles for
three are provided by graphic hardware, we need to reduce models we tested with our implementation.
the five input dimensions (R is 3D, N is 2D) to three.
The first dimension reduction – and so the first texture
coordinate S – is obtained by quantizing the surface normal 5. Results
bw( 1 n + 1 )c+frac( 1 n + 1 )
2 x 2 2 y 2
at xin with: w with frac(x) = x − bxc.
Table 1 shows the performance of our implementation of
The variable w represents the half resolution (in texels) of
the Translucent Shadow Map method using a resolution of
the texture in the S dimension. It is necessary to defer the
512 × 512 for the shadow map and the camera view. The
quantizing of the normal to this stage, because we want to
timings were collected on an Intel Pentium 4 Processor with
obtain mip-mapped normals from the Translucent Shadow
2.4GHz and an ATI Radeon 9700 graphics card. Note that
Map.
the object and the light source can be moved interactively
As second texture coordinate T we use the z-component and freely by the user. Complex objects can be rendered at
of R which is the difference of the depth values of xin and interactive frame rates, simpler objects in real-time. In the

c The Eurographics Association 2003.


200
Dachsbacher et al / Translucent Shadow Maps

first case the rendering speed is limited by the vertex pro- ceedings, Annual Conference Series, pages 165–174,
cessing of the GPU because we need multiple render-passes, August 1993. 2
due to the limited number of instructions and texture look-
4. Henrik Wann Jensen and Juan Buhler. A rapid hier-
ups in the fragment processing stage. For simpler objects
archical rendering technique for translucent materials.
the frame rate is bounded by the fragment processing speed.
ACM Transactions on Graphics, 21(3):576–581, July
With newer GPUs like the Radeon 9800 or GeForce FX we
2002. 1, 2
will be able to increase rendering speed by saving render
passes. The rendering quality will benefit from this aspect, 5. Henrik Wann Jensen and Per H. Christensen. Efficient
too: intermediate results need no longer be accumulated in simulation of light transport in scenes with participating
the precision limited frame buffer, thus the calculation gets media using photon maps. In Proceedings of SIG-
more accurate, due to higher internal precision of the GPUs. GRAPH 98, Computer Graphics Proceedings, Annual
With the Radeon 9700 we need 7 render passes for the local Conference Series, pages 311–320, July 1998. 1
and 7 for the global response.
6. Henrik Wann Jensen, Stephen R. Marschner, Marc
Fig. 7 shows the bunny model under different lighting Levoy, and Pat Hanrahan. A practical model for sub-
conditions. Fig. 8 and 9 show models with varying mate- surface light transport. In Proceedings of ACM SIG-
rial density. In our examples we used the material properties GRAPH 2001, Computer Graphics Proceedings, An-
given in Jensen6 . nual Conference Series, pages 511–518, August 2001.
1, 2, 5

6. Discussion and Future Work 7. Hendrik P. A. Lensch, Michael Goesele, Philippe


Bekaert, Jan Kautz, Marcus A. Magnor, Jochen Lang,
We extended the concept of shadow maps by storing the and Hans-Peter Seidel. Interactive rendering of translu-
surface normal and irradiance for every texel. The result- cent objects. In Proc. Pacific Graphics 2002, pages
ing Translucent Shadow Maps allow rendering of translucent 214–224, 2002. 2, 3, 5
objects on contemporary hardware in real-time and perfor-
mance and accuracy of our approach benefit from the newest 8. W. Reeves, D. Salesin, and R. Cooke. Rendering anti-
generation of GPUs. aliased shadows with depth maps. In Proceedings of
ACM SIGGRAPH 1987, Computer Graphics Proceed-
The low-frequency global response could be calculated ings, Annual Conference Series, pages 283–291, Au-
per vertex, as proposed by Lensch et al. 7 . On nowadays gust 1987. 1
GPUs this could be done with our method, but the results
have to be read back from the frame-buffer stalling the 9. Christophe Schlick. An inexpensive brdf model for
graphic pipeline. With future GPUs, when textures can be physically-based rendering. Computer Graphics Fo-
sampled at the vertex processing stage, this will be possible rum, 13(3):233–246, 1994. 2, 4
without performance penalty. 10. François X. Sillion. Clustering and volume scattering
A Translucent Shadow Map captures – typical for shadow for hierarchical radiosity calculations. In Fifth Euro-
maps – only the first visible surface seen by the light space graphics Workshop on Rendering, pages 105–117, June
camera. They do not contain all information necessary for 1994. 1
rendering sub-surface scattering effects for concave or hol- 11. Lance Williams. Casting curved shadows on curved
lowed objects. In the future we would like to solve this prob- surfaces. In Computer Graphics (Proceedings of SIG-
lem by using a depth peeling technique as used by Everitt et GRAPH 78), volume 12, pages 270–274, August 1978.
al.2 , which reveals all necessary depth information. 1

References
1. Philippe Blasi, Bertrand LeSaẽc, and Christophe
Schlick. An importance driven monte-carlo solution to
the global illumination problem. In Fifth Eurographics
Workshop on Rendering, pages 173–183, June 1994. 1
2. Cass Everitt. Order-independent transparency.
http://developer.nvidia.com/view.asp?IO=order_
independent_transparency, 2001. 5
3. Pat Hanrahan and Wolfgang Krueger. Reflection from
layered surfaces due to subsurface scattering. In Pro-
ceedings of SIGGRAPH 93, Computer Graphics Pro-

c The Eurographics Association 2003.


201
Dachsbacher et al / Translucent Shadow Maps

Figure 6: The sub-surface scattering is evaluated in two steps: the local response and the global response (displayed brightened
in the lower left image).

Figure 7: The bunny model rendered with sub-surface scattering illuminated by a rotating parallel light source.

Figure 8: This model is illuminated by parallel light from the left. From left to right the material density increases.

Figure 9: The Max Planck model is back-lit with varying material density.

c The Eurographics Association 2003.


311

You might also like