From 2f6b174fdb649b2dcd1f6e0751d5d03585ce1f70 Mon Sep 17 00:00:00 2001 From: yum Date: Tue, 11 Nov 2025 16:50:04 -0800 Subject: Fix IBL specular energy conservation --- brdf.cginc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'brdf.cginc') diff --git a/brdf.cginc b/brdf.cginc index 1cb4d33..46b28e8 100644 --- a/brdf.cginc +++ b/brdf.cginc @@ -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); -- cgit v1.2.3