Shading models
From Tech Artists Wiki
There are a number of shading models that determine how direct lighting interacts with a surface. The goal of all shading models is to determine the color of each point on the surface, given the local properties of the surface and the lighting environment in which the surface is found. Each model combines the various input elements (light vector, surface normal, eye vector, surface roughness, etc) in a different way to achieve the appearance of a specific type of real-world material.
All of the descriptions on this page are very general. Future revisions will include more specific examples, images, and formulas.
Contents |
[edit] Phong
The Phong shading model was developed by Bui Tuong Phong in 1973. It was the first shading model to combine ambient, diffuse, and specular terms to create the final result.
The ambient term is simply a color value added to the other terms. The ambient color represents indirect lighting in the environment - the light that simply exists every where and doesn't come from any specific direction.
The diffuse term is the N dot L that is discussed in the Lambertian section. It represents light that hits the surface of the object and is then bounced in all directions instead of being reflected in a specific direction.
The specular term was Phong's true innovation. It combines the surface normal, the view vector, and the light vector to simulate the results of light being reflected off of the surface of the object. This type of bright highlight can be seen on plastic and other reflective objects that don't display mirror reflection, but do reflect the light source uniformly.
To calculate Phong specular, we first find the reflection vector of the light vector and the surface normal. This alone yeilds a very broad specular highlight. To tighten the highlight (for more glossy objects) we raise the resulting reflection vector to a power. This specular power value is often called the glossiness term. In most implementations, it can be defined by the user.
[edit] Blinn (Blinn-Phong)
In 1977, Jim Blinn presented an optimization to the specular calculations of the original Phong model. Just like the Phong model, the Blinn model includes an ambient term, a diffuse term and a specular term. The ambient and diffuse terms are identical to the Phong model. The only differece between the Blinn and Phong models is the way the specular highlights are computed. Instead of computing the reflection vector of the incoming light vector and the surface normal as in the Phong model, the Blinn model computes a half-way angle between the light vector and the view vector. This "Half Angle" is then used in place of the reflection vector to calculate the final result.
The performance advantage of the Blinn model over the Phong model can only be realized when using a directional light source where the light vector is the same for every point on the surface. In this case, it is possible to compute the Half Angle once for the entire scene. This is possible because computing the Half Angle only requires the light vector and view vector - which don't change from one point to another. With the Phong model, the reflection vector must be computed for every point since it is dependent on the surface normal.
This performance advantage can not be realized when using point lights or spot lights since the light vector is different for each point in the scene. In these cases, the Blinn and Phong models are very close in performance. Because many scenes use a mix of spot lights, point lights, and directional lights, and because the same lighting model should be used for all light types, the performance benefits of Blinn over Phong are rarely realized and both models are generally regarded as fast and inexpensive.
[edit] Cook-Torrence
[edit] Oren-Nayer
[edit] Gouraud
[edit] Anisotropic
The term "Anisotropic" is a descriptive term that refers to not one, but many shading models. The common theme that all anisotropic shading models share is that their resulting specular highlights are not uniform in all surface directions. The highlights will yield different results depending on the direction of the surface (in contrast with the other lighting models here where the specular highlights are uniform and the same for all directions.)
On real-world materials, anisotropic highlights are generally seen on surfaces that have micro-textures or scratches that all go in one direction - such as brushed metal. These very small surface features cause light to be reflected differently depending on the orientation of the object.
[edit] Bidirectional reflectance distribution function (BRDF)
A Bidirectional reflectance distribution function is any function that takes a surface position, normal, eye vector, and light vector and returns a resulting color for that point on the surface. All of the lighting models on this page are considered BRDFs since they take those inputs and return a surface color based on a formula. However, each shading model formula is very specific to a certain type of surface. The most flexible type of lighting model would be one that allows the basic formula to be changed based on the desired effect so that a wide range of material types could be simulated.
Generally, when a shading model is said to use a BRDF, it means that the basic shading model formula can be changed based on a user defined set of data. In most cases, this data is represented by one or more texture maps that have been pre-baked to give the desired result. Instead of using a math formula to generate the effect, a BRDF shader looks up the result in the texture map based on the input parameters. This means that an infinite number of shading models or surface types can be represented by the same shader - simply by altering the texture or textures that are used to find the result.
Categories: WIP | Shaders | Rendering
