05+ +surfaces
05+ +surfaces
Christoph Garth
Scientific Visualization Lab
Motivation and Overview
In the previous chapter, we considered the rendering equation as the basis for PBR1 :
Z
Lo (x, ω) = Le (x, ω) + f (x, ω, ωi ) Li (x, ωi ) cos θi dωi
Ω
Remember:
• We identified radiance is the correct physically quantity to model a “light field”; giving a
directional flux density at each point surface x.
• Li and Lo are coupled by rays between points that can see each other (vacuum assumption).
This turns the 5-dimensional rendering equation into a four-dimensional problem.
Neglecting participating media, light intensity and direction are only modified at
such boundaries; this allows for phenomena such as reflection, refraction, and
absorption.
• incident ray, reflected ray and surface normal lie in the same plane
• incident angle to normal θi = reflected angle to normal θr
N
ωr
ωi ωr
θi θr ωi
normal
The index or refraction (IOR) describes how fast light travels
in a material: θ1
c ωi
n=
v
where v is the speed of light in the material and c is the interface n1 v1
speed of light in vacuum. For example, n2 v2
θ2
Snell’s Law: if n1 , n2 are the refraction indices of two media, ωo
a light ray is refracted at the transition such that
n1 sin θ1 = n2 sin θ2
n1
θcrit = arcsin
n2
n2 θ2
90 o
total reflection
θcrit
n1 θ1
diffuse
Specular reflection [refraction] denotes the case when
incoming light is reflected into (mostly) a single direction.
• Even for diffuse and rough specular reflection, the law of reflection still holds;
however, the surface is not flat, but “rough”, and so photons hitting at slightly
different positions are reflected into completely different directions.
from https://google.github.io/filament/Filament.html
• A single photon can of course not be reflected into multiple directions at once.
Macroscopically, we can interpret a BRDF as a probabilty density function that gives
the probability that a single photon is reflected into a particular direction, and
describes the surface microstructure statistically.
In other words: the Lambertian / diffuse BRDF is constant, f (ωi , ωr ) = kπd , where kd
is a material constant that describes the total fraction of reflected light.
Normalization: Since
kd k kd
Z Z
cos θi dωi = d cos θi dωi = · π,
Ω+ π π Ω+ π
2
highest diffuse reflectance of any known material
Computer Graphics – Surfaces– Diffuse Reflection and Lambertian BRDF 5–10
How can we visualize BRDFs to understand them better?
ωi N ωi N
ωi N
R
Computer Graphics – Surfaces– Specular Reflection and Local Lighting Models 5–12
How can we model specular reflection in terms of a BRDF?
Let’s take a short history detour to approach this from a simpler perspective.
• Consider a surface point illuminated by a single point light. Light arrives from
a single direction L, and the incoming intensity is distributed.
• Let’s further limit to direct illumination: the intensity at the sensor is the
intensity reflected into the sensor direction V (“viewer”).
Computer Graphics – Surfaces– Specular Reflection and Local Lighting Models 5–13
Phong Reflection Model (Bui Tuong Phong, 1975)
Computer Graphics – Surfaces– Specular Reflection and Local Lighting Models 5–14
Phong Reflection Model (Bui Tuong Phong, 1975)
Phong’s idea: reduce reflected intensity with cosn α = hV, Rin , giving
Here, N
• ks ∈ [0, 1] (“amount of reflection”) and
V
• n > 1 (specular exponent) θr
L θi α R
are material constants that can be used to
influence the appearance of the material.
Computer Graphics – Surfaces– Specular Reflection and Local Lighting Models 5–15
Illustration: Polar plot of Phong reflected relative intensity (n = 30)
L
R
L R
Computer Graphics – Surfaces– Specular Reflection and Local Lighting Models 5–16
Illustration: Specular highlights become “sharper” as n grows (perfect mirror for n → ∞).
0.8
0.6
0.4
0.2
Computer Graphics – Surfaces– Specular Reflection and Local Lighting Models 5–17
How to calculate the reflection vector R for light vector L (= ωi )?
(Without using trigonometric functions, that is.)
R = 2hN, LiN − L
−L
Computer Graphics – Surfaces– Specular Reflection and Local Lighting Models 5–18
Blinn-Phong Reflection (Jim Blinn 1977)
Computer Graphics – Surfaces– Specular Reflection and Local Lighting Models 5–19
Blinn-Phong Lighting Model (Jim Blinn 1977)
For n0 ≈ 4n, Blinn-Phong and Phong give similar highlights except near grazing angles.
Computer Graphics – Surfaces– Specular Reflection and Local Lighting Models 5–20
Phong Lighting Model
Observing that most materials have both diffuse and specular reflection, Phong
formulated a local lighting model to allow the simulation of diverse materials.
Computer Graphics – Surfaces– Specular Reflection and Local Lighting Models 5–21
The resulting combination of diffuse, specular and ambient reflection,
N
L
Computer Graphics – Surfaces– Specular Reflection and Local Lighting Models 5–22
Illustration: Contributions in the Phong Lighting Model
Computer Graphics – Surfaces– Specular Reflection and Local Lighting Models 5–23
Illustration: Contributions in the Phong Lighting Model
L L
Computer Graphics – Surfaces– Specular Reflection and Local Lighting Models 5–24
Notes:
• Thus far, we did not consider colors in the lightling models and measures like
I, L, etc; in principle, we would have to write all terms with a wavelength
dependence, e.g. L(. . . , λ . . . ), ks (λ), etc.
• For most practical purposes, wavelength-dependent effects can be
neglegted, and we can fall back to representing colors in the RGB model:
• color coefficients Cd , Cs , Ca
• Cd = (diffuse) surface color
• Cs = color of specular reflection
• Similarly, the color of light sources is specified as an RGB triple.
Computer Graphics – Surfaces– Specular Reflection and Local Lighting Models 5–25
Why is specular color Cs given separately from diffuse color Cd ?
Simplified answer:
Computer Graphics – Surfaces– Specular Reflection and Local Lighting Models 5–26
Pseudocode (GLSL, multiple point lights)
Computer Graphics – Surfaces– Specular Reflection and Local Lighting Models 5–27
The Phong and Blinn-Phong lighting model are often perceived to look “plasticky”.
Material nuances cannot or can only be badly represented. On the upside, the
model can be evaluated fast.
Computer Graphics – Surfaces– Specular Reflection and Local Lighting Models 5–28
Cook-Torrance Model (roughly)
Ir = Ii · hN, Li · (ks · Rs + kd )
D·F·G
Rs =
hN, VihN, Li
The specular reflection is computed through three terms D, F, and G; each model
different characteristics of microfacets.
Lambertian reflection is typically used (as above) for the diffuse component.
While not going into detail, the role of the terms in describing the microfacets is
roughly as follows.
Computer Graphics – Surfaces– Specular Reflection and Local Lighting Models 5–29
D – Microfacet Distribution
from codinglabs.com
Computer Graphics – Surfaces– Specular Reflection and Local Lighting Models 5–30
G - Geometry Term
Illustration: Geometry Term with GGX distribution (again using roughness α ∈ [0, 1])
from codinglabs.com
Computer Graphics – Surfaces– Specular Reflection and Local Lighting Models 5–31
F – Fresnel term
The Fresnel effect (physics) determines the part of incident light that is reflected vs.
transmitted.
It depends on the refraction index of the medium and the incident angle, and increases
specular reflection at grazing angles for most materials.
from scratchapixel.com
Computer Graphics – Surfaces– Specular Reflection and Local Lighting Models 5–32
Illustration:
Fresnel effect
Computer Graphics – Surfaces– Specular Reflection and Local Lighting Models 5–33
Illustration: Effect of Fresnel Term
The Fresnel effect is largely responsible for the realistic look of the right sphere (with
Fresnel). The left sphere (without Fresnel) looks somewhat metallic.
Computing the Fresnel term is difficult – often the Schlick approximation is used.
Computer Graphics – Surfaces– Specular Reflection and Local Lighting Models 5–34
Illustration: Terms in the Cook-Torrance model
Computer Graphics – Surfaces– Specular Reflection and Local Lighting Models 5–35
Lighting Models and BRDFs
From Local Lighting Models to BRDFs
Thus far, we have formulated local lighting models – how can we get back to BRDFs? In
principle, not much is needed. Let’s briefly consider the Phong reflection model and see
how to turn it into a BRDF3 .
Remember: BRDFs appear in the rendering equation with a factor of cos θi , so directly
writing turning the specular formula into a BRDF, we divide by cos θi to obtain
cosn α
Ir (ωi ) = ks cosn α ⇒ fPhong (ωr , ωi ) = ks
cos θi
ks
Z
RPhong (ωi ) = cosn α cos θr dωr
cos θi Ω+
3
following derivation not relevant for exam
Computer Graphics – Surfaces– Lighting Models and BRDFs 5–36
For grazing angles (θi → π/2), cos θi → 0 and the reflectance approaches infinity! The
surface would be too bright or “glow”.
We can improve this by adding back in the cos θi factor the original model, giving the BRDF
A little thinking reveals that the reflectance becomes maximal when angle of incidence θi
is 0, i.e. when the ωi = N. Evaluate this as
2π
RPhong (0) = max RPhong (ωi ) = ks
ωi n+2
Observe:
6
n = 1, 5, 10, 50
kd
Ir (x, V) = · I (x, L) · hN, Li
π i
n+2
+ ks · Ii (x, L) · hV, Rin hN, Li,
2π
which is often encountered in physically-based realtime rendering.
kd
Ir (x, V) = · I (x, L) · hN, Li
π i
n +8
0
ks · Ii (x, L) · hN, Hin hN, Li
0
+
8π
• Oren-Nayar
• better approximation of diffuse reflection than Lambertian on many materials
• Ward Anisotropic
• surfaces with anisotropic structure, e.g. brushed metal, hair
• Disney BRDF – “universal” BRDF with few parameters
• also Blender’s Principled BSDF)
• specialized models for metals
• models for dielectrics, e.g. glass, certain fluids
• and many more
https://disney-animation.s3.amazonaws.com/library/s2012_pbs_disney_brdf_notes_v2.pdf
from pbr-book.org
from pbr-book.org
from wikipedia.org
What is missing:
Answering this question will give us our first rendering algorithm, Ray Tracing.