π± π, πβ² = π(π, πβ²) π π, πβ² + ΰΆ±
π»
π π, πβ², πβ²β² π± πβ², πβ²β² ππβ²β²
INFOMAGR β Advanced Graphics
Jacco Bikker - November 2017 - February 2018
Lecture 13 - BRDFs Welcome! , = (, ) , - - PowerPoint PPT Presentation
INFOMAGR Advanced Graphics Jacco Bikker - November 2017 - February 2018 Lecture 13 - BRDFs Welcome! , = (, ) , + , , ,
π± π, πβ² = π(π, πβ²) π π, πβ² + ΰΆ±
π»
π π, πβ², πβ²β² π± πβ², πβ²β² ππβ²β²
Jacco Bikker - November 2017 - February 2018
Advanced Graphics β BRDFs 3
In path tracing, we can reduce variance by using cosine weighted sampling of the hemisphere, rather than uniform sampling, for diffuse surfaces. a) Why does this reduce variance? b) When using cosine weighted sampling, the result remains unbiased. What does unbiased mean?
Advanced Graphics β BRDFs 4
An exam can be seen as a Monte-Carlo process. Expain why.
Advanced Graphics β BRDFs 5
After reading the probability tutorial, answer these: a) What is a definite integral? b) What do we mean by an analytical solution? c) How is the Riemann sum defined (mathematically)? d) What is βunivariateβ? e) What is βaliasingβ? f) Define, in your own words, βexpected valueβ. g) What is βdeviationβ in the context of probability theory? And, finally: When using importance sampling, we assume that for π = β,
πβπ π Οπ=1 π π(π) π(π) = πβπ π Οπ=1 π
π(π), if Χ¬
π π π π¦ ππ¦ = 1. Provide one
example for which this is not true.
Advanced Graphics β BRDFs 7
BRDFs, Recap
Recall that a BRDF defines the relation between incoming and outgoing radiance for directions and a surface point: π
π π¦, ππ, ππ = ππ(π¦, ππ)
πΉπ(π¦, ππ) = ππ(π¦, ππ) ππ π¦, ππ cos ππ
π
ππ ππ
π¦ π π What about materials that are not purely specular, nor diffuse?
Advanced Graphics β BRDFs 8
BRDFs, Recap
We already know how to do materials that are diffuse and shiny. But that gets us good looking marble floors, not glossy reflections.
50% diffuse, 50% specular, 50% diffuse, 50% glossy (or: 100% glossy)
Advanced Graphics β BRDFs 9
Glossy Reflection
Glossy reflections: sending out rays in random directions close to the reflected vector.
Simple solution: π = π ππππππ’(π, π); π = π½ + π + π‘ππππ(π ππππππππππ’π½πππβππ π(), π‘ππππ£πππ ππ’π§) π = πππ πππππ¨π(π β π½); Or: π = π ππππππ’(π, π); π = π½ + π + π‘ππππ(π ππππππΈππ πππ’ππππ½ππΌππππ‘πβππ ππ·ππ‘πππππππβπ’ππ(π), π‘ππππ£πππ ππ’π§) π = πππ πππππ¨π(π β π½); πΆ
Advanced Graphics β BRDFs 10
Glossy Reflection
In OpenGL, shading is defined as follows*: π½π¦ = ππππππππ’π½πππππππ’ + ΰ·
πβπππβπ’π‘
ππππππ£π‘π π β ππ + ππ‘ππππ£πππ ππ β π
ππ¦ππππππ’
π½π
*: Bui-Tuong Phong, Illumination for Computer Generated Images, 1975.
ππ ππ π
π¦ where
material properties (typically: rgb);
normal π;
π ΰΆ±
π»
cos π = π ΰΆ±
π»
πππ‘ππ¦ππ =?
Advanced Graphics β BRDFs 11
Blinn-Phong BRDF (images: Disney BRDF Explorer)
Advanced Graphics β BRDFs 12
Modified Phong BRDF
Advanced Graphics β BRDFs 13
Fixing Phong
Recall the requirements for a proper BRDF:
π ππ, ππ β₯ 0
π ππ, ππ = π π ππ, ππ
π» π π ππ, ππ cos ππ πππ β€ 1
BRDFs obeying these rules are called physically plausible. For a path tracer, we have additional requirements:
(for MIS).
Advanced Graphics β BRDFs 14
Fixing Phong
Sampling proportional to π β π, according to the G.I.C. : π¦ = cos 2ππ
1
1 β π 2 π§ = sin 2ππ
1
1 β π 2 π¨ = π
2
π β π 1 π β π 2 π β π 10 π β π 50
Sampling proportional to π β π π½, according to the G.I.C. : π’ = π
2
2 π½+1, π¦ = cos 2ππ
1
1 β π’ π§ = sin 2ππ
1
1 β π’ π¨ = π’
π¨ π¦ π§
Advanced Graphics β BRDFs 15
Tangent / Local Space
Setting up a local coordinate system in 2D:
π = π π = βπ. π§ π. π¦ Setting up a local coordinate system in 3D: π = π π = πππ πππππ¨π(π Γ π) πΆ = π Γ π where π is a random unit vector; π β π.
π¨ π¦ π§
Good choice for π: π = (0,1,0) if abs(ππ¦) > 0.99; π = 1,0,0 otherwise.
πΆ πΌ πͺ
Advanced Graphics β BRDFs 16
Tangent / Local Space
Converting a vector from world space to local space: π
π¦
π
π§
π
π¨
= π β π π β πΆ π β π Local space to world space: ππ₯ππ ππ = π Γ ππππππ = π
π¦π + π π§πΆ + π π¨π
πΆ πΌ πͺ
Advanced Graphics β BRDFs 17
Normalizing the Lobe
A material cannot reflect more energy than it receives: ο¨ We thus scale the BRDF by the inverse of its integral over the hemisphere. For the Lambertian BRDF: π‘ππππ =
1 π (because cos π integrates to π)
For the cosine lobe, the scale is
π½+1 2π (*). However, there is a problem:
*: Physically Based Rendering, page 969; also see: http://www.farbrausch.de/~fg/stuff/phong.pdf
π π π
Advanced Graphics β BRDFs 18
The Modified Phong BRDF
The Phong BRDF has problems:
intersects the surface. Compensating for the intersection: Modified Phong BRDF. π
π π¦, ππ, ππ = ππ
1 π + ππ‘ π½ + 2 2π πππ‘π½π where π is the angle between the view vector and the reflected light vector. For ππ + ππ‘ < 1, this guarantees energy preservation*.
*: Lafortune & Willems, Using the Modified Phong Reflectance Model for Physically Based Rendering, 1994.
π
π π¦, ππ, ππ = ππ 1 π + ππ‘ π½+2 2π πππ‘π½π :
Total hemispherical reflection (note: integrating over
π π¦, ππ = ΰΆ±
Ξ©
π
π π¦, ππ, ππ cos ΞΈππππ
= ΰΆ±
Ξ©
(ππ 1 π + ππ‘ π½ + 2 2π πππ‘π½π) cos ΞΈππππ = ππ + ππ‘ π½ + 2 2π ΰΆ±
Ξ©
πππ‘π½π cos ΞΈππππ The last integral is maximal when the incoming light arrives along the normal; in this case π = ππ, and the integral is 2π/ (π + 2). Therefore, in this case: π π¦, ππ = ππ + ππ‘ and conservation of energy is guaranteed iff: ππ + ππ‘ β€ 1.
Advanced Graphics β BRDFs 19
The Modified Phong BRDF
Despite the kludges, we now have a decent BRDF for glossy materials. We can sample it: π’ = π
2
2 π½+1, π¦ = cos 2ππ
1
1 β π’ π§ = sin 2ππ
1
1 β π’ π¨ = π’ Normalize it: π½ + 2 2π πππ‘π½π We have a PDF: π½ + 2 2π πππ‘π½π
And finally, we can blend it with the Lambertian BRDF:
Advanced Graphics β BRDFs 21
BRDFs Without Issues
We now have two BRDFs without problems:
These are plausible and can be sampled. The PDF is also clear. And, we have the somewhat kludged modified Phong BRDF.
Advanced Graphics β BRDFs 22
Microfacet BRDFs*
We can simulate a broad range of materials if we assume: at a microscopic level, the material consists of tiny specular fragments.
*: Torrance & Sparrow, Theory for Off-Specular Reflection from Roughened Surfaces. 1967.
Advanced Graphics β BRDFs 23
Microfacet BRDFs*
The Microfacet BRDF: π
π π, π = πΊ π, π π» π, π, πΌ πΈ πΌ
4 π β π π β π Ingredients:
Advanced Graphics β BRDFs 24
Normal Distribution
Microfacet BRDF, ingredient 1: πΈ(πΌ) ο¨ the normal distribution function. Parameter πΌ: the halfway vector: π
π π, π = β―
A microfacet that reflects π towards π must have a normal halfway π and π:
H = normalize(V + L).
π
π π¦, ππ, ππ =
ππ(π¦, ππ) ππ π¦, ππ cos ππ
πΎ π΄
Advanced Graphics β BRDFs 25
Normal Distribution
Intuitive choices for D: πΈ πΌ = π·: microfacet normals are equally distributed ο¨ diffuse material. πΈ πΌ = β, πππ πΌ = 0,0,1 0, ππ’βππ π₯ππ‘π : all microfacet normals are (0,0,1) ο¨ pure specular. Good practical choice for D: the Blinn-Phong distribution; πΈ πΌ = π½ + 2 2π π β πΌ
π½
Advanced Graphics β BRDFs 26
Geometry Term
Microfacet BRDF, ingredient 2: π»(π, π, πΌ) ο¨ the geometry term.
Advanced Graphics β BRDFs 27
Geometry Term
Intuitive choice for G: π»(π, π, πΌ) = 1: no occlusion. Good practical choice for G*: π» π, π, πΌ = min(1, min 2 π β πΌ π β π π β πΌ , 2 π β πΌ π β π π β πΌ
*: Physically Based Rendering, page 455
Advanced Graphics β BRDFs 28
Fresnel Term
Microfacet BRDF, ingredient 3: πΊ(π, πΌ) ο¨ the Fresnel term. So far, we assumed that the light reflected by a specular surface is only modulated by the material color. This is not true for dielectrics: here we use the Fresnel equations to determine reflection. In nature, Fresnel does not just apply to dielectrics.
π ππ ππ
Advanced Graphics β BRDFs 29
From βReal-time Rendering, 3rd edition, A. K. Peters.
Fresnel Term
Iron is specular, but reflectivity differs depending on incident angle. Aluminum is even more interesting: reflectivity depends on wavelength. The three lines in the graph: Top: blue, middle: green, bottom: red. Copper takes this to extremes: at grazing angles, it appears white. The lines in the graph: Top: red, middle: green, bottom: blue.
(hence its reddish appearance)
Advanced Graphics β BRDFs 30
Fresnel Term
For Fresnel, we once again use Schlickβs approximation: πΊ
π = ππ‘ππππ£πππ + (1 β ππ‘ππππ£πππ )(1 β π β πΌ )5
Note that this is calculated per color channel (ππ‘ππππ£πππ is an rgb triplet). Values for ππ‘ππππ£πππ for various materials: Iron 0.56, 0.57, 0.58 Copper 0.95, 0.64, 0.54 Gold 1.00, 0.71, 0.29 Aluminum 0.91, 0.92, 0.92 Silver 0.95, 0.93, 0.88
Advanced Graphics β BRDFs 31
Bringing it All Together
The Microfacet BRDF: π
π π, π = πΊ π, π π» π, π, πΌ πΈ πΌ
4 π β π π β π πΊ
π = ππ‘ππππ£πππ + (1 β ππ‘ππππ£πππ )(1 β π β πΌ )5
π» π, π, πΌ = min(1, min 2 π β πΌ π β π π β πΌ , 2 π β πΌ π β π π β πΌ πΈ πΌ = π½ + 2 2π π β πΌ
π½
For a full derivation of the denominator of the BRDF, see Physically Based Rendering, section 8.4.2.
Advanced Graphics β BRDFs 32
Lambertian BRDF
Advanced Graphics β BRDFs 33
Blinn-Phong Microfacet BRDF, Ξ±=1
Advanced Graphics β BRDFs 34
Blinn-Phong Microfacet BRDF, Ξ±=10
Advanced Graphics β BRDFs 35
Blinn-Phong Microfacet BRDF, Ξ±=50
Advanced Graphics β BRDFs 36
Blinn-Phong Microfacet BRDF, Ξ±=500
Advanced Graphics β BRDFs 37
Blinn-Phong Microfacet BRDF, Ξ±=50000
Advanced Graphics β BRDFs 38
Specular BRDF
Advanced Graphics β BRDFs 40
Tricks & Tips
Picking the best light:
10 10 22 22 4 20 20 56 30
Advanced Graphics β BRDFs 41
Tricks & Tips
Multi-layer Microfacet:
ο¨ Sample one random layer. When evaluating (for MIS): ο¨ Evaluate both layers, scale each sub-PDF
Advanced Graphics β BRDFs 42
Tricks & Tips
Material interface: In general, you need two methods:
probability density for the generated direction.
the probability density for the generated direction. The first is commonly used for extending the random path. The second is used for next event estimation.
Advanced Graphics β BRDFs 43
Tricks & Tips
Russian Roulette: Any termination probability is good. However: we donβt want really bright paths. Consider this probability: min( 1.0f, max( max( diffuse.x, diffuse.y ), diffuse.z ) ); Effect:
This is THE BEST. Itβs genius and stable.
Advanced Graphics β BRDFs 44
Tricks & Tips
On Random Number Generators: Noise is annoying, but its effects can be reduced somewhat. Each pixel uses for its seed:
Replace β2β by a counter which is reset each time the camera moves. Now noise will be stationary during movement, which is a lot easier on the eyes.
Advanced Graphics β BRDFs 45
Tricks & Tips
Fireflies: You want your path tracer to be unbiased. However: Some pixels will be extremely bright, and it takes ages for them to βaverage outβ. Solution: clamp.
Advanced Graphics β BRDFs 54
Quo Vadis
Anisotropic materials:
Advanced Graphics β BRDFs 55
Quo Vadis
The Other Side: BSSRDF*
*: Jensen et al., 2001. A Practical Model for Subsurface Light Transport.
Advanced Graphics β BRDFs 56
Quo Vadis
Variance Reduction for BSSRDFs:
Advanced Graphics β BRDFs 57
Quo Vadis
Measured BRDFs:
Jacco Bikker - November 2017 - February 2018
next lecture: βGradient Domain Path Tracingβ (guest)