Introduction
Filament implements a physically based rendering (PBR) system that provides accurate material representation and light interaction. This document explains the theory and equations behind the implementation.This content is derived from Filament’s official PBR documentation, which provides comprehensive details on the rendering equations.
Why Physically Based Rendering?
From Filament.md.html:56-60:Physically based rendering is a rendering method that provides a more accurate representation of materials and how they interact with light when compared to traditional real-time models. The separation of materials and lighting at the core of the PBR method makes it easier to create realistic assets that look accurate in all lighting conditions.
Core Principles
Filament’s PBR implementation is guided by these principles:Real-time Mobile Performance
Optimized for OpenGL ES 3.x class GPUs while maintaining quality.
Quality
Emphasis on overall picture quality with acceptable compromises for performance.
Ease of Use
Simple, intuitive parameters that produce physically plausible results.
Physical Units
Uses real-world units: meters, Kelvin, lumens, candelas.
The BRDF Model
Surface Response Equation
The complete surface response is expressed as: Where:- is the diffuse component (subsurface scattering)
- is the specular component (surface reflection)
- is the view direction
- is the light direction
Microfacet Theory
From Filament.md.html:133-138:A microfacet BRDF states that surfaces are not smooth at a micro level, but made of a large number of randomly aligned planar surface fragments, called microfacets.
- Low roughness → Aligned facets → Sharp reflections
- High roughness → Random facets → Blurred reflections
Specular BRDF (Cook-Torrance)
The specular term uses the Cook-Torrance approximation: This equation has three key terms:1. Normal Distribution Function (D)
Filament uses the GGX distribution for realistic highlights: Implementation from Filament.md.html:222-227:2. Geometric Shadowing (G)
The Smith-GGX visibility function accounts for microfacet masking and shadowing: Filament uses an optimized approximation:Filament.md.html:335-340
3. Fresnel Term (F)
The Schlick approximation models how reflectance changes with view angle: Implementation:Filament.md.html:367-370
The Fresnel effect explains why water appears transparent when viewed straight down but reflective at grazing angles.
Diffuse BRDF
Filament uses a Lambertian diffuse model for efficiency: Where is the diffuse reflectance (albedo).Filament.md.html:403-407
Why not a more complex diffuse model?
Why not a more complex diffuse model?
From Filament.md.html:411-413:
Given our constraints we decided that the extra runtime cost does not justify the slight increase in quality. This sophisticated diffuse model also renders image-based and spherical harmonics more difficult to express and implement.The Lambertian model provides good results at minimal cost, which is crucial for mobile performance.
Material Types
Dielectrics vs Conductors
From Filament.md.html:179-192:- Dielectrics (Non-metals)
- Conductors (Metals)
- Have both diffuse and specular components
- Light penetrates surface and scatters internally
- Achromatic specular reflectance
- Examples: plastic, wood, water, glass
Energy Conservation
From Filament.md.html:197-199:Energy conservation states that the total amount of specular and diffuse reflectance energy is less than the total amount of incident energy.This ensures materials behave physically correctly without manual artist adjustment.
Energy Compensation
The Cook-Torrance BRDF loses energy at high roughness due to single-scattering approximation. Filament adds a compensation term: Implementation:Filament.md.html:588-591
Complete BRDF Implementation
Here’s the full GLSL implementation:Filament.md.html:456-501
Material Parameters
Standard Parameters
| Parameter | Type | Range | Description |
|---|---|---|---|
| baseColor | RGB | [0..1] | Diffuse albedo for dielectrics, specular color for metals |
| metallic | Scalar | [0..1] | 0 = dielectric, 1 = conductor |
| roughness | Scalar | [0..1] | 0 = smooth/glossy, 1 = rough/matte |
| reflectance | Scalar | [0..1] | Fresnel reflectance at normal incidence (dielectrics only) |
Roughness Remapping
Filament remaps roughness for perceptual linearity: From Filament.md.html:740-753:Without this remapping, shiny metallic surfaces would have to be confined to a very small range between 0.0 and 0.05.
Reflectance to F0 Conversion
For dielectrics: This maps reflectance=0.5 to f0=4%, which is typical for common dielectrics.Common Material Values
Dielectric Reflectance
| Material | Reflectance | IOR | Linear Value |
|---|---|---|---|
| Water | 2% | 1.33 | 0.35 |
| Plastic, glass | 4-5% | 1.5-1.58 | 0.5-0.56 |
| Common gems | 5-16% | 1.58-2.33 | 0.56-1.0 |
Metal F0 Colors (sRGB)
| Metal | F0 (sRGB) | Hex |
|---|---|---|
| Silver | (0.97, 0.96, 0.91) | #f7f4e8 |
| Aluminum | (0.91, 0.92, 0.92) | #e8eaea |
| Gold | (1.00, 0.85, 0.57) | #ffd891 |
| Copper | (0.97, 0.74, 0.62) | #f7bc9e |
Validation Techniques
White Furnace Test
A purely reflective metallic surface (f0 = 1) in a white uniform environment should be indistinguishable from the background at all roughness levels when energy is conserved.Best Practices
Use Physical Values
Use Physical Values
Stick to physically plausible parameter ranges:
- Dielectric baseColor: 50-240 sRGB (strict) or 30-240 (tolerant)
- Metallic: close to 0 or 1 (not intermediate values)
- Reflectance: 0.35-1.0 (never below 0.35)
Author in Linear Space
Author in Linear Space
Clamp Roughness
Clamp Roughness
Clamp roughness to avoid precision issues:
Test Energy Conservation
Test Energy Conservation
Verify materials in a white furnace environment to ensure energy conservation.
Advanced Topics
Clear Coat Model
Filament supports multi-layer materials with a clear coat:- Second specular lobe for coating
- Always isotropic and dielectric
- Simpler visibility function for performance
- Accounts for energy loss through coating
Anisotropic Reflections
Anisotropic materials (brushed metal) require directional roughness parameters.Subsurface Scattering
For materials with large mean free path (skin, wax, marble), additional subsurface terms are needed.Related Topics
Materials Overview
Learn how to create and use materials in practice
Rendering Loop
Understand how PBR fits into the render pipeline