From ede8bbae3496315e5ef821d4c00cf04022a3d453 Mon Sep 17 00:00:00 2001 From: yum Date: Mon, 23 Feb 2026 22:44:17 -0800 Subject: Implement bent normals --- pbr.cginc | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'pbr.cginc') diff --git a/pbr.cginc b/pbr.cginc index 25d6ece..5e19089 100755 --- a/pbr.cginc +++ b/pbr.cginc @@ -16,6 +16,12 @@ struct Pbr { float roughness_perceptual; float roughness; float metallic; +#if defined(_AMBIENT_OCCLUSION) + float ao; +#endif +#if defined(_BENT_NORMALS) + float3 bent_normal; +#endif #if defined(_CLEARCOAT) float cc_roughness; float cc_strength; @@ -208,6 +214,12 @@ Pbr getPbr(v2f i) { pbr.normal = normalize(mul(normal_tangent, pbr.tbn)); +#if defined(_BENT_NORMALS) + float3 bent_ts = UnpackNormal(_Bent_Normals_Map.Sample(aniso4_trilinear_repeat_s, uv_parallax * _Bent_Normals_Map_ST.xy + _Bent_Normals_Map_ST.zw)); + bent_ts.xy *= _Bent_Normals_Strength; + pbr.bent_normal = normalize(mul(bent_ts, pbr.tbn)); +#endif + float4 metallic_gloss = _MetallicGlossMap.Sample(aniso4_trilinear_repeat_s, uv_parallax * _MetallicGlossMap_ST.xy); pbr.smoothness = metallic_gloss.a * _Glossiness; pbr.metallic = metallic_gloss.r * _Metallic; @@ -219,6 +231,10 @@ Pbr getPbr(v2f i) { #endif propagateSmoothness(pbr); +#if defined(_AMBIENT_OCCLUSION) + pbr.ao = saturate(lerp(1.0, _OcclusionMap.Sample(bilinear_repeat_s, i.uv01.xy).r, _OcclusionStrength)); +#endif + return pbr; } -- cgit v1.2.3