For my uber-shader, I have gone with a ‘layered’ style model so that I may represent many different types of common materials easily. I’ve structured it so that some familiar, but old, concepts are represented, yet in a way that is physically plausible.
Computer-generated graphics, like most things, can be burdoned by their history. The common shading models have existed since the beginning of computer graphics, and they are usually chosen for their speed or ease of implementation. Either reason can be justified, depending on how well the chosen model approximates reality. I won’t be getting into the details of the shading models that are commonly used, but I will bring up how they differ from the models I am using and why I think my approach is better.
For structural reasons, instead of allowing an arbitrary amount of layers with varying properties, my uber shader is broken into three layers of varying specialization: diffuse, specular, and a coating. Others and I agree that this approach can represent most materials, and that is what an uber-shader is designed to do. Although diffuse and specular may sound familiar, this shader treats them differently than what you might be used to.
The diffuse layer represents the base material, which scatters light almost uniformly across all directions. This is usually the layer responsible for a material’s overall color. Typically, the diffuse section of a shader would only represent light that comes from sources in the 3D scene; however, I have fully integrated a global-illumination model that allows the diffuse layer to receive light from images (see my previous post) and/or bounced off of other objects in the scene.
The specular layer represents a small layer on top of the diffuse layer that both reflects and transmits light. This surface can vary between very rough (similar to the diffuse layer) and perfectly smooth (like a mirror). Reflections are included in this layer because they represent the same thing ‘specularity’ is trying to achieve.
The coating layer represents yet another smaller layer on top of the specular layer that both reflects and transmits light. This is essentially another specular layer. In most cases, this layer would exhibit near-perfect reflections while the specular layer is more rough.
Light interactions between each layer are physically accurate, except where time savings are achieved with little visual difference. One major difference between my shading model and standard shading models is that I account for the fact that light ranges between completely reflected and mostly transmitted depending upon the viewing angle, so this shader is energy-conserving (it doesn’t reflect more light than it receives). Additionally, any light absorbed by a layer is removed from the layers below, contrary to other shading models where the ‘diffuse’ and ‘specular’ components are simply summed.
In future blog posts I will dive into each layer to explain what it is, the model I’ve chosen for it, and how you can tweak it.