E. Heitz & E. d’Eon / Importance Sampling Microfacet-Based BSDFs using the Distribution of Visible Normals
5.4. Sampling D
ω
i
(ω
m
)
In Algorithm
4, we sample (x
˜m
,y
˜m
) with PDF
P
22
S
α
x
,α
y
(ω
i
)
(x
˜m
,y
˜m
,1,1) by sampling x
˜m
with marginal-
ized PDF P
2−
ω
i
(x
˜m
,1,1) and y
˜m
with conditional
PDF P
2|2
(y
˜m
|x
˜m
,1,1). Then, we transform this
slope vector back to the canonical frame where
ω
i
= (cosφ
i
sinθ
i
,sinφ
i
sinθ
i
,cosθ
i
) by applying a ro-
tation of angle φ
i
and we unstretch the slopes by multiplying
by respectively α
x
and α
y
. The sampled PDF at this point is
P
22
ω
i
(x
˜m
,y
˜m
,α
x
,α
y
). Finally, we transform the slopes into a
normal. The sampled PDF is D
ω
i
(ω
m
,α
x
,α
y
).
Algorithm 4 Sample D
ω
i
(ω
m
) (Smith profile)
ω
′
i
← S
α
x
,α
y
(ω
i
) ⊲ 1. stretch
x
˜m
←C
2−
ω
′
i
−1
(U
1
,1,1) ⊲ 2.a. sample P
2−
ω
′
i
(x
˜m
,1, 1)
y
˜m
←C
2|2
−1
(U
2
|x
˜m
,1,1) ⊲ 2.b. sample P
2|2
(y
˜m
|x
˜m
,1, 1)
x
˜m
y
˜m
←
cosφ
′
i
−sinφ
′
i
sinφ
′
i
cosφ
′
i
x
˜m
y
˜m
⊲ 3. rotate
x
˜m
y
˜m
←
α
x
x
˜m
α
y
y
˜m
⊲ 4. unstretch
ω
m
←
(−x
˜m
,−y
˜m
,1)
√
x
2
˜m
+y
2
˜m
+1
⊲ 5. compute normal
Figure 8: Illustration of Algorithm 4.
Analytic Computation of C
2−
ω
i
−1
and C
2|2
−1
The corner-
stone of Algorithm
4 is the inversion of the CDFs C
2−
ω
i
and
C
2|2
. We found this to be possible analytically for Beckmann
and GGX distributions, for which we provide the detailed
derivations of the inversion procedures and their C++ imple-
mentations in the associated supplemental material.
Precomputation of C
2−
ω
i
−1
and C
2|2
−1
If an analytic in-
version procedure of the CDFs C
2−
ω
i
and C
2|2
is not avail-
able, we propose to use precomputed data T
x
˜m
[θ
i
,U
1
] and
T
y
˜m
[x
˜m
,U
2
] parametrized in slope space. One advantage of
the slope space is that the equation of P
22
ω
i
becomes sepa-
rable: χ
+
(x
i
x
˜m
+ z
i
)(x
i
x
˜m
+ z
i
) does not depend on y
i
and
thus can be pulled out one of the two integrals. This prop-
erty is used in Equations (
10) and (12) and makes the pre-
computations easier than they would have been with spheri-
cal coordinates. The problem of using spherical coordinates
was discussed by Becker and Max [BM93]: they store ta-
bles parametrized in (θ,φ) and they either assume that θ and
φ can be sampled independently, which is approximate and
leads to biased sampling, or they need to store a 3D table
to sample θ for a given φ (or the reciprocal). This would
require an enormous 3D table and would be impractical
(>1GB). However, in slope space, Equation (12) shows that
P
2|2
ω
i
(y
˜m
|x
˜m
,1,1) = P
2|2
(y
˜m
|x
˜m
,1,1) and the inversion does
not depend on θ
i
, which allows us to use a 2D precomputed
table indexed by x
˜m
and U
2
. Thus, we need to precompute
only two 2D tables T
x
˜m
[θ
i
,U
1
] and T
y
˜m
[x
˜m
,U
2
]. More im-
portantly, thanks to the invariance property in slope space,
we can use the same data with different roughnesses and
anisotropy. In our implementation, T
x
˜m
and T
y
˜m
are both of
size 1024
2
. Popular heavy-tailed distributions of slopes like
GGX have very long tails but also a very sharp peak at the
same time, and so require a 1024
2
table to capture them well.
The total memory footprint for every parametric anisotropic
BSDF with the same shape is then 32MB.
Limitation Note that this technique works only when the
distribution of normals D is built from a shape-invariant dis-
tribution of slopes P
22
. For instance, this is the case for
the Beckmann [
Smi67] and GGX [WMLT07], but not for
the Phong distribution (which lacks a Smith masking func-
tion [
WMLT07]).
6. Results and Validation
In Figure 1 we show a dielectric glass plate with anisotropic
GGX roughness (Smith masking) on all faces. The illumi-
nant is constant uniform distant white radiance from all di-
rections (a white environment map). In all renders we use
forward path tracing with unbounded path lengths. Multi-
ple importance sampling (MIS) mixes BSDF and next-event-
estimation (light sampling) at each path vertex. Figure 1 uses
64 independent samples per pixel. Our new BSDF sampling
scheme runs in roughly the same time as prior work and pro-
vides a significant reduction in variance. Figure
9 shows a
configuration where fireflies are still present with the previ-
ous method even with 4000 samples per pixel. Due to the de-
fault Gaussian filter in Mitsuba, a single bright sample may
contribute significantly to several pixels (appearing as a 2x2
bright pixel block).
Figure 10 compares the convergence of importance sam-
pling with the previous method to our method in a config-
uration shown in Figure 2, i.e. a rough conductor lit by an
environment map. The plot shows that both methods con-
verge to the same value, which was expected because the
previous method and our method are both mathematically
well-defined. However, the convergence rate is not the same.
In the two first rows we used the Smith model. We see
that the convergence rate is very sensitive to the fact that
the sampling weight can be arbitrary high with the previous
method. This produces firefly artifacts that take a long time
c
2014 The Author(s)
Computer Graphics Forum
c
2014 The Eurographics Association and John Wiley & Sons Ltd.