The Physically Based RenderingThe process of drawing graphics to the screen (or to a render texture). By default, the main camera in Unity renders its view to the screen. More info
See in Glossary Material Validator is a draw mode in the Scene ViewAn interactive view into the world you are creating. You use the Scene View to select and position scenery, characters, cameras, lights, and all other types of Game Object. More info
See in Glossary. It allows you to make sure your materials use values which fall within the recommended reference values for physically-based shadersA small script that contains the mathematical calculations and algorithms for calculating the Color of each pixel rendered, based on the lighting input and the Material configuration. More info
See in Glossary. If pixel values in a particular Material fall outside of the reference ranges, the Material Validator highlights the pixelsThe smallest unit in a computer image. Pixel size depends on your screen resolution. Pixel lighting is calculated at every screen pixel. More info
See in Glossary in different colors to indicate failure.
To use the Material Validator, select the SceneA Scene contains the environments and menus of your game. Think of each unique Scene file as a unique level. In each Scene, you place your environments, obstacles, and decorations, essentially designing and building your game in pieces. More info
See in Glossary View’s draw mode drop-down menu, which is is usually set to Shaded by default.
Navigate to the Material Validation section. The Material Validator has two modes: Validate Albedo and Validate Metal Specular.
Note: You can also check the recommended values with Unity’s Material Charts. You still need to use these charts when authoring Materials to decide your albedo and metal specular values. However, the Material Validator provides you with a visual, in-editor way of quickly checking whether your Materials’ values are valid once your Assets are in the Scene.
Also note: The validator only works in Linear color space. Physically Based Rendering is not intended for use with Gamma color space, so if you are using Physically Based Rendering and the PBR Material Validator, you should also be using Linear color space.
The PBR Validation Settings that appear in the Scene view when you set Material Validation to Validate Albedo.
Property: | Function: | |
---|---|---|
Check Pure Metals | Enable this checkbox if you want the Material Validator to highlight in yellow any pixels it finds which Unity defines as metallic, but which have a non-zero albedo value. See Pure Metals, below, for more details. By default, this is not enabled. | |
Luminance Validation | Use the drop-down to select a preset configuration for the Material Validator. If you select any option other than Default Luminance, you can also adjust the Hue Tolerance and Saturation Tolerance. The color bar underneath the name of the property indicates the albedo color of the configuration. The Luminance value underneath the drop-down indicates the minimum and maximum luminance value. The Material Validator highlights any pixels with a luminance value outside of these values. This is set to Default Luminance by default. | |
Hue Tolerance | When checking the albedo color values of your material, this slider allows you to control the amount of error allowed between the hue of your material, and the hue in the validation configuration. | |
Saturation Tolerance | When checking the albedo color values of your material, this slider allows you to control the amount of error allowed between the saturation of your material, and the saturation in the validation configuration. | |
Color Legend | These colors correspond to the colours that the Material Validator displays in the Scene view when the pixels for that Material are outside the defined values. | |
Red Below Minimum Luminance Value | The Material Validator highlights in red any pixels which are below the minimum luminance value defined in Luminance Validation (meaning that they are too dark). | |
Blue Above Maximum Luminance Value | The Material Validator highlights in blue any pixels which are above the maximum luminance value defined in Luminance Validation (meaning that they are too bright). | |
Yellow Not A Pure Metal | If you have Check Pure Metals enabled, the Material Validator highlights in yellow any pixels which Unity defines as metallic, but which have a non-zero albedo value. See Pure Metals, below, for more details. |
Unity’s Material charts define the standard luminance range as 50–243 sRGB for non-metals, and 186–255 sRGB for metals. Validate Albedo mode colors any pixels outside of these ranges with different colors to indicate that the value is too low or too high.
In the example below, the first texture is below the minimum luminance value, and therefore too dark. The fourth texture is above the maximum luminance value, and therefore too bright.
The material charts provide albedo values for common Materials. The brightness of albedo values has a dramatic impact on the amount of diffuse bounce light generated, so it is important for Global IlluminationA group of techniques that model both direct and indirect lighting to provide realistic lighting results. Unity has two global illumination systems that combine direct and indirect lighting.: Baked Global Illumination, and Realtime Global Illumination (deprecated).
See in Glossary baking to make sure that your different Material types are within the correct luminance ranges, in proportion with each other. To help you get these values right, you can select from the presets in the Luminance Validation drop-down, which provides common Material albedo values to verify the luminance ranges of particular Material types.
Depending on the art style of your project, you might want the luminance values of Materials to differ from the preset luminance ranges. In this case, you can override the built-in albedo values used by the Material Validator with your own values. To override the preset luminance ranges, assign an array of AlbedoSwatchInfo values for each desired Material type to the property EditorGraphicsSettings.albedoSwatches.
The PBR Validation Settings that appear in the Scene view when you set Material Validation to Validate Metal Specular.
Property: | Function: | |
---|---|---|
Check Pure Metals | Enable this checkbox if you want the Material Validator to highlight in yellow any pixels it finds which Unity defines as metallic, but which have a non-zero albedo value. See Pure Metals, below, for more details. By default, this is not enabled. | |
Color Legend | These colors correspond to the colours that the Material Validator displays in the Scene view when the pixels for that Material are invalide - meaning their specular value falls outside the valid range for that type of material (metallic or non-metallic). See below this table for the valid ranges. | |
Blue Below Minimum Specular Value | The Material Validator highlights in red any pixels which are below the minimum specular value. (40 for non-metallic, or 155 for metallic). | |
Red Above Maximum Specular Value | The Material Validator highlights in blue any pixels which are above the maximum specular value. (75 for non-metallic, or 255 for metallic). | |
Yellow Not A Pure Metal | If you have Check Pure Metals enabled, the Material Validator highlights in yellow any pixels which Unity defines as metallic, but which have a non-zero albedo value. See Pure Metals, below, for more details. |
Unity’s Material charts define two separate specular colorThe color of a specular highlight.
See in Glossary ranges:
In Unity, all non-metallic Materials have a constant specular color that always falls within the correct range. However, it is common for metallic Materials to have specular values that are too low. To help you identify metallic Materials with this issue, the Material Validator’s Validate Metal Specular mode colors all pixels that have a specular color value that is too low. This includes all non-metallic materials by definition.
In the example below, the left material is below the minimum specular value, and therefore too dark. This also applies to the Scene’s background. The right material has specular values with in the valid range.
Unity defines physically-based shading materials with a specular color greater than 155 sRGB as metallic. For Unity to define a metallic Material as a pure metal
If a non-metallic surface has a specular color value that is too high, but has a non-zero albedo value, this is often due to an authoring error. The Material Validator also has an option called Check Pure Metals. When you enable this option, the Material Validator colors in yellow any Material that Unity defines as metallic but which has a non-zero albedo value. An example of this can be seen in the images below. It shows three materials, the left and right materials are pure metals, but the middle material is not, so the Material Validator colors it yellow:
In the second image above, the background is red because the Materials in the background are below the minimum specular value for the Material Validator’s Validate Metal Specular mode.
For complex materials that combine metallic and non-metallic properties, the pure metal checker is likely to pick up some invalid pixels, but if a Material is totally invalid, it’s usually a sign of an authoring error.
The Material Validator works with any Materials that use Unity’s Standard shaderA built-in shader for rendering real-world objects such as stone, wood, glass, plastic and metal. Supports a wide range of shader types and combinations. More info
See in Glossary or surface shadersUnity’s code generation approach that makes it much easier to write lit shaders than using low level vertex/pixel shader programs. More info
See in Glossary. However, custom shaders require a pass named “META”
. Most custom shaders that support lightmapping already have this pass defined. See documentation on Meta pass for more details.
Carry out the following steps to make your custom shader compatible with the Material Validator:
#pragma shader_feature EDITOR_VISUALIZATION
UnityMetaInput
structure, assign the specular color of the Material to the field called SpecularColor
, as shown in the code example below.Here is an example of a custom meta pass:
Pass
{
Name "META"
Tags { "LightMode"="Meta" }
Cull Off
CGPROGRAM
#pragma vertex vert_meta
#pragma fragment frag_meta
#pragma shader_feature _EMISSION
#pragma shader_feature _METALLICGLOSSMAP
#pragma shader_feature _ _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
#pragma shader_feature ___ _DETAIL_MULX2
#pragma shader_feature EDITOR_VISUALIZATION
float4 frag_meta(v2f_meta i) : SV_TARGET
{
UnityMetaInput input;
UNITY_INITIALIZE_OUTPUT(UnityMetaInput, input);
float4 materialSpecularColor = float4(1.0f, 0.0f, 0.0f, 1.0f);
float4 materialAlbedo = float4(0.0f, 1.0f, 0.0f, 1.0f);
input.SpecularColor = materialSpecularColor;
input.Albedo = materialAlbedo;
return UnityMetaFragment(input);
}
}