Another day, another blog post about physically based rendering. Physically based rendering is becoming very common in games, but that doesn’t help you very much if the artists don’t know how to use it properly. So consider this post a quick intro for artists.
Let’s imagine that you have some surface in the world. And we have some light source that is emitting photons. Now consider the life of that single photon. Will it be reflected off the surface and hit your eye as specular light? Physically based rendering says that three things must happen.
- That photon must actually hit the surface (it can't be shadowed).
- That photon must be reflected off the surface (as opposed to absorbed by the surface)
- That photon must be reflected in your direction (and not bounce off in some other direction)
That’s it. In the image above, we are really zoomed in and looking at the tiny bumps on the surface. It’s very much not to scale. The photon hitting point A would have a chance to get to the viewer. But the photon hitting point B has no chance of becoming specular light because it has been occluded.
In the second image, that photon hits the surface. When it does, it might reflect off the surface or refract into the surface. If it reflects (grey line), it becomes specular. If it refracts (blue line), it becomes diffuse light or heat.
And third, that photon must bounce towards the viewer (C). If it floats off in another direction you won’t see it as specular (D). Physically based rendering is about modeling those steps as math/physics says they should.
Geometry Self-Shadowing As mentioned before, for a photon to hit the surface and bounce back towards your eye, it can’t already be shadowed by another object. The term for this phenomena is Geometric Self-Shadowing, and it is usually written as G. It’s also sometimes combined with the denominator of the BRDF to form the term V, but if you’re an artist it doesn’t matter. Just know that when engineers talk about G (Geometry Self-Shadowing) or V (Visiblity), they are fundamentally talking about the same thing.
At the microscopic level most (but not all) surfaces are quite bumpy. These little bumps are called microfacets. So the G term refers to the chance that our photon will get to the spot we are looking at without being shadowed by one of these other tiny bumps. Obviously, rough surfaces will be darker than smooth surfaces because rough surfaces have more self-shadowing.
Many of the models for G (when paired with the terms in the denominator of the BRDF) will tend to cause the grazing angles to get brighter. Intuitively, this should make sense. Let’s say you are looking at a rough surface with lots of crevices.
If you look at that surface from straight ahead, the point that you are looking at is equally likely to be a peak or a valley. But if you look at it from a grazing angle your eye will only see the peaks. I’m oversimplifying, but since those peaks are brighter than the valleys, a rough surface will be brighter at grazing angles.
Fresnel Once this singular photon hits the surface, there are two basic things it can do.
- Reflect off the surface
- Absorb into the surface
The Fresnel equation dictates which of those two things will happen. As you probably guessed, this term is usually called F. Also, the s in Fresnel is silent.
If the light reflects off the surface, it becomes specular light. If the photon gets absorbed into a surface, it can either retransmit as diffuse light, or be absorbed as heat. That’s why wearing a black shirt on a sunny day will be hotter than wearing a white shirt. A white shirt will retransmit those photons as diffuse light whereas a black shirt will absorb those photons as heat.
The fresnel equation is based on the index of refraction of participating media, but that’s not important for artists. What is important is that the chance of being reflected or absorbed is highly dependent on the angle at which light hits the surface. Most typical environment materials that we care about (wood, concrete, paint, cloth, etc) are dielectrics.
For dielectrics, if light hits the object straight on, only 2-5% of the light will reflect as specular. The rest will be absorbed. Whereas at true grazing angles the fresnel equation tells us that 100% of the light will reflect as specular. Said another way, the Fresnel term on the right will be 20x to 50x brighter than the situation on the left. Fresnel is REALLY strong.
That’s why I always say:
Microfacet Distribution This term, usually called D, refers to the chance that the photon will reflect back into your eye. And that chance is determined by the mcirofacet distribution of the surface. For this term, we usually think of the surface as a bunch of tiny little mirrors. If you have a very smooth surface (like a mirror) then all nearby rays will reflect in the same direction which causes a tight specular highlight.
However, if you have a bumpy surface, the light will scatter in more directions, which causes a wider specular highlight.
One note is that the Microfacet Distribution term will usually conserve energy. Although when you have a very wide distribution term, it will sometimes create the illusion that the specular highlight is darker. If you think about a specular highlight in terms of the perceptual radius of the highlight, the area of that highlight is proportional to the square of the radius. So if your radius gets 10x wider the average intensity is 100x darker. In other words, the perceived intensity of the highlight drops very quickly as the radius gets wider.
Conclusions Here are the key takeaways for me.
- Grazing angles have brighter specular highlights due to both F and G.
- As the distribution gets wider the average intensity drops off very quickly.
- Fresnel is stronger than you think. For example, skin should use the value 0.028, meaning that the amount of specular light at a grazing angle should be 35.7 (!) times brighter than a light right at the camera.
- Fresnel has always been used on glass and water, but it actually has a stronger effect on normal dielectrics like wood and stone.
- Rougher surfaces have more geometric shadowing, and thus darker G.
- Usually D and G will use the same input parameter, under the assumption that the roughness term affects both the microfacet distribution and the self-shadowing.
- Your dielectrics should have strong specular response at grazing angles.