First Pass Techniques
This section is all about first pass techniques. This is dominantly filled with different types of lighting effects but also includes other fragment shaders and useful techniques that can be done in the first pass.
Gouraud Shading
Blinn-Phong Shading
Cook-Torrance Shading
Oren-Nayar Shading
Gouraud shading is among the cheapest lighting techniques available to compute. It has a diffuse, ambient and specular contribution but is calculated per-vertex and interpolated across fragments. [...]
Up until around 2011 Blinn-Phong was by far the most popular lighting technique in real-time applications. With an ambient, diffuse and specular contribution this per-fragment shader is both computationally cheap and of a high quality. [...]
With the introduction of more and more powerful hardware comes the allowance of more expensive yet accurate "Physically Based Rendering" shaders. The Cook-Torrance BRDF is one of the best options for simulating reflections on materials such as metals, mirrors or plastics. [...]
So Cook-Torrance works best with reflective materials, but what about rough microsurfaces such as rubber, wood or clay? Oren-Nayar is a diffuse only BRDF that aims to simulate the way light spreads across a rough, matte surface more accurately than the simple Lambertian method. [...]
Cel Shading
Realistic lighting may not always be the desired effect. If you are working to a cartoon-ish specification then Cel shading would be more appropriate. This simple effect uses a single dot product to calculate and clamp the intensities of a light source to give a scene that hand-drawn feel. [...]
So we've looked at a lot of ways to make light work in all kinds of situations but up until now we've only been using constant coefficients and values across the entire object which does not look all that great. In the real world every material has some kind of variation to it and texture maps can be used to store this information on a per-fragment level. [...]
Texture Mapping
Image Based Lighting
Even with physically based lighting in place materials such as chrome or gold will still be lacking in accurate spatial reflection. To overcome this we must use the environment around an object, extracting its light intensity values to create lighting and reflections from every direction. This is known as Image Based Lighting. [...]
In any scene, realism or artistic, one important effect remains constant throughout to ensure the viewer has a sense of depth in the area. That effect is shadows [...]
Two Pass Shadow Mapping
Parallax Occlusion Mapping
Parallax Occlusion Mapping (or POM) is a relatively simple method of simulating surface detail on a flat surface without the need to create more geometry. The technique can be quite expensive if overused however it is sometimes more appropriate than alternate methods such as tessellation. [...]