summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--brdf.cginc5
1 files changed, 3 insertions, 2 deletions
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);