CHAO BIAN / SELECTED WORKAll projects ↗
COMPUTER GRAPHICS / RENDERING STUDYUNITY · HLSL / CG

Unity PBR
ShaderFrom BRDF to material response.

Implementing a physically based shader in Unity, integrating environment lighting, and tracing visual differences back to the math and material inputs.

Refined bronze Corinthian helmet reflecting the Mirrored Hall environment
Bronze / Custom PBR · Mirrored Hall environment

00 / Visual reference

Comparing with
Unity Standard.

After aligning the shading conventions and smoothness inputs, the helmet materials produced a close visual match in the tested scene.

BronzeCustom PBR ↔ Unity Standard
Bronze rendered with Unity Standard
Bronze rendered with the custom PBR shader
Custom PBRStandard
Oxidized metalCustom PBR ↔ Unity Standard
Oxidized metal rendered with Unity Standard
Oxidized metal rendered with the custom PBR shader
Custom PBRStandard

The tested materials and scene show a close visual match, with subtle local brightness differences remaining along the lower cheek guards, most visibly in bronze. Both pairs use the same crop and scale; the implementation focuses on opaque ForwardBase shading.

01 / The project

Understanding what
makes a material
look right.

This study connects the microfacet BRDF to a working real-time material, using Unity Standard as a visual and implementation reference.

The project includes two shaders, refined through comparison with Unity’s Built-in implementation. PBR_simple evaluates direct lighting with a simple ambient term. PBR_IBL extends the same material model with Unity’s environment-lighting data.

My work covers the shading logic, material input conventions, and debugging. Unity supplies the lightmaps, SH coefficients, and prefiltered probe textures; I implemented how the shader reads and combines them.

02 / Implementation

One material.
Two sources of light.

Direct light is evaluated from the scene light. Environment light is reconstructed from data prepared by Unity, with the material still controlling the response at runtime.

  1. 01

    Material inputs

    Albedo, tangent-space normals, metallic R, smoothness A, occlusion G, and emission.

  2. 02

    Direct lighting

    GGX distribution, Smith joint visibility approximation, Schlick Fresnel, and Disney diffuse.

  3. 03

    Environment lighting

    Skybox SH supplies diffuse illumination in this scene; prefiltered reflection probes supply specular illumination.

  4. 04

    Composition

    Light attenuation and shadows, indirect diffuse and specular, emission, then fog.

fspecular = D × V × F

D describes the microfacet normal distribution; V includes masking, shadowing, and denominator normalization; F is Fresnel reflectance.

Lighting breakdown

Bronze helmet with direct lighting only: concentrated highlights and mostly dark unlit regions
Direct lighting

Main-light diffuse and specular contributions.

Bronze helmet illuminated by environment lighting, showing broad reflections and surface detail
Environment lighting

Skybox SH supplies environment diffuse; reflection probes supply environment specular.

Bronze helmet with direct and environment lighting combined
Combined / Final render

Main-light and environment contributions combined.

Under this lighting setup, environment reflections dominate the bronze helmet’s appearance, while the main light adds localized highlights.

SH & Light Probes

SH compactly represents low-frequency directional lighting; Light Probes provide spatial lighting samples. The shader evaluates SH using the surface normal for environment diffuse.

Reflection Probes

Probes store the surrounding environment in cubemaps. The shader samples by reflection direction and selects a prefiltered mip by roughness. Box Projection corrects parallax in local reflections.

Lightmaps

Lightmaps store baked illumination in surface textures. The shader reads them using lightmap UVs for baked diffuse lighting.

Final color = direct lighting + indirect diffuse + indirect specular + emission

03 / A debugging case

The BRDF was only
part of the difference.

A material input mismatch explained an important part of the visual gap.

Trace the material input.

  1. Problem

    The metal helmet had sharper reflections and deeper dark regions than Standard.

  2. Cause

    The custom shader read roughness from a separate texture’s R channel; Standard used Metallic Alpha × Smoothness. The resulting roughness values differed.

  3. Fix & result

    Aligning Metallic Alpha × Smoothness narrowed the visual gap, alongside the BRDF and environment-response corrections.

THE MATERIAL CONVENTION

Aligning the
smoothness input.

smoothness = metallicSample.a * _Smoothness;
roughness = 1.0 - smoothness;
alpha = max(roughness * roughness, 0.002);

With a varying Alpha channel, Smoothness = 0.75 does not mean a constant roughness of 0.25.

Project iteration

Initial bronze helmet with sharp, concentrated highlights and deeper dark regions
Early project state
Refined bronze helmet with broader reflections and more continuous surface shading
Final project state

04 / What I learned

From a reflectance model
to a working material.

Building this shader connected the BRDF equations to visible material response. Aligning smoothness inputs enabled a more consistent comparison with Standard, while separating direct and environment lighting showed how each contribution shapes the helmet’s highlights and surface detail.

Connecting to my CPU Path Tracer

My CPU Path Tracer samples ray paths and uses Monte Carlo estimation to evaluate light transport. This Unity shader evaluates the main light directly and combines it with environment-lighting data prepared by Unity. Together, the projects helped me understand how similar material models can be evaluated under different computational budgets.

Related study / CPU Path Tracer ↗