Physically Based Rendering
This MR introduces a new material rendering shader based on physical properties.
On the classic material rendering (Phong), the user can set his material with an ambient color, a diffuse color (that can be mapped using a texture) and a specular color/power.
This new shader drops the ambient color (see Image Based Lighting part) and computes automatically diffuse and specular parts based on three parameters:
- Base Color (RGB): also called albedo, this is the color of the object without shading.
- Metallic (float): in the real world, common objects are either metallic or non-metallic (dielectric) and shading is different depending on this parameter.
- Roughness (float): parameter used to specify how an object is glossy.
With this new shader, the energy (light) received by the object is conserved and correctly distributed to the diffuse and specular part without having to tune them manually.
When an object contains texture coordinates, normals, tangents and bitangents (a new filter
vtkPolyDataTangents is available to compute tangents), it is possible to attach a normal texture on the
vtkProperty using the method
SetNormalTexture to handle normal mapping.
The user can also specify three special textures using
SetEmissiveTexture in order to get albedo, material, and emissive values depending on the texture coordinate of the fragment.
The material texture (ORM) contains the ambient [O]cclusion, [R]oughness and [M]etallic value on the R,G,B channel respectively.
Ambient occlusion is used to make a fragment darker simulating small shadows.
Emissive texture simulates emission of light.
Image Based Lighting
Ambient color is coming from the environment.
In order to compute this correctly, the shader can access to precomputed (on the GPU) textures which are generated from a cubemap texture describing the environment (i.e. the skybox).
vtkPBRIrradianceTexture: used to compute the diffuse part of the environment.
vtkPBRPrefilterTexture: used to compute the specular part of the environment.
vtkPBRLUTTexture: used to compute the Fresnel coefficient based on roughness and angle between light and normal. Those textures are automatically added to the renderer, the user has to enable this feature using
vtkRenderer::UseImageBasedLightingOn()and setting the input cubemap environment texture.
Comparison of shaders
Left: Classic (Phong) VTK shading, Right: PBR VTK shading
Examples of materials
Comparison of 3 dielectric (top) and 2 metallic (bottom) materials, roughness varying from 0 (left) to 1 (right)