diff options
| author | yum <yum.food.vr@gmail.com> | 2026-02-23 22:44:17 -0800 |
|---|---|---|
| committer | yum <yum.food.vr@gmail.com> | 2026-02-23 22:44:17 -0800 |
| commit | ede8bbae3496315e5ef821d4c00cf04022a3d453 (patch) | |
| tree | 288770e1ce30fb71efb3744aec289108362c91a2 /lighting.cginc | |
| parent | 87e0f98e6d4e2774c08763c94aa21ad68b0b13f9 (diff) | |
Implement bent normals
Diffstat (limited to 'lighting.cginc')
| -rwxr-xr-x | lighting.cginc | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/lighting.cginc b/lighting.cginc index d5e0be8..e56bb37 100755 --- a/lighting.cginc +++ b/lighting.cginc @@ -174,11 +174,15 @@ float3 yumSH9(float4 n, float3 worldPos, inout LightIndirect light) { float4 getIndirectDiffuse(v2f i, Pbr pbr, inout LightIndirect light) { float4 diffuse = 0; #if defined(FORWARD_BASE_PASS) +#if defined(_BENT_NORMALS) + diffuse.xyz += max(0, yumSH9(float4(pbr.bent_normal, 1.0), i.worldPos, light)); +#else diffuse.xyz += max(0, yumSH9(float4(i.normal, 1.0), i.worldPos, light)); #endif +#endif #if defined(_AMBIENT_OCCLUSION) - diffuse.xyz *= saturate(lerp(1, _OcclusionMap.Sample(bilinear_repeat_s, i.uv01.xy), _OcclusionStrength)); + diffuse.xyz *= pbr.ao; #endif return diffuse; @@ -233,6 +237,18 @@ void GetLighting(v2f i, Pbr pbr, out LightData data) { data.indirect.diffuse = getIndirectDiffuse(i, pbr, data.indirect); data.indirect.specular = getIndirectSpecular(i, pbr.roughness_perceptual, view_dir, -data.indirect.dir); +#if defined(_AMBIENT_OCCLUSION) || defined(_BENT_NORMALS) + float ao_vis = 1.0; +#if defined(_AMBIENT_OCCLUSION) + ao_vis = pbr.ao; +#endif +#if defined(_BENT_NORMALS) + float3 spec_ao_bent = pbr.bent_normal; +#else + float3 spec_ao_bent = pbr.normal; +#endif + data.indirect.specular *= computeSpecularAO(data.common.NoV, ao_vis, pbr.roughness, spec_ao_bent, -data.indirect.dir); +#endif #if defined(_CLEARCOAT) data.indirect.specular_cc = getIndirectSpecular(i, saturate(sqrt(pbr.cc_roughness)), view_dir, dir_cc); #if defined(_CLEARCOAT_MASK) |
