diff options
| author | yum <yum.food.vr@gmail.com> | 2025-11-11 16:50:04 -0800 |
|---|---|---|
| committer | yum <yum.food.vr@gmail.com> | 2025-11-11 16:50:04 -0800 |
| commit | 2f6b174fdb649b2dcd1f6e0751d5d03585ce1f70 (patch) | |
| tree | 1cc3ad05f69a2148d7b9ae56c662147434059699 /brdf.cginc | |
| parent | af1d995a9ea92de599caae0977c0a43ee4c27140 (diff) | |
Fix IBL specular energy conservation
Diffstat (limited to 'brdf.cginc')
| -rw-r--r-- | brdf.cginc | 5 |
1 files changed, 3 insertions, 2 deletions
@@ -229,8 +229,9 @@ float4 brdf(Pbr pbr, LightData data) { // UnityStandardBRDF.cginc :: BRDF1_Unity_PBS float surface_reduction = 1.0f / (pbr.roughness * pbr.roughness + 1.0f); const float F = F_Schlick(data.indirect.NoL, f0_spec, f90); - specular += surface_reduction * indirect_specular * F; - remainder -= F; + const float3 is_conserved = surface_reduction * indirect_specular * F; + specular += is_conserved; + remainder = saturate(remainder - is_conserved); // Diffuse is Lambertian, which is pre-integrated into the SH diffuse probe float3 indirect_diffuse = pbr.albedo.xyz * data.indirect.diffuse * remainder * (1.0 - pbr.metallic); |
