diff options
| author | yum <yum.food.vr@gmail.com> | 2025-11-11 16:20:14 -0800 |
|---|---|---|
| committer | yum <yum.food.vr@gmail.com> | 2025-11-11 16:20:14 -0800 |
| commit | fb48528cbb1881ff8ac96a1cd05c2c7aa326b203 (patch) | |
| tree | 8f48bd00c00c0b26e49bbfa84de74509a6032ace /pbr.cginc | |
| parent | 5cbad6aa884ee4c77f6af65cdfceac987f54a227 (diff) | |
add detail map feature
Diffstat (limited to 'pbr.cginc')
| -rw-r--r-- | pbr.cginc | 11 |
1 files changed, 11 insertions, 0 deletions
@@ -4,6 +4,7 @@ #include "filamented.cginc" #include "globals.cginc" #include "interpolators.cginc" +#include "texture_utils.cginc" struct Pbr { float4 albedo; @@ -63,6 +64,16 @@ Pbr getPbr(v2f i) { float3 normal_tangent = UnpackNormal(_BumpMap.Sample(aniso16_trilinear_repeat_s, i.uv01.xy * _BumpMap_ST.xy)); normal_tangent.xy *= _BumpScale; + +#if defined(_DETAILS) + float2 detail_uv = get_uv_by_channel(i, _Details_UV_Channel); + float3 detail_normal = UnpackNormal(_DetailNormalMap.Sample(aniso16_trilinear_repeat_s, detail_uv * _DetailNormalMap_ST.xy)); + detail_normal.xy *= _DetailNormalMapScale; + float detail_mask = _DetailMask.Sample(aniso16_trilinear_repeat_s, detail_uv * _DetailMask_ST.xy).r; + detail_normal.xy *= detail_mask; + normal_tangent = blendNormalsHill12(normal_tangent, detail_normal); +#endif + // Map from tangent space to world space. float3 bitangent = cross(i.normal, i.tangent.xyz) * i.tangent.w; pbr.tbn = float3x3(i.tangent.xyz, bitangent, i.normal); |
