Hansson Soderlund2022SDF
Hansson Soderlund2022SDF
org
Figure 1. A path traced image of two orange signed distance function models mixed with
triangle geometry.
Abstract
We evaluate the performance of a wide set of combinations of traversal and voxel intersection
testing of signed distance function grids in a path tracing setting. In addition, we present an
optimized way to compute the intersection between a ray and the surface defined by trilinear
interpolation of signed distances at the eight corners of a voxel. We also provide a novel way
to compute continuous normals across voxels and an optimization for shadow rays. On an
NVIDIA RTX 3090, the fastest method uses the GPU’s ray tracing hardware to trace against
a bounding volume hierarchy, built around all non-empty voxels, and then applies either an
analytic cubic solver or a repeated linear interpolation for voxel intersection.
1. Introduction
Rendering signed distance functions (SDFs) is becoming more and more popular due
to their simplicity and expressiveness with a small amount of data. Impressive three-
dimensional scenes can be defined using only code, where SDFs are used with oper-
ators, such as union, intersection, smooth subtraction, and smooth union [Bloomen-
thal et al. 1997], and are often demonstrated on websites, such as ShaderToy. Entire
94 ISSN 2331-7418
Journal of Computer Graphics Techniques Vol. 11, No. 3, 2022
Path Tracing of Signed Distance Function Grids http://jcgt.org
games, such as Dreams [Evans 2015] and Claybook [Aaltonen 2018], use SDFs ex-
tensively. In those cases, the SDF primitives and operators are sampled onto a three-
dimensional grid, where each corner of a grid cell holds a signed distance. We call
these SDF grids. The bounding box of such a grid can be rasterized and the con-
tent sphere traced [Hart 1995] to reveal its containing geometry. Sphere tracing has
a weakness in that it takes smaller and smaller steps the closer the iteration gets to
the actual surface. This reduces performance just before a ray hits a surface, when a
ray is close to a silhouette, and when secondary rays are to be shot from a hit point
on an SDF surface, when using path tracing, for example. One may use acceleration
techniques for sphere tracing [Keinert et al. 2014; Bálint and Valasek 2018], but those
often only pay off when the number of iterations is large. Segment tracing [Galin et al.
2020] can provide generous speedups, but this method has not yet been extended to
SDF grids.
We present a method to analytically ray trace the surface inside each voxel in
an SDF grid. The surface inside a voxel is a third-order polynomial as was derived
by Parker et al. [1998]. Our method uses substantially fewer operations than theirs.
In addition, Parker et al. did not provide continuous normals between voxels, which
gives poor visual quality when the viewer is close to the voxels. We present a remedy
to this.
Before we describe our work, we want to emphasize the surprising (at least to us)
expressive power of possible surfaces of the third-order polynomial inside a voxel.
When triangulating SDF grids, one may use the marching cubes algorithm [Lorensen
and Cline 1987], which states that 14 topological situations (excluding empty) can
occur in a voxel. However, when using trilinear interpolation of the signed distances
inside a voxel, the surface becomes a third-order polynomial, which has a much wider
set of topologies. Lopes and Brodlie [2003] showed that there are 31 different topolo-
gies. We show a few in Figure 2.
95
Journal of Computer Graphics Techniques Vol. 11, No. 3, 2022
Path Tracing of Signed Distance Function Grids http://jcgt.org
Figure 2. Each image shows the surface inside a single voxel, which has a signed distance
at each of the 2 × 2 × 2 corners of the voxel. In the upper left image, all signed distances
are positive, except for two opposing corners of the bottom quadrilateral. This case is part
of the marching cubes algorithm. However, the second image on the top row has the same
configuration, except the numbers are a bit different. In this case, a single surface is shown
inside the voxel. Marching cubes does not generate geometry correctly for this case. The rest
of the images show various cases that marching cubes does not handle correctly.
s011
s001 z
s101 s111
y
s010
s000
x
s110
s100
Figure 3. A voxel with signed distances sijk at the 2 × 2 × 2 corners. A possible surface is
shown in blue.
f (x, y, z) =
(1 − z) (1 − y) (1 − x)s000 + xs100 + y (1 − x)s010 + xs110 (1)
+ z (1 − y) (1 − x)s001 + xs101 + y (1 − x)s011 + xs111 ,
where x, y, z ∈ [0, 1]. This equation is evaluated at each step in algorithms based on
sphere tracing [Hart 1995].
96
Journal of Computer Graphics Techniques Vol. 11, No. 3, 2022
Path Tracing of Signed Distance Function Grids http://jcgt.org
The surface inside a voxel is defined by f (x, y, z) = 0 (Equation (1)), which can
be rewritten as
which is a polynomial of degree three because the highest-order term is xyz. The
constants ki are functions of the sijk distances:
k0 = s000 , k4 = k0 − s001 ,
k1 = s100 − s000 , k5 = k1 − a,
k2 = s010 − s000 , k6 = k2 − (s011 − s001 ), (3)
k3 = s110 − s010 − k1 , k7 = k3 − s111 − s011 − a ,
a = s101 − s001 .
A ray is defined by r(t) = o + td, where o = (ox , oy , oz ) and similar for d. The
intersection between the surface and the ray is found by replacing x, y, and z with the
ray components, e.g., replacing x with rx (t) = ox + tdx , in Equation (2). This results
in
(oz + tdz ) k4 + k5 (ox + tdx ) + k6 (oy + tdy ) + k7 (ox + tdx )(oy + tdy )
(4)
− k0 + k1 (ox + tdx ) + k2 (oy + tdy ) + k3 (ox + tdx )(oy + tdy ) = 0,
c3 t3 + c2 t2 + c1 t + c0 = 0, (5)
where
c0 = (k4 oz − k0 ) + ox m3 + oy m4 + m0 m5 ,
c1 = dx m3 + dy m4 + m2 m5 + dz (k4 + k5 ox + k6 oy + k7 m0 ),
(6)
c2 = m1 m5 + dz k5 dx + k6 dy + k7 m2 ,
c3 = k7 m1 dz ,
and
m0 = ox oy , m3 = k5 oz − k1 ,
m1 = dx dy , m4 = k6 oz − k2 , (7)
m2 = ox dy + oy dx , m5 = k7 oz − k3 .
The method presented by Parker et al. [1998] for computing the ci in Equation (5)
is rather brute-force, though mathematically elegant, in their presentation. Their
method uses about 161 operations, where fused-multiply-and-adds were counted as
97
Journal of Computer Graphics Techniques Vol. 11, No. 3, 2022
Path Tracing of Signed Distance Function Grids http://jcgt.org
one operation. By sharing repeated calculations (the ki and mi ) where possible, our
method uses only 37 operations, again counting each FMA as one operation.
To intersect a ray with the surface inside a voxel, we first compute the intersection
between the ray and the box. This intersection point is used as the new origin of the
ray, unless the ray origin is inside the box. The origin of the ray is then transformed
to the canonical voxel space, which is [0, 1]3 , as we have derived our surface function
in that space. The distance from this point to the exit point of the ray on the box is
denoted tfar .
Next, we compute the intersection distance, t, by using Equation (5) with the
constants in Equations (3), (6), and (7). Note that we are only interested in the first
real root inside the box, i.e., with t ∈ [0, tfar ]. There are several viable approaches to
solving that third-order polynomial. First, one may use an analytic cubic polynomial
solver based on Vieta’s approach [Press et al. 2007], or any other analytic method for
solving cubic polynomials.
Second, one may use a numerical approach instead of an analytic solver for the
third-order polynomial. As a first step, we use the approach by Marmitt et al. [2004].
Let us denote our cubic polynomial by g(t) = c3 t3 + c2 t2 + c1 t + c0 . Marmitt et
al. differentiate this equation and solve for equality to zero, which gives us g ′ (t) =
3c3 t2 + 2c2 t + c1 = 0. This can be solved analytically by splitting the interval
[0, tfar ] into subintervals wherever g ′ (t) = 0. The subintervals are processed in order,
from t = 0 toward t = tfar . As soon as we find a subinterval [tstart , tend ], where
g(tstart )g(tend ) ≤ 0, i.e., g(tstart ) and g(tend ) have different signs, we know that
there will be a root of g(t) in [tstart , tend ]. This is illustrated in Figure 4.
We also found that this type of computation can be used to optimize shadow ray
testing. For opaque geometry, shadow ray testing can be terminated as soon as a hit
is found in [0, tlight ]. This means that we can exploit the previous step, i.e., if we find
that there is a root in [tstart , tend ] and this interval fully overlaps with [0, tlight ], then
we can report a hit without numeric iteration. This is evaluated in Section 4.
If we detect that there is a root in [tstart , tend ], using the method in Figure 4, one
alternative is to use a numerical solver to find the root in that subinterval. Marmitt
et al. applied repeated linear interpolation to find the root. Another alternative is to
first refine the current t into t = (g(tend )tstart − g(tstart )tend )/(g(tend ) − g(tstart )),
which provides a refined initial guess of the root. Next, we use the Newton–Raphson
method [Press et al. 2007] to find the root. This is shown in Listing 1. We evaluate
the analytic solution, the method of Martmitt et al., and the Newton–Raphson method
in Section 4.
If desired, one can add an additional test, which makes the voxel surface solid,
as shown in Figure 2, before using the cubic solver. When the ray origin is located
on a face of the voxel’s box, we evaluate Equation (2) once at the ray origin. If
f (ox , oy , oz ) < 0, then the ray is deemed to have hit a side of the voxel, and we return
98
Journal of Computer Graphics Techniques Vol. 11, No. 3, 2022
Path Tracing of Signed Distance Function Grids http://jcgt.org
g(t) tfar
tfar
t
tfar
Figure 4. Illustration of how the solutions to g ′ (t) = 0 help with numeric root finding. The
roots to g ′ (t) = 0 are marked with vertical dashed lines, which split the t-axis into three
intervals. Since the curve is above the t-axis in the first two intervals (yellow and green),
there cannot be any real roots there. For the last interval, the curve is above the t-axis at the
beginning of the interval and below at tfar . Using linear interpolation, we then compute the
t-value at the non-filled circle and use that as a starting point for Newton–Raphson iteration
(NR). The top right example shows how there are three roots in [0, tfar ], but NR will start in
the first interval due to opposite signs of g(t) at the start and end of the first (yellow) interval.
The bottom right example shows that there are no roots, and so no iteration is needed.
a hit there immediately. An advantage of adding this test is that rays which “sneak”
between the surfaces of two neighboring voxels due to floating-point imprecision are
likely to immediately hit such a box face, which avoids visible cracks.
3. Normals
For any continuous surface defined by a differentiable implicit function f , a vec-
tor n, which is normal to the surface, can be computed from the gradient of f , i.e.,
n = ( ∂f ∂f ∂f
∂x , ∂y , ∂z ). Common numerical methods for computing n include central
differencing [Frisken et al. 2000], forward and backward differencing, or the tetra-
99
Journal of Computer Graphics Techniques Vol. 11, No. 3, 2022
Path Tracing of Signed Distance Function Grids http://jcgt.org
hedral method, using only four function evaluations, by Falcão [2008]. All of these
numerical methods are based on some epsilon value to determine offset points.
We compute normals using the analytic derivative of f , as described in Sec-
tion 3.1. Because f is a cubic polynomial, the normal will be C 2 continuous inside
each voxel. However, over an SDF grid, the normals will not be continuous, since two
neighboring voxels’ surfaces are only C 0 continuous where they meet. To remedy
this, we present a method (Section 3.2) that interpolates normals from neighboring
voxels’ surfaces, which is similar in spirit to how normals are computed for PN tri-
angles [Vlachos et al. 2001]. To clarify, our approach computes continuous normals
that appear to be reasonable, but they do not correspond to the normals of the surface,
similar to the method by Vlachos et al.
∂f (x,y,z)
∂x = (1 − y) (1 − z) (s100 − s000 )
+ y (1 − z) (s110 − s010 )
(8)
+ (1 − y) z (s101 − s001 )
+ y z (s111 − s011 ).
and
x0 = lerp(x, s001 − s000 , s101 − s100 ),
x1 = lerp(x, s011 − s010 , s111 − s110 ), (11)
∂f (x,y,z)
∂z = lerp(y, x0 , x1 ).
100
Journal of Computer Graphics Techniques Vol. 11, No. 3, 2022
Path Tracing of Signed Distance Function Grids http://jcgt.org
voxel
dual voxel
hitpoint
Figure 5. Left: A 2 × 2 voxel grid and its corresponding dual voxel in the middle. Each
voxel has its own surface, and normals can be evaluated outside its voxel. For a hit point,
we compute the normals for each of the four voxels at the same hit point and then weight
these based on the position of the hit point inside the voxel. Right: To avoid cluttering the
illustration, we only show two voxels here. The illustration shows a green (respectively, red)
surface defined by the signed distance values at the corners of the left (respectively, right)
voxel. Normals, shown in red and green, can be computed at the hit point based on the implicit
function defined in both voxels. These normals are then weighted based on the position of the
hit point inside the dual voxel. In this simple illustration, only the x-component of the hit
point would be used for weighting. Because the hit point is closer to the right border of the
dual voxel than the left border, the red normal will get a larger weight than the green normal.
Our method uses about 30 operations for the normal (without normalization),
while the method of Parker et al. uses 54 operations.
n= (1 − u) (1 − v) (1 − w) n000 + u (1 − v) (1 − w) n100
+ (1 − u) v (1 − w) n010 + u v (1 − w) n110
(12)
+ (1 − u) (1 − v) w n001 + u (1 − v) w n101
+ (1 − u) v w n011 + u v w n111 ,
101
Journal of Computer Graphics Techniques Vol. 11, No. 3, 2022
Path Tracing of Signed Distance Function Grids http://jcgt.org
with the subscript indices indicating from which voxel a normal is computed. We
chose to write the expression in the clearest form in Equation (12), but in reality,
it is better to evaluate it using a form similar to that of Equation (1). Our method
differs from standard trilinear interpolation in that we do not compute normals at the
corners of the dual voxel, but instead compute the (normalized) analytic normals,
using Equations (9)–(11), evaluated at the hit point. This is illustrated to the right in
Figure 5. Note that this means that normals are computed outside the usual domain
of a voxel in seven out of the eight cases, and only inside for the voxel where the
hit point is located. As can be seen to the right in Figure 5, the green normal is not
computed on the green surface, but rather at the hit point on the red surface.
The resulting interpolated normals are smoothly varying across the whole field;
however, they do not correspond exactly to the original normals of the intersected
surface, which are discontinuous at voxel boundaries. In other words, we trade a
small deviation from the geometric normal to the surface for smoothness across voxel
boundaries.
4. Results
All tests were run on an Intel Core i9 10980XE clocked at 3.00 GHz with 128 GB
of DDR4 system memory clocked at 2.4 GHz. The graphics card was an NVIDIA
RTX 3090 with 24 GB of memory using driver version 471.68. Our implementation
was done inside an in-house path tracer running in Falcor [Kallweit et al. 2021].
We have used four test scenes called Cheese, Goblin, Heads, and Ladies, which
can be seen in Figure 6. All rendering was done with full path tracing using up
to three bounces and with a single square light source. Performance was evaluated
using different camera paths for our four scenes, with 900 frames per scene. After
30 seconds of warm-up rendering on the GPU, we ran the camera path five times and
computed the average frame time.
4.1. Algorithms
To provide a comprehensive study of the performance of path tracing of SDF grids,
we have divided the algorithm into a grid traversal part and a voxel intersection part.
4.1.1. Grid Traversal
102
Journal of Computer Graphics Techniques Vol. 11, No. 3, 2022
Path Tracing of Signed Distance Function Grids http://jcgt.org
Cheese
Goblin
Heads
Ladies
Figure 6. Three frames from each of our test scenes at different viewpoints from our camera
paths.
Grid sphere tracing GST is sphere tracing through a dense grid of SDF values. The
grid that GST uses stores all voxels for a given resolution, this includes those voxels
that do not contain the SDF surface. Values are formatted and clamped to [−1, 1]
such that a value of 1 encodes 2.5 interior voxel diagonals. This allows the SDF
values to be stored as 8-bit snorm integers. To accelerate traversal of empty regions
of space, a hierarchy of SDF grids is utilized. Lower-resolution levels of the hierarchy
encode larger SDF values. An algorithm adaptively selects a grid resolution to safely
maximize the step size taken by the sphere tracing traversal. The traversal is done
entirely in shader code. A similar technique is used in Claybook [Aaltonen 2018].
Sparse voxel set SVS creates an axis-aligned bounding box (AABB) for each voxel
that intersects part of the surface and builds a bounding volume hierarchy (BVH) for
use in DirectX Raytracing (DXR). Hence, BVH traversal is done using the GPU’s
RTX ray tracing hardware. When a voxel is reached, a custom intersection shader is
invoked and any of the following methods can be used. Instead of storing 2 × 2 × 2
signed distance values per voxel, SVS stores 4 × 4 × 4 signed distance values around
a voxel. This allows easy access of neighboring voxel values, which is necessary for
some of the normal evaluation methods that follow.
103
Journal of Computer Graphics Techniques Vol. 11, No. 3, 2022
Path Tracing of Signed Distance Function Grids http://jcgt.org
Sparse brick set SBS is similar to SVS, except that each AABB stores the data of
7×7×7 voxels (8×8×8 values), called bricks. When the custom intersection shader
is invoked, a 3D digital differential analyzer (DDA) is used to visit the relevant voxels
in order. SBS stores the distance values of each 83 brick as slices in a 2D texture and
provides a lookup buffer to access the bricks. This allows eight voxel corner values
to be fetched using only two HLSL gather operations. This traversal method is
most similar to that used by Dreams [Evans 2015] and OpenVDB [Museth 2013;
Museth 2021]; OpenVDB uses a forest of trees to store leaf bricks with data for
8 × 8 × 8 voxels. OpenVDB does not directly make use of GPU gather operations
and therefore does not need to duplicate the voxel data at brick borders.
Sparse voxel octree SVO is a sparse voxel octree [Crassin et al. 2009] with im-
plementation details following the work by Laine and Karras [2010]. All traversal
occurs in shader code for SVO. In general, we store SDF values as 8-bit snorm in-
tegers. SDF values are formatted such that a value of 1 encodes 0.5 interior voxel
diagonals. After formatting, the SDF values are clamped to [−1, 1], allowing them
to be stored as snorm integers. The size of a voxel varies at different levels of the
octree, which allows lower-resolution levels to encode larger distances at the expense
of precision.
4.1.2. Voxel Intersection
3. analytic (A),
5. Newton–Raphson (NR).
Grid sphere tracing GST for voxel intersection is only combined with GST for grid
traversal, meaning that the same algorithm is used until an intersection is found.
Sphere tracing ST performs classical sphere tracing only inside the voxel and can
be combined with other traversal methods. To prevent extremely long runs, GST and
ST stops after 512 and 128 iterations,1 respectively, or when there is a crossing from
outside to inside the surface.
1
We use a larger value for GST because it uses sphere tracing for both traversal and voxel intersec-
tion, while ST only uses it for voxel intersection. Note that these numbers are mostly there to prevent
extremely long runs, but we seldom see this happening.
104
Journal of Computer Graphics Techniques Vol. 11, No. 3, 2022
Path Tracing of Signed Distance Function Grids http://jcgt.org
Cheese Goblin
GST ST A M NR GST ST A M NR
GST 15.4 22.6 14.6 15.7 15.7 GST 16.6 22.2 16.0 16.9 17.0
SVS – 16.6 9.7 9.9 10.4 SVS – 14.9 9.7 9.8 11.2
SBS – 30.3 17.8 19.1 18.6 SBS – 25.5 17.3 18.1 18.0
SVO – 28.4 16.7 17.3 17.3 SVO – 24.3 16.3 16.6 16.6
Heads Ladies
GST ST A M NR GST ST A M NR
GST 50.8 63.9 47.9 50.8 50.8 GST 79.7 93.2 82.9 86.3 86.3
SVS – 27.2 17.3 17.1 18.0 SVS – 23.6 16.1 16.2 17.3
SBS – 53.8 32.8 34.8 33.9 SBS – 44.6 30.9 32.3 31.3
SVO – 59.4 40.7 41.4 41.6 SVO – 66.1 54.8 54.8 55.3
Table 1. Main performance results, in milliseconds, for our four scenes called Cheese, Goblin,
Heads, and Ladies. The traversal method (GST/SVS/SBS/SVO) is identified by the row and
the voxel intersection method (GST/ST/A/M/NR)) by the column. The fastest two methods
per scene are marked with bold numbers.
Analytic We solve the cubic polynomial using an analytic cubic root solver, as men-
tioned in Section 2.
Marmitt et al. and Newton–Raphson M first uses the method proposed by Marmitt
et al. [2004] to split the polynomial as shown in Figure 4, and then uses repeated
linear interpolation for iteration. NR also uses the polynomial split, but then replaces
repeated linear interpolation with Newton–Raphson iteration. Both M and NR have
a maximum number of iterations that can be performed and also stops iteration if
the difference between two subsequent t-values is less than a chosen epsilon. We
empirically picked a maximum number of iterations of 50 and an epsilon value of
ϵ = 4.0 · 10−3 , where a larger maximum number of iterations or smaller epsilon value
never visually improved the images we rendered.
With this, we denote a combination of a traversal algorithm and a voxel inter-
section test method by the concatenation of the abbreviations, i.e., SBS-NR is sparse
brick set with Newton–Raphson. We use classical instancing in the scenes (Heads
and Ladies) with replicated objects: e.g., for each instance, we inverse-transform the
ray and then traverse a shared object.
4.2. Performance
The main performance results using path tracing are shown in Table 1. It is clear that
the fastest traversal method is SVS, combined with either the analytic voxel intersec-
tion test (A) or the numerical method by Marmitt et al. (M). Among the rest of the
algorithms, it is less clear. For the simpler scenes (Cheese and Goblin), GST is the
next fastest, closely followed by SBS and SVO. For the more complex scenes (Heads
and Ladies), SBS is generally faster than SVO, and GST is the slowest. This is likely
105
Journal of Computer Graphics Techniques Vol. 11, No. 3, 2022
Path Tracing of Signed Distance Function Grids http://jcgt.org
Table 2. Memory usage for different grid traversal algorithms, numbers are in megabytes.
The memory usage includes both internal data buffers that are used to intersect against the
SDF surface as well as the acceleration structure size.
due to more indirect rays hitting the SDF surface in complex scenes. SBS and SVO
are better at handling this random access as they store data more compactly. Further-
more, SBS creates tighter bounding boxes around the SDF surface, which allows for
better utilization of hardware-accelerated ray tracing. However, for simpler scenes
where most rays access similar data, GST seems to traverse the grid faster than SBS
and SVO.
For voxel intersection testing, the analytic test (A) is the fastest method, but with
M having similar numbers for SVS. It was surprising to us that M is often faster than
Newton–Raphson (NR), as NR has faster convergence rates. It may be due to NR
taking longer to converge in harder cases where the starting point is on the cubic
curve and the magnitude of the derivative is relatively small.
We speculated that SBS might be faster than SVS due to better use of locality
because a block of 7 × 7 × 7 voxels is read at a time, but we cannot see any such
evidence. This may change if the data is compressed with BC4 texture compression.
However, since values at the edges are replicated to avoid reading neighboring blocks,
the lossy nature of BC4 will cause edge values to be different, which can give rise to
cracks in the SDF surface. This may be reasonable when the camera is far away, but
less acceptable when the camera is closer. We leave a thorough evaluation of texture
compression for future work.
Memory usage for the different grid traversal algorithms can be seen in Table 2.
The memory usage of GST is constant as it does not depend on the sparsity of surface
voxels. SVS needs to store a large amount of data per voxel, but only stores voxels
that intersect the SDF surface. Therefore, SVS uses more memory than GST for the
Cheese SDF as it causes more voxels to intersect the surface than the other SDFs do.
If we reduced the storage per voxel from 4 × 4 × 4 SDF values to 2 × 2 × 2 SDF
values, the numbers for SVS would approximately be reduced by 50%. That would,
however, make our new normal interpolation method substantially slower. SBS and
SVO use the least amount of memory across all scenes due to both of them being
good at exploiting sparsity, while also storing less data per voxel compared to SVS.
In a memory-constraint scenario, SBS is likely the winning method because it uses
the least memory and is faster than SVO.
106
Journal of Computer Graphics Techniques Vol. 11, No. 3, 2022
Path Tracing of Signed Distance Function Grids http://jcgt.org
Table 3. Performance of different normal methods measured as a percent change in the overall
frame time, where negative numbers indicate a reduction in total frame time to the baseline,
while positive numbers indicate an increase. The baseline is the discontinuous version of the
method by Falcão.
4.3. Normals
Our comparison method for the normal computations is a difference-based method
that uses four evaluations of the signed distance function [Falcão 2008] and is the least
expensive method that we have found. It is possible to create normals that achieve C 0
continuity of the normal field over voxel edges by sampling neighboring voxels with
this method combined with GST. We call this method Falcão normals. However,
using other traversal methods, it is not always possible to sample neighboring voxels
as they may not exist. Therefore, a version of the method by Falcão [2008] that
is not C 0 across voxel edges is used for those traversal methods. This method is
denoted baseline. It extends the surface of the current voxel outside its box to allow
the signed distance to be sampled for neighbors that might not exist. We compare
to analytic normals (Section 3.1), which are also not C 0 across voxels, and to our
proposed method (Section 3.2), which delivers continuous normals. For the baseline
and Falcão methods, we empirically picked an epsilon of 20% of the voxel size as it
resulted in the best visual appearance. The other methods do not require any tweaking
of epsilon values. To summarize, the four normal computation methods we evaluate
are the following:
1. baseline,
To reduce the sheer amount of data, we present statistics only for GST-A, SVS-A,
and SBS-A using analytic normals and our proposed method. We also present statis-
tics on the performance of Falcão normals using GST-A. The results are presented
in Table 3, where the numbers are compared against the baseline method. Falcão
107
Journal of Computer Graphics Techniques Vol. 11, No. 3, 2022
Path Tracing of Signed Distance Function Grids http://jcgt.org
Falcão normals [2008] Analytic normals (Section 3.1) Our method (Section 3.2)
Full frame
Zoom
Full frame
Zoom
Figure 7. Image quality comparison of the three different normal methods that we evaluate.
normals perform consistently slightly worse than the baseline. This is due to it be-
ing more costly to sample additional distance values from neighboring voxels than to
use the distance values of only one voxel. Analytic normals (Section 3.1) perform
similar to the baseline, which is expected as both only use the distance values of a
single voxel. Our method, on the other hand, uses 1.1–4.2% more time per frame on
average for GST-A compared to the baseline and 1.0–7.3% more time per frame on
average for SVS-A. Without storing the 4 × 4 × 4 SDF values per voxel, the runtime
was substantially larger. Finally, our method used 3.5–5.8% more time per frame on
average for SBS-A compared to the baseline.
Even though our method used more time to compute the normals, there is also
a significant difference in image quality, as seen in Figure 7. From a distance, it is
108
Journal of Computer Graphics Techniques Vol. 11, No. 3, 2022
Path Tracing of Signed Distance Function Grids http://jcgt.org
difficult to see any large differences between the three methods. In closeups, Falcão
normals are somewhat smoother than the method of Section 3.1, which is to be ex-
pected since Falcão normals sometimes access neighboring voxel data. Our method
provides superior results for closeups as can be seen to the lower right. An alternative
would be to use the method of Section 3.1 far away from the object and switch to our
method for closeups. This could be decided by tracing ray cones [Akenine-Möller
et al. 2019] and selecting a method based on the ray cone radius at the hit point. This
is also left for future work.
109
Journal of Computer Graphics Techniques Vol. 11, No. 3, 2022
Path Tracing of Signed Distance Function Grids http://jcgt.org
Acknowledgements
Thanks to Aaron Lefohn for supporting this work, and thanks to Pontus Andersson,
Marco Salvi, and Eric Haines for providing feedback. We are grateful to Jonathan
Åleskog for modeling the “sad guy” in the teaser image.
References
A ALTONEN , S., 2018. GPU-based clay simulation and ray tracing tech in Claybook.
Presentation at Game Developers Conference, March 19–23. URL: https://ub
m-twvideo01.s3.amazonaws.com/o1/vault/gdc2018/present
ations/Aaltonen_Sebastian_GPU_Based_Clay.pdf. 95, 103
A KENINE -M ÖLLER , T., N ILSSON , J., A NDERSSON , M., BARR É -B RISEBOIS , C.,
T OTH , R., AND K ARRAS , T. 2019. Texture level of detail strategies for real-time
ray tracing. In Ray Tracing Gems, E. Haines and T. Akenine-Möller, Eds. Apress,
ch. 20, 321–345. URL: https://link.springer.com/chapter/10.1
007/978-1-4842-4427-2_20. 109
B LOOMENTHAL , J., BAJAJ , C., B LINN , J., C ANI -G ASCUEL , M.-P., ROCKWOOD ,
A., W YVILL , B., AND W YVILL , G. 1997. Introduction to Implicit Surfaces.
Morgan Kaufmann. URL: https://dl.acm.org/doi/book/10.5555/
549676. 94
C RASSIN , C., N EYRET, F., L EFEBVRE , S., AND E ISEMANN , E. 2009. GigaVoxels:
Ray-guided streaming for efficient and detailed voxel rendering. In Proceedings
on the 2009 Symposium on Interactive 3D Graphics and Games, Association for
Computing Machinery, 15–22. URL: https://maverick.inria.fr/Pu
blications/2009/CNLE09/CNLE09.pdf. 104
FALC ÃO , P., 2008. Implicit function to distance function. URL: https://www.
pouet.net/topic.php?which=5604&page=3#c233266. 100, 107,
108
110
Journal of Computer Graphics Techniques Vol. 11, No. 3, 2022
Path Tracing of Signed Distance Function Grids http://jcgt.org
G ALIN , E., G U ÉRIN , E., PARIS , A., AND P EYTAVIE , A. 2020. Segment tracing
using local Lipschitz bounds. Computer Graphics Forum 39, 2, 545–554. URL:
https://doi.org/10.1111/cgf.13951. 95
H ART, J. C. 1995. Sphere tracing: A geometric method for the antialiased ray
tracing of implicit surfaces. The Visual Computer 12, 527–545. URL: https:
//link.springer.com/article/10.1007/s003710050084. 95, 96
K ALLWEIT, S., C LARBERG , P., KOLB , C., YAO , K.-H., F OLEY, T., W U , L.,
C HEN , L., A KENINE -M ÖLLER , T., W YMAN , C., C RASSIN , C., AND B ENTY,
N., 2021. The Falcor rendering framework, August. URL: https://github
.com/NVIDIAGameWorks/Falcor. 102
K EINERT, B., S CH ÄFER , H., KORND ÖRFER , J., G ANSE , U., AND S TAMMINGER ,
M. 2014. Enhanced sphere tracing. In Smart Tools and Apps for Graphics—
Eurographics Italian Chapter Conference, The Eurographics Association, 1–8.
URL: http://dx.doi.org/10.2312/stag.20141233. 95
L AINE , S., AND K ARRAS , T. 2010. Efficient sparse voxel octrees—Analysis, exten-
sions, and implementation. NVIDIA Technical Report NVR-2010-001, NVIDIA.
URL: https://research.nvidia.com/publication/2010-02_ef
ficient-sparse-voxel-octrees-analysis-extensions-and-i
mplementation. 104
L OPES , A., AND B RODLIE , K. 2003. Improving the robustness and accuracy of the
marching cubes algorithm for isosurfacing. IEEE Transactions on Visualization
and Computer Graphics 9, 1, 16–29. URL: https://ieeexplore.ieee.
org/document/1175094. 95
M ARMITT, G., K LEER , A., WALD , I., AND F RIEDRICH , H. 2004. Fast and accurate
ray-voxel intersection techniques for iso-surface ray tracing. In Vision, Modeling,
and Visualization, AKA, vol. 4, 429–435. 98, 105
111
Journal of Computer Graphics Techniques Vol. 11, No. 3, 2022
Path Tracing of Signed Distance Function Grids http://jcgt.org
M USETH , K. 2021. NanoVDB: A GPU-friendly and portable VDB data structure for
real-time rendering and simulation. In ACM SIGGRAPH 2021 Talks, Association
for Computing Machinery, 1:1–1:2. URL: https://doi.org/10.1145/34
50623.3464653. 104
PARKER , S., S HIRLEY, P., L IVNAT, Y., H ANSEN , C., AND S LOAN , P.-P. 1998.
Interactive ray tracing for isosurface rendering. In Proceedings Visualization ’98,
IEEE, 233–238. URL: https://ieeexplore.ieee.org/document/7
45713. 95, 97
V LACHOS , A., P ETERS , J., B OYD , C., AND M ITCHELL , J. L. 2001. Curved PN
triangles. In Proceedings of the Symposium on Interactive 3D Graphics, Associa-
tion for Computing Machinery, 159–166. URL: https://doi.org/10.114
5/364338.364387. 100
Received: 2021-09-08
Recommended: 2022-02-17 Corresponding Editor: Natalya Tatarchuk
Published: 2022-09-21 Editor-in-Chief: Marc Olano
112
Journal of Computer Graphics Techniques Vol. 11, No. 3, 2022
Path Tracing of Signed Distance Function Grids http://jcgt.org
113