In this lesson, you will learn how to use metallic masking to precisely define which areas of your materials behave as conductive metals and which behave as non-conductive dielectrics.
The Physics of Conductivity
In a PBR (Physically Based Rendering) workflow, materials are classified into two main categories: dielectrics (insulators like wood, plastic, or stone) and conductors (metals). Metals interact with light differently; they do not have a diffuse "albedo" color in the traditional sense. Instead, their base color represents the color of the specular reflection itself, often featuring an "edge tint" where reflections become more intense at grazing angles according to the Fresnel effect.
Implementing the Metallic Mask
If you use a single "Metallic" slider for your entire material, every pixel reacts to light as either fully metal or fully plastic. This is rarely realistic for objects that feature wear, grime, or mixed materials. A Metallic Mask is a grayscale texture where:
- Black (0.0): Defines the area as a dielectric. The shader uses the Albedo map for color and creates white specular highlights.
- White (1.0): Defines the area as a conductor. The shader treats the Albedo color as the reflection color, tinting the specular highlights accordingly.
Practical Workflow
To implement this, you typically pack your metallic map into the Metallic/Smoothness channel of your material. In the Unity Inspector, assign your texture to the Metallic slot. If you are authoring your own shaders, the logic inside your pixel shader (HLSL) behaves like this:
// Conceptual metallic blending
float metallic = tex2D(_MetallicMap, uv).r;
float3 finalColor = lerp(albedo.rgb, metallicColor, metallic);
By painting a mask, you can show a rusty iron pipe where the iron areas are fully metallic (tinting reflections and exhibiting Fresnel edge effects), while the oxidized, rusty patches are masked as dielectrics (returning to matte, diffuse-based light interaction). This ensures that your materials respond consistently to the reflection probes and light sources you’ve already configured in your scene.
Key Takeaway: A metallic mask allows you to blend between dielectric and conductive surface properties, ensuring that only the metallic portions of your texture exhibit the distinct edge-tinting and reflection characteristics required for physical accuracy.