Physically based shading means that the lighting and shading algorithms used in Unreal Engine 4 approximate the physical interaction between light and materials, the units used are common physical measurements, and material definitions are simple to translate from reality. In the past developers had to tweak many variables to achieve the look they desired and many times would have unpredictable results in different lighting scenarios. Physically based shading allows developers to create content that will be consistently high quality and predictable in many lighting scenarios.
Here are the ways that Physically based rendering affects content creators inside of Unreal Engine 4.
When calculating lighting, UE4 uses algorithms and units that are as close to physically accurate as possible. For example, light intensity is provided in lumens and the light intensity falls off at a rate that follows the inverse square law. This means that the light is very bright close to the light source, and then gets dim very quickly as distance to the light source is increased. This level of accuracy helps give the scene a broader range of light which in turn allows for other features like Global Illumination and Reflections to really shine.
The first image shows a light with inverse square falloff on the left, and a light with exponential falloff on the right. The second image shows a scene lit by a single spotlight with inverse square falloff and it shows how the high dynamic range of lighting affects reflections and global illumination.
Since every surface in reality has some form of specular reflection, UE4 gives every material specular highlights and scene reflections. The amount of reflection is also affected by how the surface is angled in relation to the camera. If the surface is non-metal and facing the camera it will specularly reflect about 4% of light; if the surface is at a grazing angle to the camera it will specularly reflect almost 100% of light.
This image shows how the amount of specular reflection changes as the surface faces the camera.
When shading materials, UE4 also follows the law of conservation of energy. This is easily visible when changing the roughness of a material. If you create a material with very low roughness it has a very small but very bright highlight. As you increase the roughness the highlight becomes larger and very dim. This is because the same amount of light is being reflected over a larger area, making it appear less bright.
The following image shows a material with a roughness of 0.1, 0.5 and finally 0.9.
The biggest change to materials is probably the introduction of the metalness input. In reality metals and non-metals are shaded very differently. While non-metals are mostly diffusely shaded with around 4% specular reflection, metals have no diffuse reflection and are 100% specular reflection. In UE4 this means that if you have metalness set to 0, your BaseColor input is used for diffuse shading color. If metalness is set to 1, BaseColor is used for specular reflection color and diffuse color is set to black.
The following image shows a material with a metalness of 0, then the same material with a metalness of 1.
The second change that will be useful to understand is how to use roughness to approximate surfaces you see in reality. When you view a surface that has almost no highlight you may be inclined to decrease the specularity, instead you should increase the roughness. Since highlights get dimmer as the roughness increases, this is a more physically accurate method of approximating dull surfaces such as chalkboard. The specular input is rarely used in UE4; in practice it’s occasionally been useful to remove specularity from areas that would receive micro-occlusion caused by details in the normal map that aren’t present in the geometry.
In the following image you can see the surface on the left has a roughness of 0, and appears to have much more specular reflection than the surface on the right which has a roughness of 1.
If you want to learn more about physically based material, don’t forget to check out our official documentation. And as always, if you have any questions, please feel free to drop by our forums or find me over on Twitter at @Mutantspoon!
The first preview for Unreal Engine 4.19 is now available for download o...