diff options
| author | yum <yum.food.vr@gmail.com> | 2025-11-11 17:26:35 -0800 |
|---|---|---|
| committer | yum <yum.food.vr@gmail.com> | 2025-11-11 17:26:35 -0800 |
| commit | cb101b9bd1f0e9dbfcfe45d114d1a63af3e85d82 (patch) | |
| tree | 117733c30b5888ad24143e09cd0afa3510048cc3 /lighting.cginc | |
| parent | b11eecd7e4bf9cd5d1cdf95a5e995a39c59ca4bf (diff) | |
fix energy conservation issues; notably smooth=0 metallic=1 matches filamented now
Diffstat (limited to 'lighting.cginc')
| -rw-r--r-- | lighting.cginc | 5 |
1 files changed, 4 insertions, 1 deletions
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)); |
