This article is intended to be a compendium of Jacobian determinants of various
mappings commonly used in computer graphics. I intend to keep updating this
article with new mappings in the future.
This is also a follow-up to the Jacobian matrix post, so
if you need a primer on what these are and why you should care, read that first
(or Wikipedia, or PBRT).
Notation
Mapping function: T:Ξ→Ω, ω=T(ξ)
We assume that T is a bijection.
The inverse is T−1:Ω→Ξ, ξ=T−1(ω)
Volume of domain: vol(Ω)=∫Ωdω, such that vol([0,2]2)=4
Jacobian determinant: ∣JT∣ if constant, ∣JT(ξ)∣ if not constant.
Useful properties of Jacobian determinants
Jacobian determinants can be used to compute the probability density function
(PDF) of a mapping T(ξ), where ξ is a uniform random sample in [0,1]N:
p(ξ)=∣JT(ξ)∣1
For multiple importance sampling (MIS), you need to evaluate the probability of a given direction ω as if it was
sampled using a given mapping. Therefore, you need a function like:
p(ω)=∣JT(T−1(ω))∣1
Jacobian determinants have a useful property for this:
∣JT(ξ)∣=∣JT−1(T(ξ))∣−1
Because ∣JT−1(ω)∣ is often simpler than ∣JT(ξ)∣,
it is often convenient to express the PDF in terms of ∣JT−1∣:
p(ω)=∣JT(T−1(ω))∣1=∣JT−1(ω)∣
As such, I've also listed the Jacobian determinants of the inverse mappings in
this article as well.
Jacobian determinants can also be chained. If you have two mappings, T and U,
then the Jacobian determinant of T(U(ξ)) is:
∣JT∘U(ξ)∣=∣JT(U(ξ))∣⋅∣JU(ξ)∣
Common domains and their volumes
Unit hypercube / primary sample space: Ω=[0,1]N, vol(Ω)=1
Unit circle: vol(Ω)=2π
Unit disk: vol(Ω)=π
Unit sphere / 3D unit vector: vol(Ω)=4π
Unit hemisphere / 3D unit vector with one axis always positive: vol(Ω)=2π
Unit ball: vol(Ω)=34π
For all bijective mappings, we know that:
vol(Ω)=∫Ξ∣JT(ξ)∣dξ
This is useful as a quick check for validating that the Jacobian
determinant is correctly derived.
∣JT∣ Catalogue
Any equal-area projection
For equal-area projections specifically, the Jacobian determinant is constant:
∣JT∣=vol(Ξ)vol(Ω)
You can look up the volumes for the domains of your equal-area projection from
the previous section and plug them into the above equation.
Here, Ξ is the unit square and Ω is the unit sphere. It goes
something like below, but there's lots of options depending on which axis you
choose for the north-south direction and where you want ξ1 and ξ2 to map:
Here, Ξ is the unit square and Ω is the unit sphere. This
non-equal-area octahedral projection [2] is widely used in light probes, e.g.
in DDGI [3]. It is also used for encoding normal vectors into two numbers
[4].
Note that the surface area of the triangle is S=2∣(A−B)×(A−C)∣
and its normal vector is n=∣(A−B)×(A−C)∣(A−B)×(A−C).
Therefore, we can also express ∣JT(ξ)∣ as:
∣JT(ξ)∣=S⋅∣Q(ξ)∣3∣n⋅Q(ξ)∣
The inverse is a bit more awkward, as it involves ray casting. Remember that ω=T(ξ), so:
Q=ω⋅∣Q∣
where ∣Q∣ is the "hit distance" that can be recovered by tracing a ray along ω.
Once you have that determined, the rest is easy:
∣JT−1(ω)∣=S∣n⋅(ω⋅∣Q∣)∣∣Q∣3=S∣n⋅ω∣∣Q∣2
Surface point to unit vector
Here, Ξ is the surface, ξ is a point on that surface and
Ω is the solid angle subtended by that surface. This is a generalization
of the above point-on-triangle case:
∣JT(ξ)∣=∣ξ∣3∣n⋅ξ∣
Note that the S in the point-on-triangle case is actually the Jacobian
determinant of Q(ξ), as it is an equal-area mapping: ∣JQ∣=vol([0,1]2)S=S.
We do not include it here because we
already start from a point on the surface (instead of starting from the unit
square).
The inverse is also similar to the triangle case and requires recovering ∣ξ∣
by ray tracing.
∣JT−1(ω)∣=∣n⋅ω∣∣ξ∣2
This mapping and its inverse also appear in ReSTIR GI [7], where they are
chained together so that we can compute the Jacobian determinant for when
ξ is being spatially offset (= viewed from different origins).
Didn't find what you were looking for?
Alright, here's the "teach a man to fish" section. You can usually find
Jacobian determinants quite easily with the help of Sympy:
from sympy import *r, u, v = symbols('r u v', real=True)T = [ r * cos(2*pi*u) * sin(pi*v), r * cos(pi*v), r * sin(2*pi*u) * sin(pi*v)]J = Matrix(T).jacobian((r,u,v))JT = simplify(J.det())print(JT)
You may have to apply some elbow grease to rewrite the Jacobian into a
form that is intuitive or more efficient to evaluate.