From cb101b9bd1f0e9dbfcfe45d114d1a63af3e85d82 Mon Sep 17 00:00:00 2001 From: yum Date: Tue, 11 Nov 2025 17:26:35 -0800 Subject: fix energy conservation issues; notably smooth=0 metallic=1 matches filamented now --- lighting.cginc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'lighting.cginc') diff --git a/lighting.cginc b/lighting.cginc index 4e5a61b..5f66b80 100644 --- a/lighting.cginc +++ b/lighting.cginc @@ -188,7 +188,10 @@ void GetLighting(v2f i, Pbr pbr, out LightData data) { data.direct.color = lightColorIntensity.rgb * lightColorIntensity.w; // Indirect lighting - data.indirect.dir = -reflect(data.common.V, pbr.normal); + float3 reflect_dir = -reflect(data.common.V, pbr.normal); + float3 dominant_dir = getSpecularDominantDirection(pbr.normal, reflect_dir, pbr.roughness); + + data.indirect.dir = normalize(dominant_dir); data.indirect.H = normalize(data.common.V + data.indirect.dir); data.indirect.NoL = saturate(dot(pbr.normal, data.indirect.dir)); data.indirect.NoH = saturate(dot(pbr.normal, data.indirect.H)); -- cgit v1.2.3