- 29: Cook-Torrance Specular Models
- Elements of PBR
- Bidirectional Reflectance Functions
- BRDFs should have reciprocity
- Modified Blin-Phong
- Energy conservation
- A common yet confusing convention
- Normalized modified Blinn-Phong
- Combining specular and diffuse
- Normalized specular helps your artists
- Metals vs. dielectrics
- Fresnel effect
- F₀ for dielectrics(linear)
- F₀ for metals (linear)
- Incorporating Fresnel term
- A reflective paradox ?
- General Cook-Torrance specular
- Blinn-Phong microfacet distribution
- GGX microfacet distribution
- The geometric term
- Original Cook-Torrance geometric term
- GGX-based geometric term
- GGX-matched to GGX geometric term
- Implicit geometric term
- Kelemen Geometric term
- most popular model for specular reflections and physically based rendering
- Linear space lighting
- don't use gamma color space
- Energy conservation
- unless you have a material that is emissive (i.e. it is its own light source) it can't be reflecting more energy than is coming in.
- Reciprocity
- which says you need to be able to swap the viewer and the light source and get the same answer.
- Metallic/dielectric distinction
- we're going to be using the term
dielectric
in a much more general sense, basically a dielectric is anything that's not metal.
- we're going to be using the term
- "Everything is shiny" (i.e. has specular)
- "Everything has Fresnel"
- here we're using the term
fresnel
in a different way. It has the same ideas but we're going to be a little more specific about it, and essentially apply it to everything not just things that are refracting.
- here we're using the term
- Bonus: high definition render buffers and tonemapping to handle high dynamic range
- now if you actually implement all of these above things and try to put in some realistic light sources and materials you will find that the kinds of light your camera is receiving will cover an extreme dynamic range.
- previously when people weren't trying to go for physically based rendering they're just trying to go for something that looked decent, you would take a lot of time scaling your light sources to try to not blow out your image. But if you are trying to do something somewhat realistic you have to encapsulate the fact that you will have some very dim parts of your scene and some very bright parts of your scene.
- so you may need a high definition render buffer that can handle this high dynamic range and then various techniques such as tone mapping or bloom to take that high dynamic range information and compress it into what can actually be shown on a display.
- For "punctal" lights ( typical point, directional , spotlight... )
- Cfinal = Clight ⊗ πBRDF(L,V) max(0, n·L)
- BRDF: bidirectional reflectance distribution function
- L: light coming in
- V: viewer
- π: magic ...
- ⊗: color-wise multiplication
- multiply red by red, green by green, blue by blue
- Classic diffuse lighting model:
- BRDF = Mdif / π
- Cfinal = Clight ⊗ Mdif max(0, n·L)
- Classic Blinn-Phong lighting model:
- Reciprocity means we can swap the incoming and outgoing light directions:
- BRDF(L,V) = BRDF(V,L)
- Obviously true for classic diffuse lighting, because that's just a contant, doesn't have L or V in it anyway.
- BRDF = Mdif / π
- Reciprocity does not hold for classic Blinn-Phong:
- BRDF = ( Mdif / π ) (n·H)s
- s parameter: let us scale the width of the spot.
- if s is very small, I get a broad peak , while if s is large, I get a narrow peak , because
n·H < 1
- if s is very small, I get a broad peak , while if s is large, I get a narrow peak , because
- s parameter: let us scale the width of the spot.
- Cfinal = Clight ⊗ Mspec (n·H)s max(0, n·L)
- But there is a problem with this
s
. In general thiss
is not enery conservation.
- "Total amount of reflected light cannot be more than the amount of incoming light" -- Rory Driscoll
- For classic diffuse model BRDF = Mdif / π
- turns out you techinically nedd πMdif
< 1
( need calculus to derive)
- turns out you techinically nedd πMdif
- since π is just a constant, "we usually just ignore it and assume that our lights are just π times too bright." -- Steve McAuley
- For classic diffuse model BRDF = Mdif / π
- We'll pretend you practically need Mdif
< 1
- We'll pretend you practically need Mdif
- Convenient for artists: hit a diffuse surface with a materialo color of "1" with a directional light with an "intensity" of "1" parallel with its normal and you get "1"
- If you are implementing global illumination, be careful !
- if you have something that's sending out more light than it's taking in when it's not supposed to that can cause your numeric solutions to freak out.
- To achieve energy conservation
- it turns out if you work through a bunch of multi-dimensional integrals you can figour out that if you stick this fact
(S+8)/(8Π)
out in front, then the reflected energy is going to be conserved as you changes
. - and having this term
s+8
in the numerator means that as we shrink the sport , we're making that spot brighter.
- Dielectrics have diffuse and specular reflections
- Specular reflection is white
- Metals have purely specular reflections
- specular reflection may be non-white
- particularly if you're looking at them head on
- Still white at large grazing angles.
- specular reflection may be non-white
- Specular reflections increase dramatically at high grazing angles
- Schlick aporoximation:
- F(V,H) = F₀ + (1-F₀)(1-V·H)⁵
- = F₀ + (1-F₀)(1-L·H)⁵
- F₀ : reflection when view and ligth vector align ( grey for dielectrics, but metals can have color )
- since H is the half vector of L and V, V·H == L·H
- ( 1 - L·H )⁵ this gives us a really aggressive slope off near the edge. Essentially this becomes an interpolation factor.
- F(V,H) = F₀ + (1-F₀)(1-V·H)⁵
- one thing that's confusing is you'll often see a different formulation used here
- F₀ + (1-F₀)(1-n·H)⁵
- indead of
V·H
you seen·V
- this is a special form of the fresnel effect that you use for global illumination effects where you know where the camera is and you have a normal vector associated with your surface, but the lights coming from all over in some sense , you don't really have an L vector that you can use.
- here are some example of F₀ for various dielectrics.
- Remember specular reflection of dielectrics is white.
- we're not really going to use this expression anyway because we'd like to take a few more steps and do something a little more complicated.
- it's particularly weird here because this road is black asphalt, and it's been raining so there is water on top and you would expect the main issus is that there's water on it and the sun is reflecting off of the water.
- now what's weird about his is that F₀ is actually higher for the asphalt that it is for the water.
- so it makes you wonder why are the puddles reflecting more than the places without puddles.
- well all of thing being equal, it would, the asphalt would be more reflective than the water, but the main difference here is that the water will pool and form smooth surfaces whereas the asphalt is fairly rough. So we're getting strong reflections off of the water even though the water technically has a lower F₀ , because those surfaces are smoother than the surfaces formed by the asphalt.
- so we would like to take this effect into account.
- G(n,L,V) the geometric term
- D(n·H) the distribution term
- this is the term that encapsulates the effect we saw on the slide about the asphalt and the water.
- it's something that is parameterized by smoothness.
- one term we might use is the following modified blinn-phong term.
- Microfacet Blinn-Phong
- Throughout rest of slides , imagine the artist makes "smoothness maps" containing "gloss" g in the range [0,1]
- Call of Duty: Black Ops
- s = 8192g = 2(13g)
- But it turns out people tend not to use this modified blinn-phong that much anymore anyway.
- A different g called GGX has become much more popular and is pretty much the dominant distribution term that you'll see in cook-torrance specular models and in modern game engines.
- GGX:
- Crytex: α = (1-0.7g)²
- Unreal: α = (disney roughness)² = (1-g)²
- objects tended to have a much quicker fall off right around the peak, and then very long tails that will go out a lot further than you could get from the modified blinn-phong model.
- The last thing we need to look at is the g term.
- g term is trying to deal with the effect that variation of height has both blocking light coming in and blocking light that's trying to come out.
- Now the kind of effectes we're talking about here are at an even smaller level than the kinds of effects we're trying to achieve with normal maps. This is trying to capture the effects of roughness variations that you couldn't see with the naked eye.
- it is expressed in this form of factors: GGX-R(n·L) and GGGX-R(n·V)
- the 2nd equation is the core formula to expand the factors.
- Used in The Order: 1886
- I haven't seen this particular full ggx form used in very many games.
- Ideal of a "visualization" term:
- GGX-form matched to GGX distribution
- Disney standard: k = α/2 = (g-1)²/2
- Disney "hotness remapping": k = [0.5 + (1-g)/2]²/2
- Now imagine for a second that you picked this geometric term
- GI(n,L,V) = 4(n·L)(n·V)
- there is no reason why you might expect that to be useful.
- but it just happens that if you plug that in for you actual g and divide by the
4(n·L)(n·V)
- VizI(n,L,V) = GI(n,L,V) /( 4(n·L)(n·V) ) = 1
- GI(n,L,V) = 4(n·L)(n·V)
- If you're on a resource limited platform you might want to use this Kelemen geometric term.