The Specular Layer
The specular layer represents the second layer of my uber-shader where the reflected light varies between rough and sharp. Reflected light can consist of light from punctual light sources, image sources, and/or reflections of other objects. In general, if the reflected light varies from different viewing angles, then the specular layer will handle those reflections.
In most shaders, specularity represents the reflections of light sources in the scene, and reflections represent the reflections of objects in the scene. In fact, these are both the same phenomenon, and in my shader I consider them both specular, because linking the specular and reflection parameters is one of the easiest ways to increase the physical plausibility of a shader.
The most common specular model is the Blinn–Phong model, because of its computational simplicity. Like other models created in the beginning of computer graphics, this model is not physically based, so it fails to predict the light response of most materials at various angles accurately. Additionally, this model is not normalized or energy conserving, so as the roughness of the specular increases the amount of light reflected does not decrease as necessary; this results in really bright highlights for rough materials and when there are materials of varying roughness in the same scene, none of them ‘fit’ together visually.
Microfacet-based reflectance models, such as the popular Cook-Torrance model, are inherently more physically accurate, because the reflectance is dependent upon the viewing angle and rougher microfacets diminish the light’s energy, making it energy conserving. Most microfacet BRDFs involve three terms – fresnel, distribution, and geometry – that different functions can be plugged in to. There are two typical functions for the fresnel term: the Fresnel equations or Schlick’s approximation to them. There are many options for the distribution and geometry terms, though one is usually derived from the other so you will find them in pairs. Changing the distribution and geometry terms will change the look of the specular highlights, whereas the two most common fresnel terms are almost identical.
Many people have written equations for the microfacet BRDF, but I’ve integrated only a few in my uber-shader. The primary model is the GGX distribution by Walter et al., recommended by Disney in a recent paper on their physically based shading because of its ability to match measured data.
The specular layer can also be made metallic. Non-metallic materials reﬂect light as the same color as the incoming light because the reflected light is, for the most part, not wavelength dependent. Metallic materials reflect light as their base color for the opposite reason. When the specular layer is metallic, no light is let through to the diffuse layer and the reflections are the same color as the diffuse color, because it’s easier for an artist. In the future, I plan on supporting different indices of refractions per RGB channel to better simulate how metals appear different colors.