BSDF models implementation and references
- Introduction
- Geometric configuration
- C++ interface
- Lambert model
- 100% reflective BSDF
- 100% transmissive BSDF
- Fresnel
- Conductor
- Dielectric
- Plastic
- Microfacet model
- Rough diffuse - Oren Nayar
- Anisotropic rough diffuse, conductor and dielectric with GGX
- Rough plastic
- Multiple scattering
- Mix BSDF
- Production principled BSDF
- Subsurface scattering
- Phase functions
- References
I started writing these notes before the Crash Course in BRDF Implementation or the OpenPBR initiative were published so there is definitely some overlap and I recommend taking a look at them. The notes now cover every model listed below, from the simplest smooth models to the production principled BSDF, subsurface scattering and phase functions.
Introduction
This document covers some mathematical and implementation details for various classic bidirectional scattering distribution functions (BSDF) in a path tracer, such as:
- Diffuse models
- Lambert
- Oren-Nayar rough diffuse
- Rough diffuse isotropic / anisotropic (GGX based)
- Fresnel equations and their approximations (Schlick, Lazanyi - Schlick)
- Conductors / Tinted conductors
- Dielectrics
- Plastics (smooth coating over a diffuse base)
- Microfacet distributions
- Isotropic GGX
- Anisotropic GGX
- Rough conductors isotropic / anisotropic (GGX based)
- Rough dielectrics isotropic / anisotropic (GGX based)
- Rough plastic isotropic / anisotropic (GGX based)
- Multiple scattering energy compensation
- Mix BSDF
- Principled models: OpenPBR, Blender, glTF
- Subsurface scattering
- Phase functions for participating media
Geometric configuration
A BSDF is a function that returns the amount of light scattered from an incoming direction \(\omega_i\) to an outgoing direction \(\omega_o\) at a point \(p\). Physics-based BSDF should satisfy three main properties:
- Positivity: \(f(\omega_o, \omega_i) \geq 0\)
- Reciprocity: \(f(\omega_o, \omega_i) = f(\omega_i, \omega_o)\)
- Energy conservation: \(\int_{\Omega_i} f(\omega_o, \omega_i) \cos \theta_i \mathrm{d}\omega_i \leq 1\)
We take by convention that:
- All directions are unit vectors pointing outwards in a local orthonormal basis \((\omega_g,\omega_t,\omega_b)\) centered at the surface point \(p\) (unless otherwise stated).
- The surface normal \(\omega_g\) is always pointing outside the surface and is oriented Z-up. A light direction \(\omega_i\) in the same hemisphere as the normal is entering the object, exiting otherwise.
- For isotropic materials the local basis can be constructed using an arbitrary tangent vector \(\omega_t\) without consequences (e.g. [Duff17]), or using the following approach.
- For anisotropic materials the tangent vector \(\omega_t\) of the basis has to be continuous over the surface. A classic approach to construct a continuous tangent vector is to take the derivative of the position w.r.t the surface parameterization \((u,v)\): \(\displaystyle \omega_t = \text{normalize}\left(\frac{\partial p}{\partial u}\right) \qquad \text{or} \qquad \omega_t = \text{normalize}\left(\frac{\partial p}{\partial v}\right)\)
Additionally, the tangent vector can be rotated around the normal by an angle \(\theta\) to change the anisotropic direction: \(\displaystyle \omega_t = \text{rotate}\left(\text{normalize}\left(\frac{\partial p}{\partial u}\right), \omega_g, \theta\right)\) Several shape parameterizations and the derivatives of position and normal are derived in PBRT [Pharr16], Chapter 3: Shapes.
| Notation | Definition |
|---|---|
| \(p\) | surface point |
| \(\omega_i\) | incident direction (towards the light) |
| \(\omega_o\) | outgoing direction (towards the eye) |
| \(\omega_m\) | microfacet normal |
| \(\omega_g\) | geometric normal |
| \(\omega_t\) | tangent vector |
| \(\omega_b\) | bitangent vector |
| \((\omega_g,\omega_t,\omega_b)\) | local orthonormal basis |
| \(\eta_o\), \(\eta_i\) | refractive indices on the side of \(\omega_o\) and on the side of \(\omega_i\) |
| \(\eta = \frac{\eta_o}{\eta_i}\) | relative refractive index |
| \(\eta_{ext}\), \(\eta_{int}\) | refractive indices outside and inside the object |
Note that we chose to use the light natural propagation direction to fix the incident / outgoing convention.
C++ interface
In a path tracer, we must be able to evaluate the BSDF at any point \(p\) and for any couple of incident and outgoing directions. We compute the amount of scattered light from a point \(p\) to an outgoing direction by integrating over a set of incident directions. Hence we need a method to sample directions, and a method to evaluate the density of any direction for multiple importance sampling with light sampling. Finally, test functions verify that the implementation is consistent: the white furnace test checks energy conservation, and we should also check that the BSDF is reciprocal and that the sample and pdf methods agree and give the albedo of the BSDF for a given outgoing direction. Rendering an image of a lobe for a given outgoing direction is another very useful debugging tool.
The following code snippet describes the common BSDF interface in a path tracer.
We will derive from it all BSDF described in this document. Its main methods are:
- eval that returns the BSDF value of a given incident direction \(\omega_i\) when the outgoing direction is \(\omega_o\) and the texture coordinates are \((u,v)\).
- pdf that returns the probability density of a given incident direction \(\omega_i\), when the outgoing direction is \(\omega_o\) and the texture coordinates are \((u,v)\).
- sample that returns a sampled incident direction \(\omega_i\) using random samples from the sampler \(sampler\), when the outgoing direction is \(\omega_o\) and the texture coordinates are \((u,v)\). By convention eval returns the BSDF value without the cosine term \(\vert\cos\theta_i\vert\), which the integrator applies, and pdf returns a density with respect to solid angle. N.B Not all the BSDF sampling methods will consume the same amount of random samples. However this can lead to dimension mismatching with QMC samplers and inconsistent results. In some cases, one would prefer to send a random triplet (or n-uplet) as a parameter, ensuring that for every BSDF sample the same amount of random numbers are passed as argument even if they are not used.
class Bsdf
{
public:
Bsdf(){}
Bsdf(Texture* albedo, BsdfType type = NULL) : m_albedo(albedo), m_type(type) {}
virtual ~Bsdf() {}
virtual Color eval(const Vector& wi, const Vector& wo, const vec2& uv) const = 0;
virtual float pdf(const Vector& wi, const Vector& wo, const vec2& uv) const = 0;
virtual BsdfSample sample(Sampler& sampler, const Vector& wo, const vec2& uv) const = 0;
Texture* m_albedo;
BsdfType m_type;
};
We assume there exists a Texture class which implements the operator:
virtual Color operator() ( const vec2& uv ) const = 0;
to access surface properties such as albedo, roughness, anisotropy, etc at the specified coordinates \((u,v)\).
BsdfSample is a small 32-bytes structure containing all required information of a BSDF sample.
struct BsdfSample
{
Vector wi; // the sampled direction
float pdf; // the pdf of the direction
Color weight; // the associated sample weight (bsdf * cos / pdf)
};
Using a dedicated structure allows returning any additional information, such as the lobe that has been sampled for multi-lobe BSDF.
BsdfType enumerates the different combinations of BSDF lobes that can be used.
This is useful to define boolean test functions to retrieve bsdf properties.
enum BsdfType
{
NULL = 0,
GLOSSYREFLECTION = (1 << 0),
GLOSSYTRANSMISSION = (1 << 1),
DIFFUSEREFLECTION = (1 << 2),
DIFFUSETRANSMISSION = (1 << 3),
SPECULARREFLECTION = (1 << 4),
SPECULARTRANSMISSION = (1 << 5),
ANISOTROPIC = (1 << 6),
PHASE = (1 << 7),
FORWARD = (1 << 8),
BACKWARD = (1 << 9),
GLOSSY = GLOSSYREFLECTION | GLOSSYTRANSMISSION,
DIFFUSE = DIFFUSEREFLECTION | DIFFUSETRANSMISSION,
SPECULAR = SPECULARREFLECTION | SPECULARTRANSMISSION,
TRANSMISSIVE = GLOSSYTRANSMISSION | DIFFUSETRANSMISSION | SPECULARTRANSMISSION,
REFLECTIVE = GLOSSYREFLECTION | DIFFUSEREFLECTION | SPECULARREFLECTION,
};
class Bsdf
{
public:
...
virtual bool hasDiffuse() const { return (m_type & DIFFUSE) != 0; }
virtual bool hasGlossy() const { return (m_type & GLOSSY) != 0; }
virtual bool hasSpecular() const { return (m_type & SPECULAR) != 0; }
virtual bool hasForward() const { return (m_type & FORWARD) != 0; }
virtual bool hasBackward() const { return (m_type & BACKWARD) != 0; }
virtual bool isPhase() const { return (m_type & PHASE) != 0; }
virtual bool isPureDiffuse() const { return m_type != 0 && (m_type & ~DIFFUSE) == 0; }
virtual bool isPureGlossy() const { return m_type != 0 && (m_type & ~GLOSSY) == 0; }
virtual bool isPureSpecular() const { return m_type != 0 && (m_type & ~SPECULAR) == 0; }
virtual bool isForward() const { return m_type != 0 && (m_type & ~FORWARD) == 0; }
virtual bool isBackward() const { return m_type != 0 && (m_type & ~BACKWARD) == 0; }
virtual bool isTransmissive() const { return (m_type & TRANSMISSIVE) != 0; }
virtual bool isAnisotropic() const { return (m_type & ANISOTROPIC) != 0; }
virtual bool isDelta() const { return isPureSpecular(); }
virtual bool hasDelta() const { return hasSpecular(); }
};
One last method to add is a test function to ensure that the BSDF is normalized, which is super useful when implementing BSDF models. This test is called the white furnace test, see [Heitz14a] Section 3.5 for further details.
class Bsdf
{
public:
...
virtual void whiteFurnaceTest() const = 0;
}
Lambert model
The Lambert model assumes that the object surface is perfectly flat and that the light is equally reflected in all directions. The amount of reflected light is constant over the hemisphere and is independent of the eye direction:
\[\displaystyle \rho(\omega_i, \omega_o) = \frac{k}{\pi}\]Here \(k\) is the surface albedo at the position \(p\). The amount of light reflected towards a direction \(\omega_o\) from a surface point \(p\) writes:
\[\displaystyle L_r(p, \omega_o) = \int_\Omega L_i(p, \omega_i) \rho(\omega_i, \omega_o) \cos \theta_i \mathrm{d}\omega_i\]Estimating this integral requires sampling directions in the hemisphere around \(p\). The integrand is weighted by a cosine term, and good importance sampling is achieved when the sampling distribution is proportional to the integrand. Hence, we can use a cosine-weighted distribution to sample direction with \(\text{pdf} \propto \cos \theta_i\). The following code samples a cosine-weighted distribution of directions in the hemisphere given two uniform numbers.
Vector SampleCosineHemisphere( const float u1, const float u2 )
{
float phi = 2.f * (float) M_PI * u1;
float cos_theta = std::sqrt(u2);
float sin_theta = std::sqrt(1.f - std::min(1.f, cos_theta * cos_theta));
return Vector(std::cos(phi) * sin_theta, std::sin(phi) * sin_theta, cos_theta);
}
Finally the code for the Lambert BSDF model is:
class BsdfLambert : public Bsdf
{
public:
BsdfLambert(Texture* albedo) : Bsdf(albedo, DIFFUSEREFLECTION) {}
Color eval( const Vector& wi, const Vector& wo, const vec2& uv ) const
{
return (*m_albedo)(uv) * INV_PI;
}
float pdf( const Vector& wi, const Vector& wo, const vec2& uv ) const
{
return std::max(0.f, wi.z) * INV_PI;
}
BsdfSample sample( Sampler& sampler, const Vector& wo, const vec2& uv ) const
{
BsdfSample bs;
float u = sampler.uniform(), v = sampler.uniform();
bs.wi = SampleCosineHemisphere(u, v);
bs.pdf = std::max(0.f, bs.wi.z) * INV_PI;
bs.weight = (*m_albedo)(uv);
return bs;
}
};
This model results in a matte finish with a slight falloff that darkens edges. However, there is no control over the falloff with this model and it does not reproduce accurately the behavior of matte materials which tend to look more flat. This can be addressed by using a rough diffuse model such as the Oren-Nayar model [Oren94] or the stochastic GGX based rough diffuse model by Eric Heitz [Heitz15] which supports anisotropy.
| Constant albedo - Environment lighting | Textured albedo - Environment lighting |
|---|---|
![]() |
![]() |
Additional Lambertian diffuse models can be derived, such as Lambert transmission which is super simple and gives nice results for scattering through foliage: the same lobe mirrored in the opposite hemisphere, \(\rho(\omega_i, \omega_o) = \frac{k}{\pi}\) when \(\omega_i\) and \(\omega_o\) are on opposite sides of the surface, sampled with SampleCosineHemisphere and a flipped \(z\) component.
100% reflective BSDF
The second model is a 100% reflective material. Although this model is not physically based, it gives pleasant results and is simple to implement. In addition it is a good introduction to understand the reflection law. This model assumes that the surface is perfectly flat, and the light is reflected in a unique direction symmetric w.r.t the normal of the surface. The reflection ray can be computed using the Snell-Descartes reflection law:
\[\displaystyle \omega_i = 2 \langle \omega_g, \omega_o \rangle \omega_g - \omega_o\]If the geometric normal is aligned with the Z axis, \(\omega_g = \left(0,0,1\right)\), and the eye vector \(\omega_o\) is pointing outwards, the reflection simplifies to:
\[\displaystyle \omega_i = \left( -\omega_o.x, -\omega_o.y, \omega_o.z \right)\]We can implement both as utility functions in the code:
// arbitrary normal vector w
static Vector Reflect(const Vector& wo, const Vector& w)
{
return normalize(2.f * dot(wo, w) * w - wo);
}
// assumes w = Vector(0,0,1)
static Vector Reflect(const Vector& wo)
{
return Vector(-wo.x, -wo.y, wo.z);
}
The associated distribution is a Dirac and the pdf of a sampled direction is also 1, since for a given outgoing direction a unique incident direction exists. The eval and pdf methods can be defined in two ways. A first approach is to return 0 for any direction passed as argument. This follows the principle that a Dirac direction can only be found through the Bsdf::sample method and that evaluating the pdf or the function for an incident and outgoing direction does not make sense. A second more flexible approach, consists in returning 1 when the directions \(\omega_i\) and \(\omega_o\) follow a user-defined constraint of reflection, 0 otherwise (requiring an additional utility function). Finally the complete class writes:
class BsdfReflective : public Bsdf
{
public:
BsdfReflective(Texture* albedo) : Bsdf(albedo, SPECULARREFLECTION){}
Color eval( const Vector& wi, const Vector& wo, const vec2& uv ) const
{
return Black();
}
float pdf( const Vector& wi, const Vector& wo, const vec2& uv ) const
{
return 0;
}
BsdfSample sample( Sampler& sampler, const Vector& wo, const vec2& uv ) const
{
BsdfSample bs;
bs.wi = Vector(-wo.x, -wo.y, wo.z);
bs.pdf = 1;
bs.weight = (*m_albedo)(uv);
return bs;
}
};
The alternative flexible version with the utility function isReflection writes:
static bool isReflection(const Vector& wi, const Vector& wo)
{
return std::abs(wi.z*wo.z - wi.x*wo.x - wi.y*wo.y - 1.0f) < 1e-4f;
}
class BsdfReflectiveFlexible : public Bsdf
{
public:
BsdfReflectiveFlexible(Texture* albedo) : Bsdf(albedo, SPECULARREFLECTION){}
Color eval( const Vector& wi, const Vector& wo, const vec2& uv ) const
{
// N.B. The classic path tracing algorithm performs an integral over
// the hemisphere / shape of the BSDF. For that reason the path throughput
// is multiplied with an extra cosine term in the main loop.
// In order not to create a particular case in the main loop, we prefer
// to divide by the cosine factor in the eval method.
return isReflection(wi, wo) ? (*m_albedo)(uv) / std::abs(wi.z) : Black();
}
float pdf( const Vector& wi, const Vector& wo, const vec2& uv ) const
{
return isReflection(wi, wo);
}
BsdfSample sample( Sampler& sampler, const Vector& wo, const vec2& uv ) const
{
BsdfSample bs;
bs.wi = Vector(-wo.x, -wo.y, wo.z);
bs.pdf = 1;
bs.weight = (*m_albedo)(uv);
return bs;
}
};
This model results in a flat mirror finish. However, it does not capture the accurate behavior of smooth metals which requires taking into account Fresnel equations, which is further described in the conductors section.
| White albedo - Environment lighting | Gold albedo - Environment lighting |
|---|---|
![]() |
![]() |
100% transmissive BSDF
The third model is a 100% transmissive material. Although this model is not physically based, it gives (not so) pleasant results but is simple to implement. In addition it is a good introduction to understand the refraction law. This model assumes that the surface is perfectly flat, and the light is refracted in a unique direction through the surface. The direction can be computed using the Snell-Descartes refraction law. For further details see Section 8.2.3 in [Pharr16].
\[\displaystyle \omega_i = \left\{ \begin{array}{ll} \left( \eta \langle \omega_g, \omega_o \rangle - \cos \theta_i \right) \omega_g - \eta \omega_o \qquad \text{if $\omega_o$ is outside the object}\\ \left( \eta \langle \omega_g, \omega_o \rangle + \cos \theta_i \right) \omega_g - \eta \omega_o \qquad \text{if $\omega_o$ is inside the object} \end{array} \right.\]Here \(\eta = \frac{\eta_o}{\eta_i}\) is the ratio of the refractive index on the side of \(\omega_o\) over the refractive index on the side of \(\omega_i\). If \(\omega_o\) is outside the object \(\eta = \frac{\eta_{ext}}{\eta_{int}}\), else \(\eta = \frac{\eta_{int}}{\eta_{ext}}\). If the geometric normal is aligned with the Z axis, \(\omega_g = \left(0,0,1\right)\) the refraction simplifies to:
\[\displaystyle \omega_i = \left\{ \begin{array}{ll} \left( - \eta \omega_o.x, - \eta \omega_o.y, - \cos \theta_i \right) \qquad \text{if $\omega_o$ is outside the object}\\ \left( - \eta \omega_o.x, - \eta \omega_o.y, + \cos \theta_i \right) \qquad \text{if $\omega_o$ is inside the object} \end{array} \right.\]The angle of refraction \(\theta_i\) can be computed using Snell’s law and trigonometric identities.
\(\displaystyle \begin{split} & \eta_i \sin \theta_i = \eta_o \sin \theta_o \qquad \text{(Snell's law)} \\ \iff& \sin \theta_i = \frac{\eta_o}{\eta_i} \sin \theta_o \\ \iff& \cos \theta_i = \sqrt{1 - \left(\frac{\eta_o}{\eta_i} \sin \theta_o\right)^2} \qquad \text{using} \qquad \cos^2\theta = 1 - \sin^2\theta \\ \iff& \cos \theta_i = \sqrt{1 - \eta^2 \sin^2 \theta_o} \\ \iff& \cos \theta_i = \sqrt{1 - \eta^2 (1 - \cos^2 \theta_o)} \qquad \text{using} \qquad \sin^2\theta = 1 - \cos^2\theta \end{split}\) We have now expressed \(\theta_i\) function of \(\theta_o\), we can implement a small utility function that computes \(\theta_i\). N.B. In the unit hemisphere with normal aligned with the Z axis, the cosine term of a direction (inner product with the normal) is the Z component of the vector.
// compute the refracted cosine term using Snell's law, eta = eta_o / eta_i
static float ComputeThetaTransmitted(const float eta, const Vector &wo)
{
float sinThetaISq = (1.0f - wo.z * wo.z) * eta * eta;
if (sinThetaISq >= 1.0f) return 0; // total internal reflection
return std::sqrt(std::max(1.0f - sinThetaISq, 0.0f));
}
We are finally able to compute refracted directions from the outgoing direction, the normal and the ratio of refractive indices.
// arbitrary normal vector w (e.g. a microfacet normal): the cosines are measured w.r.t. w
static Vector Refract(const float eta, const Vector &wo, const Vector &w)
{
float cosThetaO = dot(wo, w);
float sinThetaISq = eta * eta * (1.0f - cosThetaO * cosThetaO);
if (sinThetaISq >= 1.0f) return Vector(0, 0, 0); // total internal reflection
float cosThetaI = std::sqrt(1.0f - sinThetaISq);
return (eta * cosThetaO - std::copysign(cosThetaI, cosThetaO)) * w - eta * wo;
}
// assumes w = vector(0,0,1)
static Vector Refract(const float eta, const Vector &wo)
{
float cosThetaI = ComputeThetaTransmitted(eta, wo);
return Vector(-wo.x * eta, -wo.y * eta, -std::copysign(cosThetaI, wo.z));
}
Similarly to the 100% reflective model, the associated distribution is a Dirac and the pdf of a sampled direction is also 1, since for a given outgoing direction a unique incident direction exists. The eval and pdf methods can be defined in two ways. A first approach is to return 0 for any direction passed as argument. This follows the principle that a Dirac direction can only be found through the Bsdf::sample method and that evaluating the pdf or the function for an incident and outgoing direction does not make sense. A second more flexible approach, consists in returning 1 when the directions \(\omega_i\) and \(\omega_o\) follow a user-defined constraint of refraction, 0 otherwise (requiring an additional utility function). Finally the complete class writes:
class BsdfTransmissive : public Bsdf
{
public:
BsdfTransmissive(Texture* albedo, float intIOR = 1.5f, float extIOR = 1.f) :
Bsdf(albedo, SPECULARTRANSMISSION),
m_intIOR(intIOR),
m_extIOR(extIOR),
m_eta(m_extIOR / m_intIOR),
m_invEta(1.f / m_eta)
{}
Color eval( const Vector& wi, const Vector& wo, const vec2& uv ) const
{
return Black();
}
float pdf( const Vector& wi, const Vector& wo, const vec2& uv ) const
{
return 0;
}
BsdfSample sample( Sampler& sampler, const Vector& wo, const vec2& uv ) const
{
BsdfSample bs;
float eta = wo.z > 0.0f ? m_eta : m_invEta; // eta_o / eta_i
bs.wi = Refract(eta, wo);
bs.pdf = 1;
bs.weight = (*m_albedo)(uv);
return bs;
}
float m_intIOR, m_extIOR, m_eta, m_invEta;
};
As for the 100% reflective model, we can define a more flexible version that tests whether two directions follow a refraction constraint, which writes:
static bool isRefraction(const Vector& wi, const Vector& wo, float eta, float cosThetaI)
{
float dotP = -wi.x * wo.x * eta - wi.y * wo.y * eta - std::copysign(cosThetaI, wo.z) * wi.z;
return std::abs(dotP - 1.0f) < 1e-4;
}
class BsdfTransmissiveFlexible : public Bsdf
{
public:
BsdfTransmissiveFlexible(Texture* albedo, float intIOR = 1.5f, float extIOR = 1.f) :
Bsdf(albedo, SPECULARTRANSMISSION),
m_intIOR(intIOR),
m_extIOR(extIOR),
m_eta(m_extIOR / m_intIOR),
m_invEta(1.f / m_eta)
{}
Color eval( const Vector& wi, const Vector& wo, const vec2& uv ) const
{
if(wi.z == 0 || wo.z == 0) return Black();
float eta = wo.z > 0.0f ? m_eta : m_invEta; // eta_o / eta_i
float cosThetaI = ComputeThetaTransmitted(eta, wo);
return isRefraction(wi, wo, eta, cosThetaI) ? (*m_albedo)(uv) / std::abs(wi.z) : Black();
}
float pdf( const Vector& wi, const Vector& wo, const vec2& uv ) const
{
if(wi.z == 0 || wo.z == 0) return 0;
float eta = wo.z > 0.0f ? m_eta : m_invEta; // eta_o / eta_i
float cosThetaI = ComputeThetaTransmitted(eta, wo);
return isRefraction(wi, wo, eta, cosThetaI);
}
BsdfSample sample( Sampler& sampler, const Vector& wo, const vec2& uv ) const
{
BsdfSample bs;
float eta = wo.z > 0.0f ? m_eta : m_invEta; // eta_o / eta_i
bs.wi = Refract(eta, wo);
bs.pdf = 1;
bs.weight = (*m_albedo)(uv);
return bs;
}
float m_intIOR, m_extIOR, m_eta, m_invEta;
};
This model results in a flat transparent finish. However, it does not capture the accurate behavior of smooth dielectrics which requires taking into account Fresnel equations, which is further described in the dielectric section.
| White albedo - IOR 1.5 | Cyan albedo - IOR 1.5 |
|---|---|
![]() |
![]() |

| Material | IOR |
|---|---|
| Air | 1.000293 (commonly used value is 1) |
| Water | 1.333 |
| Glass | 1.52 (commonly used value is 1.5) |
| Diamond | 2.417 |
[Some values from Wikipedia’s List of refractive indices]
Fresnel
In the real world, the amount of transmitted and reflected light varies with the angle of incidence of the eye direction. Fresnel equations accurately evaluate the reflectance of a material for a given incident angle.
We will not spend much time on Fresnel equations but a short introduction is needed before describing the next models.
First some references on Fresnel equations :
- The excellent Seb Lagarde’s memo on Fresnel equation with some useful references [Lagarde13] link
- Naty Hoffman’s 2019 MAM talk on Fresnel equations with plenty of details [Hoffman19] link
Fresnel reflectance
This is a tough topic and we invite the reader to consult Seb Lagarde’s memo and the mentioned sources for further details. Unlike the reflectance of conductors, the reflectance of dielectric materials is achromatic.
At a smooth interface between a medium of index \(\eta_o\) (the side of \(\omega_o\)) and a medium of index \(\eta_i\) (the other side, where the refracted direction \(\omega_i\) lies), part of the light is reflected and the rest is transmitted. As in the refraction section, \(\eta = \frac{\eta_o}{\eta_i}\) and Snell’s law gives the cosine of the refracted direction, \(\cos^2\theta_i = 1 - \eta^2 \left(1 - \cos^2\theta_o\right)\). The reflectance differs for the two polarizations of light (perpendicular \(s\) and parallel \(p\) to the plane of incidence):
\[\displaystyle r_s = \frac{\eta \cos\theta_o - \cos\theta_i}{\eta \cos\theta_o + \cos\theta_i} \qquad r_p = \frac{\cos\theta_o - \eta \cos\theta_i}{\cos\theta_o + \eta \cos\theta_i}\]Renderers usually assume unpolarized light, so the Fresnel reflectance is the average of both polarizations. When \(\eta^2 \sin^2\theta_o \geq 1\) there is no transmitted direction: all the light is reflected (total internal reflection):
\[\displaystyle F(\theta_o) = \left\{ \begin{array}{ll} \frac{1}{2}\left(r_s^2 + r_p^2\right) & \text{if } \eta^2 \sin^2\theta_o < 1 \\ 1 & \text{otherwise (total internal reflection)} \end{array} \right. \qquad T(\theta_o) = 1 - F(\theta_o)\]At normal incidence both polarizations agree, \(F_0 = \left(\frac{\eta_i - \eta_o}{\eta_i + \eta_o}\right)^2\), the classic 4% for glass in the air (\(\eta_o = 1\), \(\eta_i = 1.5\)). The function reuses ComputeThetaTransmitted from the refraction section:
// Fresnel reflectance of a smooth dielectric interface, eta = eta_o / eta_i
static float FresnelDielectric(float cosThetaO, float eta)
{
cosThetaO = std::abs(cosThetaO);
float sinThetaISq = eta * eta * (1.f - cosThetaO * cosThetaO);
if (sinThetaISq >= 1.f) return 1.f; // total internal reflection
float cosThetaI = std::sqrt(std::max(0.f, 1.f - sinThetaISq));
float rs = (eta * cosThetaO - cosThetaI) / (eta * cosThetaO + cosThetaI);
float rp = (cosThetaO - eta * cosThetaI) / (cosThetaO + eta * cosThetaI);
return 0.5f * (rs * rs + rp * rp);
}
Conductors absorb transmitted light within a very short distance, modeled by a complex index of refraction \(\eta + i\kappa\) with \(\kappa\) the absorption (extinction) coefficient. Following the usual convention for measured data, this is the index of the metal relative to the outside medium, the inverse of the dielectric ratio \(\frac{\eta_o}{\eta_i}\) seen from outside. Both are spectral quantities (one value per channel in an RGB renderer); measured values are on refractiveindex.info. With air as the exterior medium (otherwise divide \(\eta\) and \(\kappa\) by the exterior index), the reflectance writes ([Lagarde13], [Pharr16] Section 8.2.1):
\[\displaystyle \begin{aligned} & a^2 + b^2 = \sqrt{\left(\eta^2 - \kappa^2 - \sin^2\theta\right)^2 + 4\eta^2\kappa^2} \qquad a = \sqrt{\tfrac{1}{2}\left(a^2 + b^2 + \eta^2 - \kappa^2 - \sin^2\theta\right)} \\ & R_s = \frac{a^2 + b^2 - 2a\cos\theta + \cos^2\theta}{a^2 + b^2 + 2a\cos\theta + \cos^2\theta} \qquad R_p = R_s \frac{\cos^2\theta\left(a^2 + b^2\right) - 2a\cos\theta\sin^2\theta + \sin^4\theta}{\cos^2\theta\left(a^2 + b^2\right) + 2a\cos\theta\sin^2\theta + \sin^4\theta} \\ & F(\theta) = \frac{1}{2}\left(R_s + R_p\right) \end{aligned}\]// Fresnel reflectance of a conductor, eta + i k = complex IOR of the metal / IOR outside (per channel)
static Color FresnelConductor(float cosTheta, const Color& eta, const Color& k)
{
float c2 = cosTheta * cosTheta, s2 = 1.f - c2;
Color t0 = eta * eta - k * k - Color(s2);
Color a2b2 = sqrt(t0 * t0 + 4.f * eta * eta * k * k);
Color a = sqrt(0.5f * (a2b2 + t0));
Color t1 = a2b2 + Color(c2), t2 = 2.f * cosTheta * a;
Color Rs = (t1 - t2) / (t1 + t2);
Color t3 = c2 * a2b2 + Color(s2 * s2), t4 = t2 * s2;
Color Rp = Rs * (t3 - t4) / (t3 + t4);
return 0.5f * (Rp + Rs);
}
Color is assumed to provide per channel arithmetic operators and sqrt. With \(\kappa = 0\) the formula reduces to the dielectric one.
Schlick approximation
Schlick’s approximation [Schlick94] replaces the Fresnel equations by a polynomial that interpolates between the reflectance at normal incidence \(F_0\) and total reflection at grazing angles:
\[\displaystyle F(\theta) \approx F_0 + \left(1 - F_0\right)\left(1 - \cos\theta\right)^5\]A common generalization replaces the grazing value 1 by a parameter \(F_{90}\), with \(F_{90} = 1\) giving back the classic form:
\[\displaystyle F(\theta) \approx F_0 + \left(F_{90} - F_0\right)\left(1 - \cos\theta\right)^5\]The glTF KHR_materials_specular extension uses it to scale the dielectric reflectance at grazing angles (\(F_{90}\) is its specular factor) [glTFext], and Burley’s diffuse retro-reflection term is the same form with \(F_0 = 1\) and \(F_{90} = F_{D90} = 0.5 + 2\, \text{roughness} \cos^2\theta_d\), applied to \(\theta_i\) and \(\theta_o\) [Burley12].
For a dielectric \(F_0 = \left(\frac{\eta_i - \eta_o}{\eta_i + \eta_o}\right)^2\). From the denser to the less dense medium (\(\eta_o > \eta_i\)), the approximation must use the refracted cosine \(\cos\theta_i\) instead of \(\cos\theta_o\), and return 1 under total internal reflection. For conductors, \(F_0\) is the color of the metal at normal incidence, an intuitive parameter for artists.
static Color SchlickFresnel(const Color& F0, float cosTheta, const Color& F90 = Color(1.f))
{
float m = std::min(1.f, std::max(0.f, 1.f - cosTheta));
float m2 = m * m;
return F0 + (F90 - F0) * (m2 * m2 * m);
}
Lazanyi - Schlick approximation
In his 2019 MAM talk, Naty Hoffman proposes to use [Lazanyi05] as a better approximation for the reflectance of materials. The idea of Naty Hoffman’s talk is that Fresnel equations are only approximations, depending on how the complex IOR has been computed. Using a wrong approximation may lead to worse results than using a tint and Schlick approximation. So going with the approximation is not a bad idea. However its error can be reduced with some modifications in the equation. An additional parameter \(h=F(82°)\) is used to modulate the edge tint.
The Lazanyi - Schlick model adds an error term to Schlick’s approximation, and Hoffman’s formulation [Hoffman19] chooses its weight \(a\) so that the reflectance equals the edge tint \(h\) at the angle \(\theta_{max}\) where the error term peaks, \(\cos\theta_{max} = \frac{1}{7}\) (\(\theta_{max} \approx 81.8°\)):
\[\displaystyle F(\theta) = F_0 + \left(1 - F_0\right)\left(1 - \cos\theta\right)^5 - a \cos\theta \left(1 - \cos\theta\right)^6 \qquad a = \frac{F_0 + \left(1 - F_0\right)\left(1 - \cos\theta_{max}\right)^5 - h}{\cos\theta_{max}\left(1 - \cos\theta_{max}\right)^6}\]Both \(F_0\) and \(h\) are colors, and the model still gives \(F_0\) at normal incidence and 1 at grazing angles. OpenPBR uses this form for its metals, as the F82-tint model [Kutz21].
static Color LazanyiSchlickFresnel(const Color& F0, const Color& h, float cosTheta)
{
const float cosMax = 1.f / 7.f;
const float mMax = 1.f - cosMax;
Color a = (SchlickFresnel(F0, cosMax) - h) / (cosMax * std::pow(mMax, 6.f));
float m = std::min(1.f, std::max(0.f, 1.f - cosTheta));
return SchlickFresnel(F0, cosTheta) - a * (cosTheta * std::pow(m, 6.f));
}
Conductor
A smooth conductor is the 100% reflective BSDF with the Fresnel reflectance of the metal in place of the constant albedo: the sample weight of the Dirac direction is the Fresnel reflectance at \(\cos\theta_o = \omega_o.z\) (equal to the incident cosine for a mirror reflection):
class BsdfConductor : public Bsdf
{
public:
BsdfConductor(const Color& eta, const Color& k) : Bsdf(nullptr, SPECULARREFLECTION), m_eta(eta), m_k(k) {}
Color eval( const Vector& wi, const Vector& wo, const vec2& uv ) const { return Black(); }
float pdf( const Vector& wi, const Vector& wo, const vec2& uv ) const { return 0; }
BsdfSample sample( Sampler& sampler, const Vector& wo, const vec2& uv ) const
{
BsdfSample bs;
bs.wi = Reflect(wo);
bs.pdf = 1;
bs.weight = FresnelConductor(std::abs(wo.z), m_eta, m_k);
return bs;
}
Color m_eta, m_k;
};
The tinted conductor is the same class with FresnelConductor replaced by SchlickFresnel and a texture for \(F_0\), or by LazanyiSchlickFresnel with an additional edge tint texture \(h\).
Conductor Fresnel reflectance (with complex IOR)
| Copper | Gold | Iron |
|---|---|---|
![]() |
![]() |
![]() |
Conductor Schlick Fresnel approximation
With Schlick’s approximation, a white halo appears on the edge that is not in the reference image. The Lazanyi - Schlick approximation closely matches the reference at the cost of minor additional computation.
| Schlick Fresnel approximation | Lazanyi - Schlick Fresnel approximation | Reference |
|---|---|---|
![]() |
![]() |
![]() |
![]() |
![]() |
Edge control with the Lazanyi - Schlick approximation
Another benefit of this model is the ability to smoothly control the edge tint of the material.
| Copper with cyan tinted edges | Gold with purple tinted edges |
|---|---|
![]() |
![]() |
Dielectric
A smooth dielectric combines the two previous Dirac lobes with the Fresnel equations: the light is reflected with probability \(F(\theta_o)\) and refracted with probability \(1 - F(\theta_o)\). Choosing between the lobes with these probabilities gives sample weights equal to 1 for reflection and to the albedo tint for refraction:
\[\displaystyle \frac{F(\theta_o)}{F(\theta_o)} = 1 \qquad \text{and} \qquad \frac{1 - F(\theta_o)}{1 - F(\theta_o)} = 1\]One last subtlety: radiance is not invariant through a refraction. The solid angle is compressed when light enters a denser medium, and the radiance \(L\) scales so that \(\frac{L}{\eta^2}\) is invariant. When transporting radiance (paths starting from the camera), the transmitted sample weight is scaled by \(\left(\frac{\eta_o}{\eta_i}\right)^2\), the squared eta of the refraction functions. This factor is omitted when transporting importance from the light sources (light tracing, or the light sub-paths of a bidirectional path tracer); see [Pharr16] Section 16.1 and [Veach97] Chapter 5 on non-symmetric scattering. Forgetting it is a classic source of mismatch between unidirectional and bidirectional renders.
class BsdfDielectric : public Bsdf
{
public:
BsdfDielectric(Texture* albedo, float intIOR = 1.5f, float extIOR = 1.f) :
Bsdf(albedo, BsdfType(SPECULARREFLECTION | SPECULARTRANSMISSION)),
m_eta(extIOR / intIOR), m_invEta(intIOR / extIOR) {}
Color eval( const Vector& wi, const Vector& wo, const vec2& uv ) const { return Black(); }
float pdf( const Vector& wi, const Vector& wo, const vec2& uv ) const { return 0; }
BsdfSample sample( Sampler& sampler, const Vector& wo, const vec2& uv ) const
{
BsdfSample bs;
float eta = wo.z > 0.0f ? m_eta : m_invEta; // eta_o / eta_i
float F = FresnelDielectric(wo.z, eta);
if (sampler.uniform() < F)
{
bs.wi = Reflect(wo);
bs.pdf = F; // discrete probability of the lobe
bs.weight = Color(1.f); // F / F
}
else
{
bs.wi = Refract(eta, wo);
bs.pdf = 1.f - F;
bs.weight = (*m_albedo)(uv) * (eta * eta); // (1 - F) / (1 - F), radiance scaling
}
return bs;
}
float m_eta, m_invEta;
};
FresnelDielectric returns 1 under total internal reflection, so the refraction branch is never taken in that case.

Plastic
- A very comprehensive blog post about BSDF properties link
A plastic is a diffuse base (the colored pigments) under a smooth transparent dielectric coating (the varnish), the first layered model of this document. The coating reflects a part \(F(\theta_o)\) of the light in the mirror direction, as the smooth dielectric does. The rest enters the coating, is scattered by the Lambertian base of albedo \(\rho\), and crosses the coating again to leave the surface. Following this path gives the diffuse part of the model:
- the light enters with a factor \(1 - F(\theta_i)\),
- the diffuse base reflects it with a Lambertian lobe \(\frac{\rho}{\pi}\),
- on its way out, the inner side of the coating reflects a part \(\bar F_{int}\) of the diffuse light back towards the base, giving infinitely many inter-reflections between the base and the coating: \(\sum_{k \geq 0} \left(\rho \bar F_{int}\right)^k = \frac{1}{1 - \rho \bar F_{int}}\),
- the light leaves the coating towards \(\omega_o\) with a factor \(1 - F(\theta_o)\), and its radiance is scaled by \(\left(\frac{\eta_{ext}}{\eta_{int}}\right)^2\) since it exits into a less dense medium.
Here \(\bar F_{int}\) is the internal diffuse Fresnel reflectance, the cosine weighted average of the Fresnel reflectance seen from inside the coating. Total internal reflection makes it large (about 0.6 for \(\eta_{int} = 1.5\) in the air). It only depends on the IOR and is precomputed once:
\[\displaystyle \bar F = 2 \int_0^1 F(\mu) \mu \mathrm{d}\mu\]// cosine weighted hemispherical average of the Fresnel reflectance, eta = eta_o / eta_i
static float DiffuseFresnel(float eta, int n = 1024)
{
float sum = 0;
for (int k = 0; k < n; ++k)
{
float mu = (k + 0.5f) / n;
sum += FresnelDielectric(mu, eta) * mu;
}
return 2.f * sum / n;
}
The internal and external averages are linked by \(1 - \bar F_{int} = \left(\frac{\eta_{ext}}{\eta_{int}}\right)^2 \left(1 - \bar F_{ext}\right)\), so with a white base (\(\rho = 1\)) the model is exactly energy conserving: all the light not reflected by the coating eventually leaves the surface. With a colored base, the inter-reflections saturate the color, the characteristic look of plastics. The model is reciprocal since \(\rho_d\) is symmetric in \(\omega_i\) and \(\omega_o\).
For sampling, we choose between the specular and diffuse lobes with probabilities that approximate their energy: \(P_s = \frac{F(\theta_o)}{F(\theta_o) + \left(1 - F(\theta_o)\right) \bar\rho}\) where \(\bar\rho\) is the average of the albedo channels. Since the specular lobe is a Dirac, eval and pdf only return the diffuse part.
class BsdfPlastic : public Bsdf
{
public:
BsdfPlastic(Texture* albedo, float intIOR = 1.5f, float extIOR = 1.f) :
Bsdf(albedo, BsdfType(SPECULARREFLECTION | DIFFUSEREFLECTION)),
m_eta(extIOR / intIOR), // seen from outside, eta_o / eta_i
m_eta2(m_eta * m_eta), // (eta_ext / eta_int)^2, radiance scaling on exit
m_FdrInt(DiffuseFresnel(intIOR / extIOR)) // seen from inside
{}
float specularProbability( float Fo, const Color& rho ) const
{
return Fo / (Fo + (1.f - Fo) * average(rho));
}
Color eval( const Vector& wi, const Vector& wo, const vec2& uv ) const
{
if (wi.z <= 0 || wo.z <= 0) return Black();
Color rho = (*m_albedo)(uv);
float Fi = FresnelDielectric(wi.z, m_eta), Fo = FresnelDielectric(wo.z, m_eta);
return rho / (Color(1.f) - rho * m_FdrInt) * ((1.f - Fi) * (1.f - Fo) * m_eta2 * INV_PI);
}
float pdf( const Vector& wi, const Vector& wo, const vec2& uv ) const
{
if (wi.z <= 0 || wo.z <= 0) return 0;
float Ps = specularProbability(FresnelDielectric(wo.z, m_eta), (*m_albedo)(uv));
return (1.f - Ps) * wi.z * INV_PI;
}
BsdfSample sample( Sampler& sampler, const Vector& wo, const vec2& uv ) const
{
BsdfSample bs;
float Fo = FresnelDielectric(wo.z, m_eta);
float Ps = specularProbability(Fo, (*m_albedo)(uv));
float u = sampler.uniform(), v = sampler.uniform(), w = sampler.uniform();
if (u < Ps)
{
bs.wi = Reflect(wo);
bs.pdf = Ps; // discrete probability of the Dirac lobe
bs.weight = Color(Fo / Ps);
}
else
{
bs.wi = SampleCosineHemisphere(v, w);
bs.pdf = pdf(bs.wi, wo, uv);
bs.weight = eval(bs.wi, wo, uv) * bs.wi.z / bs.pdf;
}
return bs;
}
float m_eta, m_eta2, m_FdrInt;
};
Here average returns the mean of the color channels. The integrator must know whether a sample comes from the Dirac lobe, to skip multiple importance sampling with light sampling for it; the sampled lobe can be stored in BsdfSample.
| Red albedo | Cyan albedo |
|---|---|
![]() |
![]() |
Microfacet model
After smooth surfaces we would like to model rough / scratched / etched surfaces. Smooth surfaces are assumed perfectly flat at macroscopic and microscopic scale, on the contrary rough materials are flat at macroscopic scale and present perturbations at microscopic scale.
Microfacet models have been developed to model the distribution of normals on the surface. These models are commonly parameterized by roughness, that controls the amount of perturbations at microscopic scale, and anisotropy that controls the stretch of the distribution w.r.t the surface parameterization. The directional distribution associated with an outgoing direction is a lobe centered around the mirror direction. Several microfacet distributions exist (GGX, Beckmann, Blinn-Phong), however we will only talk about the Trowbridge-Reitz (GGX) distribution [Trowbridge75] [Walter07], since this is a widely used model in production and is fully analytical.
![Varying parameters of the GGX distribution. Top row corresponds to an isotropic distribution. Linear roughness ranges horizontally in [0,1] from left to right and anisotropy ranges vertically in [0,1] from top to bottom. The outgoing direction varies over time from a normal angle of incidence (θo = 0, cos θo = 1) to a grazing angle of incidence (θo → 90°, cos θo → 0).](/bsdf2020/data/test_bsdf_ggx_anisotropic.gif)
A microfacet model is made of three ingredients:
- the normal distribution function (NDF) \(D(\omega_m)\), the density of micro-normals, normalized so that the projected area of the microsurface equals the area of the macro surface, \(\int_{\Omega} D(\omega_m) \cos\theta_m \mathrm{d}\omega_m = 1\),
- the masking-shadowing function \(G_2(\omega_o, \omega_i, \omega_m)\), the fraction of microfacets with normal \(\omega_m\) visible from both directions [Heitz14a],
- the BSDF of a single microfacet: a perfect mirror (with Fresnel reflectance) for conductors, a perfect mirror and a perfect refraction for dielectrics.
The incident and outgoing directions select the micro-normal that maps one onto the other, the half vector: the normalized sum of both directions for a reflection, and the generalized half vector of Walter et al. [Walter07] for a refraction, with \(\eta_o\) and \(\eta_i\) the indices on the side of each direction:
\[\displaystyle \omega_m^r = \frac{\omega_o + \omega_i}{\lVert \omega_o + \omega_i \rVert} \qquad \omega_m^t = -\frac{\eta_o \omega_o + \eta_i \omega_i}{\lVert \eta_o \omega_o + \eta_i \omega_i \rVert}\]In both cases the half vector is flipped if needed to lie in the hemisphere of the macro normal, \(\omega_m.z > 0\).
Isotropic
Some common shape invariant distributions of micronormals, based on a statistical heightfield, can be derived, such as GGX / Trowbridge-Reitz, Beckmann, GTR, STD, etc.
Evaluating and sampling them is widely studied, though very efficient closed form sampling only exists for GGX. Numerical methods sample the Beckmann distribution very accurately [Jakob14], and the Student-T distribution of visible normals can be sampled as a mixture of Beckmann distributions, with delta tracking giving exact multiple scattering BSDFs for general NDFs [dEon23].
The isotropic GGX distribution has a single roughness parameter \(\alpha\). The artist friendly linear roughness \(r \in [0,1]\) is usually remapped with \(\alpha = r^2\), for a perceptually more linear variation of the appearance [Burley12]:
\[\displaystyle D(\omega_m) = \frac{\alpha^2}{\pi \cos^4\theta_m \left(\alpha^2 + \tan^2\theta_m\right)^2} = \frac{1}{\pi \alpha^2 \left(\frac{x_m^2 + y_m^2}{\alpha^2} + z_m^2\right)^2}\]Anisotropic
Anisotropy comes from the way we stretch the distribution of micronormals (cf: Microsurface transformations).
Stretching the microsurface by \(\alpha_x\) along the tangent \(\omega_t\) and by \(\alpha_y\) along the bitangent \(\omega_b\) gives the anisotropic GGX distribution, which reduces to the isotropic one when \(\alpha_x = \alpha_y = \alpha\) ([Heitz14a], Section 5):
\[\displaystyle D(\omega_m) = \frac{1}{\pi \alpha_x \alpha_y \left(\frac{x_m^2}{\alpha_x^2} + \frac{y_m^2}{\alpha_y^2} + z_m^2\right)^2}\]Burley [Burley12] maps the linear roughness \(r\) and an anisotropy parameter \(a \in [0,1]\) to both roughnesses with \(k = \sqrt{1 - 0.9a}\), \(\alpha_x = \frac{r^2}{k}\) and \(\alpha_y = r^2 k\), where the 0.9 factor limits the aspect ratio to 10:1. Clamping both values to a small minimum (e.g. \(10^{-3}\)) avoids numerical issues with almost specular surfaces.
The Smith masking function of GGX is expressed with the auxiliary function \(\Lambda\). For reflection we use the height-correlated masking-shadowing function, which is more accurate than the separable product \(G_1(\omega_o) G_1(\omega_i)\) [Heitz14a]:
\[\displaystyle \Lambda(\omega) = \frac{-1 + \sqrt{1 + \frac{\alpha_x^2 x^2 + \alpha_y^2 y^2}{z^2}}}{2} \qquad G_1(\omega) = \frac{1}{1 + \Lambda(\omega)} \qquad G_2(\omega_o, \omega_i) = \frac{1}{1 + \Lambda(\omega_o) + \Lambda(\omega_i)}\]These functions assume the directions and the micro-normal are on consistent sides: \(G\) is zero if \(\langle\omega,\omega_m\rangle\) and \(\omega.z\) have opposite signs (back-facing microfacet).
The most efficient way to importance sample GGX is to sample the distribution of visible normals (VNDF) [Heitz14b], the micro-normals weighted by their visible projected area from \(\omega_o\):
\[\displaystyle D_{\omega_o}(\omega_m) = \frac{G_1(\omega_o) \max\left(0, \langle\omega_o, \omega_m\rangle\right) D(\omega_m)}{\omega_o.z}\]It never generates micro-normals invisible from \(\omega_o\) and removes most of the variance of the sample weights. Both exact routines first stretch the view direction to the configuration where the microsurface is a unit hemisphere, sample a visible normal there, and transform it back to the ellipsoid configuration. Heitz [Heitz18] samples the projected (visible) half disk and lifts the point to the hemisphere. Dupuy and Benyoub [Dupuy23] observed that a hemispherical mirror reflects parallel rays uniformly into a spherical cap: the visible normals are the half vectors between the view direction and directions sampled uniformly in that cap, which gives a shorter routine for the same distribution, so the pdf above is unchanged.
// Sample a visible normal of GGX(alpha_x, alpha_y), Dupuy & Benyoub 2023, requires wo.z > 0
static Vector SampleGGXVNDF(const Vector& wo, float alpha_x, float alpha_y, float u1, float u2)
{
// transform the view direction to the hemisphere configuration
Vector wh = normalize(Vector(alpha_x * wo.x, alpha_y * wo.y, wo.z));
// sample a direction uniformly in the spherical cap z in (-wh.z, 1]
float phi = 2.f * (float) M_PI * u1;
float z = (1.f - u2) * (1.f + wh.z) - wh.z;
float sinTheta = std::sqrt(std::clamp(1.f - z * z, 0.f, 1.f));
Vector c(sinTheta * std::cos(phi), sinTheta * std::sin(phi), z);
// the visible normal is the half vector of c and wh (normalized below)
Vector h = c + wh;
// transform the normal back to the ellipsoid configuration
return normalize(Vector(alpha_x * h.x, alpha_y * h.y, h.z));
}
A small helper gathers the distribution functions:
struct GGX
{
float ax, ay;
float D( const Vector& m ) const
{
if (m.z <= 0) return 0;
float x = m.x / ax, y = m.y / ay, d = x * x + y * y + m.z * m.z;
return 1.f / ((float) M_PI * ax * ay * d * d);
}
float Lambda( const Vector& w ) const
{
float t = (ax * ax * w.x * w.x + ay * ay * w.y * w.y) / (w.z * w.z);
return 0.5f * (-1.f + std::sqrt(1.f + t));
}
float G1( const Vector& w ) const { return 1.f / (1.f + Lambda(w)); }
float G2( const Vector& wo, const Vector& wi ) const { return 1.f / (1.f + Lambda(wo) + Lambda(wi)); }
// density of visible normals, wo.z > 0
float Dvis( const Vector& wo, const Vector& m ) const
{
return G1(wo) * std::max(0.f, dot(wo, m)) * D(m) / wo.z;
}
Vector sample( const Vector& wo, float u1, float u2 ) const { return SampleGGXVNDF(wo, ax, ay, u1, u2); }
};
Rough diffuse - Oren Nayar
Oren and Nayar [Oren94] model a rough diffuse surface as a collection of V-shaped Lambertian cavities whose slopes follow a Gaussian distribution of standard deviation \(\sigma\) (in radians). The model accounts for masking, shadowing and inter-reflections in the cavities, which brighten the surface towards the light (back scattering) and flatten its appearance compared to Lambert. The full model has no closed form; in practice we use the authors’ qualitative approximation ([Pharr16] Section 8.4.1):
\[\displaystyle \rho(\omega_i, \omega_o) = \frac{k}{\pi} \left(A + B \max\left(0, \cos(\phi_i - \phi_o)\right) \sin\alpha \tan\beta\right) \qquad \alpha = \max(\theta_i, \theta_o) \qquad \beta = \min(\theta_i, \theta_o)\] \[\displaystyle A = 1 - \frac{\sigma^2}{2\left(\sigma^2 + 0.33\right)} \qquad B = \frac{0.45 \sigma^2}{\sigma^2 + 0.09}\]With \(\sigma = 0\) it is the Lambert model. It loses energy as roughness increases (about 10% to 25% for \(\sigma = 0.6\) depending on the outgoing direction), consistent with the darker look of rough matte surfaces. Cosine-weighted hemisphere sampling remains a good strategy.
class BsdfOrenNayar : public Bsdf
{
public:
BsdfOrenNayar(Texture* albedo, float sigma) : Bsdf(albedo, DIFFUSEREFLECTION)
{
float s2 = sigma * sigma;
m_A = 1.f - s2 / (2.f * (s2 + 0.33f));
m_B = 0.45f * s2 / (s2 + 0.09f);
}
Color eval( const Vector& wi, const Vector& wo, const vec2& uv ) const
{
if (wi.z <= 0 || wo.z <= 0) return Black();
float sinThetaI = std::sqrt(std::max(0.f, 1.f - wi.z * wi.z));
float sinThetaO = std::sqrt(std::max(0.f, 1.f - wo.z * wo.z));
// cos(phi_i - phi_o) from the tangent components
float maxCos = 0;
if (sinThetaI > 1e-4f && sinThetaO > 1e-4f)
maxCos = std::max(0.f, (wi.x * wo.x + wi.y * wo.y) / (sinThetaI * sinThetaO));
// sin(alpha) and tan(beta)
float sinAlpha, tanBeta;
if (wi.z < wo.z) { sinAlpha = sinThetaI; tanBeta = sinThetaO / wo.z; } // theta_i > theta_o
else { sinAlpha = sinThetaO; tanBeta = sinThetaI / wi.z; }
return (*m_albedo)(uv) * (INV_PI * (m_A + m_B * maxCos * sinAlpha * tanBeta));
}
float pdf( const Vector& wi, const Vector& wo, const vec2& uv ) const
{
return std::max(0.f, wi.z) * INV_PI;
}
BsdfSample sample( Sampler& sampler, const Vector& wo, const vec2& uv ) const
{
BsdfSample bs;
float u = sampler.uniform(), v = sampler.uniform();
bs.wi = SampleCosineHemisphere(u, v);
bs.pdf = pdf(bs.wi, wo, uv);
bs.weight = bs.pdf > 0 ? eval(bs.wi, wo, uv) * bs.wi.z / bs.pdf : Black();
return bs;
}
float m_A, m_B;
};

More recent alternatives include energy preserving variants of the Oren-Nayar model, and the GGX based rough diffuse model of the next section.
Anisotropic rough diffuse, conductor and dielectric with GGX
Rough conductor
The single scattering microfacet BRDF integrates the mirror reflections of all visible microfacets; for a pair of directions only those oriented along the half vector \(\omega_m\) contribute, giving the Cook-Torrance form [Walter07]:
\[\displaystyle \rho(\omega_i, \omega_o) = \frac{F\left(\langle\omega_o, \omega_m\rangle\right) D(\omega_m) G_2(\omega_o, \omega_i)}{4 \cos\theta_o \cos\theta_i}\]The Fresnel term uses the angle to the micro-normal, not the macro normal. When a visible normal is sampled and \(\omega_o\) reflected on it, the density of the incident direction includes the Jacobian of the reflection \(\frac{\mathrm{d}\omega_m}{\mathrm{d}\omega_i} = \frac{1}{4 \lvert\langle\omega_o, \omega_m\rangle\rvert}\):
\[\displaystyle \text{pdf}(\omega_i) = \frac{D_{\omega_o}(\omega_m)}{4 \langle\omega_o, \omega_m\rangle} = \frac{G_1(\omega_o) D(\omega_m)}{4 \cos\theta_o}\]Most terms cancel in the sample weight, leaving the Fresnel term and the ratio of the masking functions:
\[\displaystyle \frac{\rho(\omega_i, \omega_o) \cos\theta_i}{\text{pdf}(\omega_i)} = F\left(\langle\omega_o, \omega_m\rangle\right) \frac{G_2(\omega_o, \omega_i)}{G_1(\omega_o)}\]Reflected directions below the horizon (\(\omega_i.z \leq 0\)) are discarded (zero weight): together with the masking term, this is the energy lost by single scattering models, addressed in the multiple scattering section.
class BsdfRoughConductor : public Bsdf
{
public:
BsdfRoughConductor(const Color& eta, const Color& k, float ax, float ay) :
Bsdf(nullptr, BsdfType(GLOSSYREFLECTION | (ax != ay ? ANISOTROPIC : 0))), m_eta(eta), m_k(k), m_ggx{ax, ay} {}
Color eval( const Vector& wi, const Vector& wo, const vec2& uv ) const
{
if (wi.z <= 0 || wo.z <= 0) return Black();
Vector m = normalize(wi + wo);
Color F = FresnelConductor(dot(wo, m), m_eta, m_k);
return F * (m_ggx.D(m) * m_ggx.G2(wo, wi) / (4.f * wo.z * wi.z));
}
float pdf( const Vector& wi, const Vector& wo, const vec2& uv ) const
{
if (wi.z <= 0 || wo.z <= 0) return 0;
Vector m = normalize(wi + wo);
return m_ggx.G1(wo) * m_ggx.D(m) / (4.f * wo.z);
}
BsdfSample sample( Sampler& sampler, const Vector& wo, const vec2& uv ) const
{
BsdfSample bs;
float u = sampler.uniform(), v = sampler.uniform();
Vector m = m_ggx.sample(wo, u, v);
bs.wi = Reflect(wo, m);
if (wo.z <= 0 || bs.wi.z <= 0) { bs.pdf = 0; bs.weight = Black(); return bs; }
bs.pdf = pdf(bs.wi, wo, uv);
bs.weight = FresnelConductor(dot(wo, m), m_eta, m_k) * (m_ggx.G2(wo, bs.wi) / m_ggx.G1(wo));
return bs;
}
Color m_eta, m_k;
GGX m_ggx;
};
Rough dielectric
The rough dielectric adds refraction through the microfacets [Walter07]. The reflection part is the rough conductor with the dielectric Fresnel term, and the transmission part uses the generalized half vector \(\omega_m^t\). For radiance transport (light flowing from \(\omega_i\) to \(\omega_o\)), with the indices \(\eta_o\) and \(\eta_i\) on the side of each direction:
\[\displaystyle \rho_t(\omega_i, \omega_o) = \frac{\lvert\langle\omega_i, \omega_m\rangle\rvert \lvert\langle\omega_o, \omega_m\rangle\rvert}{\lvert\cos\theta_i\rvert \lvert\cos\theta_o\rvert} \frac{\eta_o^2 \left(1 - F\left(\langle\omega_o, \omega_m\rangle\right)\right) D(\omega_m) G_2(\omega_o, \omega_i)}{\left(\eta_i \langle\omega_i, \omega_m\rangle + \eta_o \langle\omega_o, \omega_m\rangle\right)^2}\]The \(\eta_o^2\) factor is the radiance scaling of the smooth dielectric. Replacing it by \(\eta_i^2\) gives the version for importance transport, and the model satisfies the generalized reciprocity \(\frac{\rho_t(\omega_i, \omega_o)}{\eta_o^2} = \frac{\rho_t(\omega_o, \omega_i)}{\eta_i^2}\). For sampling, we sample a visible normal, then choose the reflection with probability \(F\left(\langle\omega_o, \omega_m\rangle\right)\) or otherwise refract \(\omega_o\) through the microfacet. The density of the refracted direction uses the Jacobian of the refraction:
\[\displaystyle \text{pdf}_t(\omega_i) = \left(1 - F\right) D_{\omega_o}(\omega_m) \frac{\eta_i^2 \lvert\langle\omega_i, \omega_m\rangle\rvert}{\left(\eta_i \langle\omega_i, \omega_m\rangle + \eta_o \langle\omega_o, \omega_m\rangle\right)^2} \qquad \text{pdf}_r(\omega_i) = F \frac{D_{\omega_o}(\omega_m)}{4 \lvert\langle\omega_o, \omega_m\rangle\rvert}\]and the sample weights again simplify to the ratio of the masking functions, times the radiance scaling for transmission:
\[\displaystyle w_r = \frac{G_2(\omega_o, \omega_i)}{G_1(\omega_o)} \qquad w_t = \left(\frac{\eta_o}{\eta_i}\right)^2 \frac{G_2(\omega_o, \omega_i)}{G_1(\omega_o)}\]We use the same height-correlated \(G_2\) for reflection and transmission, as PBRT 4 does [Pharr23]; Heitz [Heitz14a] discusses the masking-shadowing functions of transmission in more detail.
The implementation flips the configuration when \(\omega_o\) is inside the object, so the GGX functions always see an outgoing direction in the upper hemisphere:
class BsdfRoughDielectric : public Bsdf
{
public:
BsdfRoughDielectric(Texture* albedo, float ax, float ay, float intIOR = 1.5f, float extIOR = 1.f) :
Bsdf(albedo, BsdfType(GLOSSYREFLECTION | GLOSSYTRANSMISSION | (ax != ay ? ANISOTROPIC : 0))),
m_ggx{ax, ay}, m_intIOR(intIOR), m_extIOR(extIOR) {}
Color eval( const Vector& wi, const Vector& wo, const vec2& uv ) const { float p; return evalPdf(wi, wo, uv, p); }
float pdf( const Vector& wi, const Vector& wo, const vec2& uv ) const { float p; evalPdf(wi, wo, uv, p); return p; }
// evaluates the BSDF and its pdf in one go, wo and wi on any side
Color evalPdf( const Vector& wi_, const Vector& wo_, const vec2& uv, float& pdf ) const
{
pdf = 0;
if (wo_.z == 0 || wi_.z == 0) return Black();
// flip so that wo is in the upper hemisphere
float s = wo_.z > 0 ? 1.f : -1.f;
Vector wo = s * wo_, wi = s * wi_;
float etaO = wo_.z > 0 ? m_extIOR : m_intIOR;
float etaI = wo_.z > 0 ? m_intIOR : m_extIOR;
bool reflection = wi.z > 0;
if (reflection) etaI = etaO;
Vector m = reflection ? normalize(wo + wi) : -normalize(etaO * wo + etaI * wi);
if (m.z < 0) m = -m;
// discard back-facing microfacets
if (dot(wo, m) <= 0 || dot(wi, m) * wi.z <= 0) return Black();
float F = FresnelDielectric(dot(wo, m), wo_.z > 0 ? m_extIOR / m_intIOR : m_intIOR / m_extIOR);
float D = m_ggx.D(m), G2 = m_ggx.G2(wo, wi), Dvis = m_ggx.Dvis(wo, m);
if (reflection)
{
pdf = F * Dvis / (4.f * dot(wo, m));
return Color(F * D * G2 / (4.f * wo.z * wi.z));
}
float om = dot(wo, m), im = dot(wi, m);
float denom = etaI * im + etaO * om;
denom *= denom;
pdf = (1.f - F) * Dvis * etaI * etaI * std::abs(im) / denom;
float ft = std::abs(im) * om / (wo.z * std::abs(wi.z)) * etaO * etaO * (1.f - F) * D * G2 / denom;
return (*m_albedo)(uv) * ft;
}
BsdfSample sample( Sampler& sampler, const Vector& wo_, const vec2& uv ) const
{
BsdfSample bs;
bs.pdf = 0; bs.weight = Black();
float s = wo_.z > 0 ? 1.f : -1.f;
Vector wo = s * wo_;
float eta = wo_.z > 0 ? m_extIOR / m_intIOR : m_intIOR / m_extIOR; // eta_o / eta_i
float u = sampler.uniform(), v = sampler.uniform(), w = sampler.uniform();
Vector m = m_ggx.sample(wo, u, v);
float F = FresnelDielectric(dot(wo, m), eta);
Vector wi;
Color tint(1.f);
if (w < F)
{
wi = Reflect(wo, m);
if (wi.z <= 0) return bs;
}
else
{
wi = Refract(eta, wo, m); // the arbitrary normal version
if (wi.z >= 0) return bs;
tint = (*m_albedo)(uv) * (eta * eta); // radiance scaling
}
bs.wi = s * wi;
bs.weight = tint * (m_ggx.G2(wo, wi) / m_ggx.G1(wo));
evalPdf(bs.wi, wo_, uv, bs.pdf);
return bs;
}
GGX m_ggx;
float m_intIOR, m_extIOR;
};
Refract(eta, wo, m) is the arbitrary normal version of the refraction function, with cosines measured against the micro-normal \(\omega_m\).
Rough diffuse
The stochastic rough diffuse model of Heitz and Dupuy [Heitz15] uses the same GGX microsurface with Lambertian microfacets. Its evaluation has no closed form: it is estimated stochastically by sampling a visible microfacet and the light paths bouncing on the microsurface, which also accounts for inter-reflections between microfacets. It naturally supports anisotropy and is consistent with the rough conductor and dielectric for the same roughness parameters.
| Rough diffuse (stochastic) | Rough conductor | Rough dielectric |
|---|---|---|
![]() |
![]() |
![]() |
Rough plastic
The rough plastic replaces the smooth coating by a rough dielectric interface: the specular lobe becomes the reflection part of the rough dielectric, and the diffuse base is seen through the rough coating. The exact light transport through a rough layer requires a stochastic evaluation [Heitz16], so practical models instead couple the two lobes through the energy left by the specular lobe, following Kelemen and Szirmay-Kalos [Kelemen01]. Let \(E_s(\mu)\) be the albedo of the specular lobe for an outgoing direction with \(\cos\theta_o = \mu\), and \(\bar E_s = 2\int_0^1 E_s(\mu)\mu\mathrm{d}\mu\) its average:
\[\displaystyle E_s(\mu_o) = \int_{\Omega} \rho_s(\omega_i, \omega_o) \cos\theta_i \mathrm{d}\omega_i\]The diffuse lobe is then weighted by the energy that crosses the coating in each direction:
\[\displaystyle \rho(\omega_i, \omega_o) = \rho_s(\omega_i, \omega_o) + \frac{\left(1 - E_s(\mu_i)\right)\left(1 - E_s(\mu_o)\right)}{1 - \bar E_s} \frac{\left(1 - \bar F_{int}\right) \rho}{\pi \left(1 - \rho \bar F_{int}\right)}\]With this normalization a white base is exactly energy conserving (the energy reflected by the coating and the diffuse albedo sum to one for every outgoing direction), and the model reduces to the smooth plastic when the roughness goes to zero, since then \(1 - \bar F_{int} = \frac{1 - \bar F_{ext}}{\eta^2}\). One cannot simply reuse the smooth plastic formula with the rough Fresnel transmittances: the average albedo of a rough coating is smaller than the smooth one (about 0.05 instead of 0.09 for \(\alpha = 0.4\) and \(\eta = 1.5\)), and the model would create energy. The specular albedo \(E_s\) depends on the roughness, the IOR and the angle; it is precomputed in a small table (e.g. \(32 \times 32\) entries over \(\mu\) and \(\alpha\) for a fixed IOR) by Monte Carlo integration with the VNDF sampling routine:
// albedo of the rough dielectric reflection lobe, eta = eta_o / eta_i
static float SpecularAlbedo(const GGX& ggx, float eta, float mu, int n = 4096)
{
Vector wo(std::sqrt(1.f - mu * mu), 0.f, mu);
float sum = 0;
for (int k = 0; k < n; ++k)
{
float u = (k + 0.5f) / n, v = std::fmod(k * 0.618034f, 1.f); // any stratified 2D sequence
Vector m = ggx.sample(wo, u, v);
Vector wi = Reflect(wo, m);
if (wi.z > 0) sum += FresnelDielectric(dot(wo, m), eta) * ggx.G2(wo, wi) / ggx.G1(wo);
}
return sum / n;
}
The class has the same structure as the plastic: eval returns the sum of both lobes, and sample chooses the specular lobe with probability \(P_s = \frac{E_s(\mu_o)}{E_s(\mu_o) + \left(1 - E_s(\mu_o)\right)\bar\rho}\). Since both lobes are now continuous, the sample weight and multiple importance sampling use the mixture of both densities, whichever lobe generated the direction:
\[\displaystyle \text{pdf}(\omega_i) = P_s \frac{G_1(\omega_o) D(\omega_m)}{4\cos\theta_o} + \left(1 - P_s\right) \frac{\cos\theta_i}{\pi} \qquad \text{weight} = \frac{\rho(\omega_i, \omega_o) \cos\theta_i}{\text{pdf}(\omega_i)}\]Multiple scattering
Classic scattering models account only for one bounce on the surface, although in the real world we can observe inter-reflections between microfacets. The main idea behind multiple scattering models is to add an energy compensation term that accounts for the lost energy. The scattering model becomes :
\[\displaystyle \rho(\omega_o, \omega_i) = \rho_{ss}(\omega_o, \omega_i) + \rho_{ms}(\omega_o, \omega_i)\]We won’t derive existing multiple scattering models here but instead refer to the original articles that are recent and well-explained:
- the approach from Eric Heitz et al. [Heitz16] which performs a stochastic random walk on the microsurface.
- the approach from Christopher Kulla and Alejandro Conty [Kulla17]
- the approach from Emmanuel Turquin [Turquin19]
These approaches have different trade-offs:
- Explicitly simulating the light path on the microsurface [Heitz16]: no precomputation and ground truth, but more involved code and a slow, stochastic evaluation.
- Adding a second, diffuse-like lobe \(\rho_{ss} + \rho_{ms}\) [Kulla17]: a precomputed table, fast to evaluate.
- Scaling the single scattering lobe \((1 + k)\rho_{ss}\) [Turquin19]: a precomputed table and the simplest to implement, but the scaling factor depends on \(\omega_o\) only, which breaks the reciprocity of the BSDF.
For the second approach, Kulla and Conty precompute the directional albedo of the single scattering lobe without Fresnel (\(F = 1\)) and its average:
\[\displaystyle E(\mu_o) = \int_{\Omega} \rho_{ss}(\omega_i, \omega_o)\big\vert_{F=1} \cos\theta_i \mathrm{d}\omega_i \qquad E_{avg} = 2 \int_0^1 E(\mu) \mu \mathrm{d}\mu\]and define a reciprocal lobe that carries exactly the missing energy \(1 - E(\mu_o)\):
\[\displaystyle \rho_{ms}(\omega_i, \omega_o) = \frac{\left(1 - E(\mu_o)\right)\left(1 - E(\mu_i)\right)}{\pi \left(1 - E_{avg}\right)}\]Since \(\int (1 - E(\mu_i)) \cos\theta_i \mathrm{d}\omega_i = \pi (1 - E_{avg})\), the sum \(\rho_{ss} + \rho_{ms}\) passes the white furnace test exactly. With a Fresnel term, each additional bounce on the microsurface is attenuated, and the multiple scattering lobe is scaled by a factor that sums the geometric series of the bounces with the average Fresnel reflectance \(F_{avg} = 2\int_0^1 F(\mu)\mu\mathrm{d}\mu\):
\[\displaystyle F_{ms} = \frac{F_{avg}^2 E_{avg}}{1 - F_{avg}\left(1 - E_{avg}\right)}\]For conductors \(F_{avg}\) is a color, and this term produces the color saturation observed on rough metals. \(E(\mu)\) is tabulated over \((\mu, \alpha)\) with the SpecularAlbedo function of the previous section without its Fresnel term, and the extra lobe is sampled as a diffuse (cosine-weighted) lobe. Kulla and Conty also extend the approach to dielectrics, where the energy is split between reflection and transmission; see their course notes.

| Rough diffuse | Rough conductor | Rough dielectric | |
|---|---|---|---|
| Single Scattering | ![]() |
![]() |
![]() |
| Approximate energy compensation | ![]() |
![]() |
![]() |
Mix BSDF
The mix BSDF linearly blends two BSDFs \(\rho_a\) and \(\rho_b\) with a (textured) weight \(t \in [0,1]\), for instance to paint rust on a metal or dust on a plastic:
\[\displaystyle \rho(\omega_i, \omega_o) = (1 - t) \rho_a(\omega_i, \omega_o) + t \rho_b(\omega_i, \omega_o)\]A convex combination of energy conserving BSDFs is energy conserving. For sampling, we choose one of the two BSDFs with probability \(t\) and sample a direction from it; its density is the mixture \(\text{pdf} = (1 - t)\, \text{pdf}_a + t\, \text{pdf}_b\). A Dirac sample is weighted with the discrete probability of choosing its lobe, as for the plastic model.
class BsdfMix : public Bsdf
{
public:
BsdfMix(Bsdf* a, Bsdf* b, Texture* t) : Bsdf(t, BsdfType(a->m_type | b->m_type)), m_a(a), m_b(b) {}
float weight( const vec2& uv ) const { return average((*m_albedo)(uv)); } // the mix texture
Color eval( const Vector& wi, const Vector& wo, const vec2& uv ) const
{
float t = weight(uv);
return (1.f - t) * m_a->eval(wi, wo, uv) + t * m_b->eval(wi, wo, uv);
}
float pdf( const Vector& wi, const Vector& wo, const vec2& uv ) const
{
float t = weight(uv);
return (1.f - t) * m_a->pdf(wi, wo, uv) + t * m_b->pdf(wi, wo, uv);
}
BsdfSample sample( Sampler& sampler, const Vector& wo, const vec2& uv ) const
{
float t = weight(uv);
bool pickB = sampler.uniform() < t;
const Bsdf* chosen = pickB ? m_b : m_a;
BsdfSample bs = chosen->sample(sampler, wo, uv);
if (chosen->isDelta())
{
// Dirac sample: only the chosen BSDF can produce this direction,
// the mix weight and the selection probability cancel out in the sample weight
bs.pdf *= pickB ? t : 1.f - t;
return bs;
}
bs.pdf = pdf(bs.wi, wo, uv);
bs.weight = bs.pdf > 0 ? eval(bs.wi, wo, uv) * std::abs(bs.wi.z) / bs.pdf : Black();
return bs;
}
Bsdf *m_a, *m_b;
};
The albedo texture of the base class stores the mix weight. When one of the BSDFs has both Dirac and continuous lobes (such as the plastic), BsdfSample must return the sampled lobe to apply the same logic per lobe.
Production principled BSDF
“One model to rule them all”
The Disney principled BRDF [Burley12] and its BSDF extension [Burley15] made popular the idea of a single über-shader driven by a few intuitive parameters in \([0,1]\) rather than physical quantities, robust at extreme values and plausible for all combinations. Its descendants, Autodesk Standard Surface [Georgiev19] and the Adobe Standard Material [Kutz21], have since converged into OpenPBR, now the common reference for offline rendering, while glTF covers real-time rendering.
OpenPBR Surface
OpenPBR Surface [OpenPBR] is an open specification hosted by the Academy Software Foundation as part of MaterialX, with a first version released in 2024. Rather than a sum of lobes, it describes the physical structure of the material: slabs (an interface BSDF over an optional medium) combined by two operations:
- mix, a horizontal blend of two materials with a coverage weight \(w\), implemented as a linear blend of their BSDFs, \(f_{mix} = (1 - w) f_0 + w f_1\);
- layer, a coat deposited on a substrate. The specification leaves the light transport between layers to the implementation; the common albedo scaling approximation adds the coat lobe and attenuates the substrate by the energy the coat does not reflect, \(f_{layer}(\omega_i, \omega_o) = f_{coat}(\omega_i, \omega_o) + \left(1 - E_{coat}(\omega_o)\right) f_{sub}(\omega_i, \omega_o)\), with \(E_{coat}\) the directional albedo of the coat (tabulated or estimated). It conserves energy, and is lossless when the substrate is.
The material is then the following tree, where every operation has a weight parameter (fuzz, coat, metalness, transmission and subsurface weights), and the whole surface is finally mixed with the ambient medium by the geometry opacity:
\[\displaystyle \begin{aligned} \text{surface} &= \textbf{layer}\left(\text{coated base},\ \text{fuzz}\right) \\ \text{coated base} &= \textbf{layer}\left(\text{base},\ \text{coat}\right) \\ \text{base} &= \textbf{mix}\left(\text{dielectric base},\ \text{metal}\right) \\ \text{dielectric base} &= \textbf{mix}\left(\text{opaque base},\ \text{transmission}\right) \\ \text{opaque base} &= \textbf{mix}\left(\text{glossy-diffuse},\ \text{subsurface}\right) \\ \text{glossy-diffuse} &= \textbf{layer}\left(\text{diffuse},\ \text{gloss}\right) \end{aligned}\]- metal: a GGX conductor whose Fresnel factor is the F82-tint model [Kutz21], the Lazanyi - Schlick form of the Fresnel section parameterized by the base color at normal incidence and a specular color near grazing angles;
- gloss and transmission: a GGX dielectric interface with an IOR, over the diffuse base or over a semi-infinite dielectric medium;
- diffuse: an energy-preserving Oren-Nayar model, EON [Portsmouth24];
- subsurface: a dielectric interface over a semi-infinite scattering medium (next section);
- coat: a GGX dielectric interface over a medium, whose internal reflections darken and saturate the base;
- fuzz: a layer of micro-fibers on top of everything (dust, peach fuzz, cloth);
- thin film: an optional thin dielectric film on the base, producing iridescence [Belcour17].
Blender Principled BSDF
Blender’s Principled BSDF [Blender] is based on OpenPBR: its base layer mixes metal, diffuse, subsurface and transmission components, under an optional glossy coat and a sheen layer, with the emission below the coat and sheen. Its parameters follow OpenPBR closely, and its manual is a practical companion to the specification.
glTF metallic-roughness
The glTF 2.0 material [glTF] is the cheap, real-time option. With \(\alpha = \text{roughness}^2\), \(\rho_{spec}\) the GGX microfacet BRDF without its Fresnel factor, and \(F_S = \left(1 - \lvert\langle\omega_o, \omega_m\rangle\rvert\right)^5\) the Schlick weight:
\[\displaystyle \begin{aligned} \rho_{metal} &= \rho_{spec} \left(\text{baseColor} + (1 - \text{baseColor}) F_S\right) \\ \rho_{dielectric} &= \text{lerp}\left(\frac{\text{baseColor}}{\pi},\ \rho_{spec},\ 0.04 + 0.96\, F_S\right) \\ \rho &= \text{lerp}\left(\rho_{dielectric},\ \rho_{metal},\ \text{metallic}\right) \end{aligned}\]The dielectric is a Fresnel mix with a fixed IOR of 1.5 (\(F_0 = 0.04\)): simple and cheap, although the specification notes that this coupling does not conserve energy. Extensions add the missing layers and parameters [glTFext]: KHR_materials_clearcoat, sheen, specular, ior, transmission, volume, iridescence, anisotropy, dispersion and emissive_strength are ratified, and diffuse_transmission is a release candidate.
Sampling
Once the layers are approximated, all these models are weighted sums of lobes. A common strategy picks one lobe with a probability proportional to its approximate albedo, samples a direction from it (cosine-weighted, GGX VNDF, …), and returns the mixture of all the lobe densities as the pdf, as for the rough plastic, so that light sampling can be combined by multiple importance sampling.
Subsurface scattering
In translucent materials such as skin, marble, milk or wax, the light enters the object, scatters many times inside, and exits at another point. The BSDF assumption that light leaves the surface where it arrived no longer holds, and the scattering is described by a bidirectional scattering surface reflectance distribution function (BSSRDF) \(S(p_i, \omega_i, p_o, \omega_o)\), integrated over the surface of the object as well:
\[\displaystyle L_o(p_o, \omega_o) = \int_A \int_{\Omega} S(p_i, \omega_i, p_o, \omega_o) L_i(p_i, \omega_i) \cos\theta_i \mathrm{d}\omega_i \mathrm{d}A(p_i)\]The methods evolved from analytic profiles to the brute force simulation of the light inside the object.
Diffusion profiles. For highly scattering materials, diffusion theory approximates well the multiple scattering inside a semi-infinite slab, which leads to radially symmetric profiles \(R(r)\) depending only on the distance \(r = \lVert p_o - p_i \rVert\): the dipole of Jensen et al. [Jensen01] and its successors, such as quantized diffusion [dEon11], more accurate near the point of illumination and for absorbing materials. Habel et al. [Habel13b] review classical and improved diffusion theory and the resulting dipoles. The BSSRDF is then separated into a Fresnel transmission at each point and the profile, \(S \approx \frac{1}{\pi} \left(1 - F(\theta_i)\right) R(\lVert p_o - p_i \rVert) \left(1 - F(\theta_o)\right)\) (up to a normalization of the directional terms). Christensen and Burley [Christensen15] observed that a sum of two exponentials, the normalized diffusion profile, fits very well the profiles computed by brute force Monte Carlo simulation:
\[\displaystyle R(r) = A \frac{s \left(e^{-sr} + e^{-sr/3}\right)}{8 \pi r}\]where \(A\) is the surface albedo and \(s\) a scaling factor that sets the width of the profile, related to the mean free path by empirical fits of \(A\) given in their technical memo. The profile integrates to \(A\) over the plane, and the radial density \(2\pi r \frac{R(r)}{A} = \frac{1}{4} s e^{-sr} + \frac{3}{4} \frac{s}{3} e^{-sr/3}\) is a mixture of two exponential distributions, trivial to importance sample:
// sample a radius of the normalized diffusion profile, pdf(r) = (s e^{-s r} + s e^{-s r / 3}) / 4
static float SampleBurleyRadius(float s, float u1, float u2)
{
float d = u1 < 0.25f ? 1.f / s : 3.f / s; // pick one of the two exponentials
return -d * std::log(1.f - u2);
}
A point \(p_i\) is then found by sampling an angle around \(p_o\) and tracing probe rays towards the surface along one of the axes of the local frame (with multiple importance sampling between the three axes); see [Pharr16] Chapter 15 for a complete implementation of diffusion based subsurface scattering.
Photon beam diffusion. Profiles assume that the light enters at a single point. Photon beam diffusion [Habel13a] treats the refracted light as a continuous beam inside the medium, integrates the diffusion contributions of the points along the beam with Monte Carlo sampling, and adds the single scattering along it: a hybrid between analytic diffusion and Monte Carlo simulation.
Path-traced random walks. Efficient unbiased volume rendering makes it practical to simulate the light transport inside the object as a homogeneous participating medium, the random walk subsurface scattering [Chiang16]. The path enters the object through the dielectric boundary, then repeatedly samples a free flight distance \(t = -\frac{\ln(1 - u)}{\sigma_t}\) and scatters with the single scattering albedo \(\frac{\sigma_s}{\sigma_t}\) and a phase function (next section), until it crosses the boundary again. It handles thin geometry, concave shapes and directional effects that diffusion profiles miss, at the cost of longer paths. Artists still control the appearance with a surface color and a scattering distance, from which the medium coefficients are computed with fitted inversions of the multiple scattering albedo [Chiang16]. Wrenninge et al. [Wrenninge17] add anisotropic phase functions and non-exponential free flights to control how far the light bleeds, and Bitterli et al. [Bitterli18] give the radiative transfer framework for such non-exponential media.
Recent improvements. Random walks are long in dense media, which motivates better sampling: a zero-variance-based scheme derived from Dwivedi’s importance biasing steers the walk back towards the surface [Krivanek14], and learned models sample the exit point directly from a network trained on path-traced data that accounts for the local shape of the object [Vicini19].
In production. Maximilian Tarpini’s Rombo Tools development blog [Tarpini] documents the subsurface shaders of an Arnold plugin and many practical tricks along the way: the standard, better and directional dipoles, a random walk that combines previous sampling strategies, a three-layer skin model, and later improvements such as plain random walks instead of Dwivedi guiding for indirect rays, similarity theory for highly anisotropic media and the approximate Mie phase function of the next section [Jendersie23]. The blog covers many other topics of material rendering as well.
Phase functions
Phase functions are the BSDFs of participating media (fog, clouds, smoke, or the inside of a subsurface object): they describe the angular distribution of the light scattered by a particle, and are flagged with PHASE in the BsdfType enumeration. They differ from surface BSDFs in two ways:
- they are defined over the whole sphere of directions and normalized, \(\int_{S^2} p(\omega_i, \omega_o) \mathrm{d}\omega_i = 1\), the albedo of the medium being handled separately,
- there is no cosine term: the integrator must not multiply the phase function by \(\lvert\cos\theta_i\rvert\) (hence the
isPhasetest), and the sample weight is \(\frac{p}{\text{pdf}}\).
Phase functions usually only depend on the angle between the propagation directions. With our convention both \(\omega_i\) and \(\omega_o\) point away from the scattering point: the light arrives travelling along \(-\omega_i\) and leaves along \(\omega_o\), so the scattering angle \(\theta\) is given by \(\cos\theta = -\langle\omega_i, \omega_o\rangle\). \(\cos\theta = 1\) is forward scattering, \(\cos\theta = -1\) is back scattering.
Isotropic. The light is scattered uniformly in all directions, \(p = \frac{1}{4\pi}\), and the directions are sampled uniformly on the sphere.
Henyey-Greenstein. The most used phase function in rendering [Henyey41] has a single parameter \(g \in (-1, 1)\), its mean cosine \(g = \int p \cos\theta \mathrm{d}\omega\): \(g > 0\) for forward scattering, \(g < 0\) for back scattering, and \(g = 0\) is isotropic.
\[\displaystyle p_{HG}(\theta) = \frac{1}{4\pi} \frac{1 - g^2}{\left(1 + g^2 - 2g\cos\theta\right)^{3/2}}\]Its cumulative distribution inverts analytically, which gives perfect importance sampling (sample weight 1):
\[\displaystyle \cos\theta = \frac{1}{2g} \left(1 + g^2 - \left(\frac{1 - g^2}{1 - g + 2g u}\right)^2\right) \qquad \text{for } g \neq 0\]class PhaseHG : public Bsdf
{
public:
PhaseHG(float g) : Bsdf(nullptr, PHASE), m_g(g) {}
float hg( float cosTheta ) const
{
float d = 1.f + m_g * m_g - 2.f * m_g * cosTheta;
return INV_PI * 0.25f * (1.f - m_g * m_g) / (d * std::sqrt(d));
}
Color eval( const Vector& wi, const Vector& wo, const vec2& uv ) const { return Color(hg(-dot(wi, wo))); }
float pdf( const Vector& wi, const Vector& wo, const vec2& uv ) const { return hg(-dot(wi, wo)); }
BsdfSample sample( Sampler& sampler, const Vector& wo, const vec2& uv ) const
{
float u = sampler.uniform(), v = sampler.uniform();
float cosTheta;
if (std::abs(m_g) < 1e-3f) cosTheta = 1.f - 2.f * u;
else
{
float s = (1.f - m_g * m_g) / (1.f - m_g + 2.f * m_g * u);
cosTheta = (1.f + m_g * m_g - s * s) / (2.f * m_g);
}
float sinTheta = std::sqrt(std::max(0.f, 1.f - cosTheta * cosTheta));
float phi = 2.f * (float) M_PI * v;
// the light leaves along wo: build a frame around it, forward scattering gives wi = -wo
Vector d = wo, t, b;
BuildOrthonormalBasis(d, t, b); // e.g. [Duff17]
BsdfSample bs;
bs.wi = -(cosTheta * d + sinTheta * (std::cos(phi) * t + std::sin(phi) * b));
bs.pdf = hg(cosTheta);
bs.weight = Color(1.f);
return bs;
}
float m_g;
};
Remember that \(\omega_i\) points towards where the light comes from: a forward scattering event (\(\cos\theta = 1\)) gives \(\omega_i = -\omega_o\), the path continuing straight ahead. Phase functions are not expressed in the local frame of a surface; the directions are in world space.
Combinations and fits. A single HG lobe cannot reproduce both a strong forward peak and some back scattering; a common solution is a mix of two HG lobes \(p = (1 - w) p_{HG}(g_1) + w\, p_{HG}(g_2)\) with \(g_1 > 0 > g_2\), sampled like the mix BSDF. Draine’s phase function [Draine03] generalizes HG with an additional parameter \(\alpha\) (and is normalized for any \(g\) and \(\alpha\)):
\[\displaystyle p_D(\theta) = \frac{1}{4\pi} \frac{1 - g^2}{\left(1 + g^2 - 2g\cos\theta\right)^{3/2}} \frac{1 + \alpha\cos^2\theta}{1 + \alpha\left(1 + 2g^2\right)/3}\]With \(\alpha = 1\) it is the Cornette-Shanks phase function, often used for the Mie scattering of aerosols. For water droplets (fog and clouds), the Lorenz-Mie theory gives the exact phase function, with a very strong forward peak and a characteristic glory and fogbow. It can be tabulated and sampled by numerical inversion of its CDF, or approximated: Jendersie and d’Eon [Jendersie23] fit it with a blend of an HG and a Draine lobe whose parameters only depend on the droplet diameter: the fit is analytic, easy to sample, and much closer to the reference than a single HG lobe.
References
- [Duff17] T. Duff, J. Burgess, P. Christensen, C. Hery, A. Kensler, M. Liani, R. Villemin, Building an Orthonormal Basis, Revisited, Journal of Computer Graphics Techniques 6(1), 2017.
- [Pharr16] M. Pharr, W. Jakob, G. Humphreys, Physically Based Rendering: From Theory to Implementation, 3rd edition, Morgan Kaufmann, 2016.
- [Heitz14a] E. Heitz, Understanding the Masking-Shadowing Function in Microfacet-Based BRDFs, Journal of Computer Graphics Techniques 3(2), 2014.
- [Heitz15] E. Heitz, J. Dupuy, Implementing a Simple Anisotropic Rough Diffuse Material with Stochastic Evaluation, technical report, 2015.
- [Oren94] M. Oren, S. K. Nayar, Generalization of Lambert’s Reflectance Model, SIGGRAPH 1994.
- [Lazanyi05] I. Lazányi, L. Szirmay-Kalos, Fresnel Term Approximations for Metals, International Conference in Central Europe on Computer Graphics (WSCG) 2005.
- [Lagarde13] S. Lagarde, Memo on Fresnel Equations, blog post, 2013.
- [Hoffman19] N. Hoffman, Fresnel Equations Considered Harmful, Eurographics Workshop on Material Appearance Modeling 2019.
- [Schlick94] C. Schlick, An Inexpensive BRDF Model for Physically-based Rendering, Computer Graphics Forum 13(3) (Eurographics), 1994.
- [Veach97] E. Veach, Robust Monte Carlo Methods for Light Transport Simulation, PhD thesis, Stanford University, 1997.
- [Pharr23] M. Pharr, W. Jakob, G. Humphreys, Physically Based Rendering: From Theory to Implementation, 4th edition, MIT Press, 2023.
- [Trowbridge75] T. S. Trowbridge, K. P. Reitz, Average Irregularity Representation of a Rough Surface for Ray Reflection, Journal of the Optical Society of America 65(5), 1975.
- [Walter07] B. Walter, S. R. Marschner, H. Li, K. E. Torrance, Microfacet Models for Refraction through Rough Surfaces, Eurographics Symposium on Rendering 2007.
- [Heitz14b] E. Heitz, E. d’Eon, Importance Sampling Microfacet-Based BSDFs using the Distribution of Visible Normals, Computer Graphics Forum 33(4) (EGSR), 2014.
- [Heitz18] E. Heitz, Sampling the GGX Distribution of Visible Normals, Journal of Computer Graphics Techniques 7(4), 2018.
- [Dupuy23] J. Dupuy, A. Benyoub, Sampling Visible GGX Normals with Spherical Caps, Computer Graphics Forum 42(8) (High-Performance Graphics), 2023.
- [Jakob14] W. Jakob, An Improved Visible Normal Sampling Routine for the Beckmann Distribution, technical report, 2014.
- [dEon23] E. d’Eon, Student-T and Beyond: Practical Tools for Multiple-Scattering BSDFs with General NDFs, SIGGRAPH Talks 2023.
- [Heitz16] E. Heitz, J. Hanika, E. d’Eon, C. Dachsbacher, Multiple-Scattering Microfacet BSDFs with the Smith Model, ACM Transactions on Graphics 35(4) (SIGGRAPH), 2016.
- [Kulla17] C. Kulla, A. Conty, Revisiting Physically Based Shading at Imageworks, SIGGRAPH Course: Physically Based Shading in Theory and Practice, 2017.
- [Turquin19] E. Turquin, Practical Multiple Scattering Compensation for Microfacet Models, technical report, Industrial Light & Magic, 2019.
- [Kelemen01] C. Kelemen, L. Szirmay-Kalos, A Microfacet Based Coupled Specular-Matte BRDF Model with Importance Sampling, Eurographics Short Presentations 2001.
- [Burley12] B. Burley, Physically-Based Shading at Disney, SIGGRAPH Course: Practical Physically-Based Shading in Film and Game Production, 2012.
- [Burley15] B. Burley, Extending the Disney BRDF to a BSDF with Integrated Subsurface Scattering, SIGGRAPH Course: Physically Based Shading in Theory and Practice, 2015.
- [OpenPBR] Z. Andersson, P. Edmondson, J. Guertault, A. Herubel, A. King, P. Kutz, A. Machizaud, J. Portsmouth, F. Servant, J. Stone, OpenPBR Surface Specification, Academy Software Foundation, 2024.
- [Georgiev19] I. Georgiev, J. Portsmouth, Z. Andersson, A. Herubel, A. King, S. Ogaki, F. Servant, Autodesk Standard Surface, Autodesk white paper, 2019.
- [Kutz21] P. Kutz, M. Hašan, P. Edmondson, Novel Aspects of the Adobe Standard Material, Adobe white paper, 2021.
- [Portsmouth24] J. Portsmouth, P. Kutz, S. Hill, EON: A Practical Energy-Preserving Rough Diffuse BRDF, arXiv preprint, 2024.
- [Belcour17] L. Belcour, P. Barla, A Practical Extension to Microfacet Theory for the Modeling of Varying Iridescence, ACM Transactions on Graphics 36(4) (SIGGRAPH), 2017.
- [Blender] Blender Foundation, Principled BSDF, Blender Manual.
- [glTF] The Khronos Group, glTF 2.0 Specification, Appendix B: BRDF Implementation.
- [glTFext] The Khronos Group, glTF Extension Registry,
KHR_materials_*extensions. - [Jensen01] H. W. Jensen, S. R. Marschner, M. Levoy, P. Hanrahan, A Practical Model for Subsurface Light Transport, SIGGRAPH 2001.
- [Christensen15] P. H. Christensen, B. Burley, Approximate Reflectance Profiles for Efficient Subsurface Scattering, Pixar Technical Memo 15-04, 2015.
- [Chiang16] M. J.-Y. Chiang, P. Kutz, B. Burley, Practical and Controllable Subsurface Scattering for Production Path Tracing, SIGGRAPH Talks 2016.
- [dEon11] E. d’Eon, G. Irving, A Quantized-Diffusion Model for Rendering Translucent Materials, ACM Transactions on Graphics 30(4) (SIGGRAPH), 2011.
- [Habel13a] R. Habel, P. H. Christensen, W. Jarosz, Photon Beam Diffusion: A Hybrid Monte Carlo Method for Subsurface Scattering, Computer Graphics Forum 32(4) (EGSR), 2013.
- [Habel13b] R. Habel, P. H. Christensen, W. Jarosz, Classical and Improved Diffusion Theory for Subsurface Scattering, technical report, Disney Research, 2013.
- [Wrenninge17] M. Wrenninge, R. Villemin, C. Hery, Path Traced Subsurface Scattering using Anisotropic Phase Functions and Non-Exponential Free Flights, Pixar Technical Memo 17-07, 2017.
- [Bitterli18] B. Bitterli, S. Ravichandran, T. Müller, M. Wrenninge, J. Novák, S. Marschner, W. Jarosz, A Radiative Transfer Framework for Non-Exponential Media, ACM Transactions on Graphics 37(6) (SIGGRAPH Asia), 2018.
- [Krivanek14] J. Křivánek, E. d’Eon, A Zero-Variance-Based Sampling Scheme for Monte Carlo Subsurface Scattering, SIGGRAPH Talks 2014.
- [Vicini19] D. Vicini, V. Koltun, W. Jakob, A Learned Shape-Adaptive Subsurface Scattering Model, ACM Transactions on Graphics 38(4) (SIGGRAPH), 2019.
- [Tarpini] M. Tarpini, Rombo Tools development blog, 2017–2026.
- [Henyey41] L. G. Henyey, J. L. Greenstein, Diffuse Radiation in the Galaxy, The Astrophysical Journal 93, 1941.
- [Draine03] B. T. Draine, Scattering by Interstellar Dust Grains. I. Optical and Ultraviolet, The Astrophysical Journal 598(2), 2003.
- [Jendersie23] J. Jendersie, E. d’Eon, An Approximate Mie Scattering Function for Fog and Cloud Rendering, SIGGRAPH Talks 2023.
























