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 /pbr.cginc | |
| parent | 87e0f98e6d4e2774c08763c94aa21ad68b0b13f9 (diff) | |
Implement bent normals
Diffstat (limited to 'pbr.cginc')
| -rwxr-xr-x | pbr.cginc | 16 |
1 files changed, 16 insertions, 0 deletions
@@ -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; } |
