The Journey of the Light: Physically Based Shading
So far, some of the previous blog posts described how an idea, manifested as concept art gets turned into a finished model. What you've been left in the blanks for a while is how the game uses these models to form a beautiful recreation of the Fallout Equestria universe - a topic this series is meant to cover. Welcome to the Journey of the Light!
For those who are allergic to technical jargon, there is a video at the end!
One of our main goals is to bring you the level of visual fidelity that you are used to in today's game titles. Such a feat is not trivial. While simply drowning the screen in post processing effects might look nice if done right, it certainly won't look real with shading that is based on the wrong principles. Principles, that were unfortunately the standard for many years.
That curiously brings us into the middle part of the light's journey with our first post: Suppose you already have a solid representation of how the environment looks and where the light is coming from. How will this light affect the way the object is drawn on the screen?
The Phong reflection model
The popularity of this shading model, dated back to 1973, knows no bounds. It is used in countless games and movies to illuminate their scenes even today and it's the standard shading model in Unity 4. Why? Because it looks pretty good and does not burn a lot of gpu cycles. So what's wrong with it then?
This is not how light behaves in the real world. Our eyes are very sensitive to any discrepancies in the image that suggest you're not looking at a photograph. One of the most visible ones is the complete lack of energy conservation, a fundamental law in physics. Under certain circumstances it happily draws a pixel much brighter than it could be given the amount of light that hits it. To make it look plausible, artists often had to manually adjust the brightness of the specular highlights, but that breaks very fast when shown under different lighting conditions than what it was authored for. This and other issues become even more pronounced when used together with ambient lighting.
Physically based shading
The new solution is actually a collection of several models with the common goal to stay as close as possible to how light behaves in the real world. Besides respecting energy conservation, it also models the Fresnel effect, where light that hits an object at grazing angles tends to reflect more often than it is absorbed. All in all, that means it just looks right under any lighting conditions.
Another important factor is the significant difference between how conductors (metals) and insulators (dielectrics) look. Light has a really hard time getting absorbed by metals. Instead, it is just reflected, so the majority of light coming from a metal are the specular parts, not diffuse.
Besides being able to accurately portray a vast array of materials, it also makes representing them in textures more intuitive. All that needs to be controlled is the albedo color, the 'smoothness' of the material and whether or not it is a metal.
A bit about the engine...
While Unity 5 in its beta stage provides physically based shaders and ambient lighting capabilities, many features covered in the next posts of this series, like improved shadows, light culling and others would not be possible without completely recreating the rendering pipeline. With the help of Jove, we did just that! Replacing Unity's "black box" graphics renderer with a fully customizable alternative provides great freedom in the techniques that can be used to achieve the “perfect image”.
As hinted above, the next post of the series will jump back to the beginning and answer where exactly all this light came from in the first place. In the meantime, have a look at some of our physically correct creations!