From fb48528cbb1881ff8ac96a1cd05c2c7aa326b203 Mon Sep 17 00:00:00 2001 From: yum Date: Tue, 11 Nov 2025 16:20:14 -0800 Subject: add detail map feature --- math.cginc | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'math.cginc') diff --git a/math.cginc b/math.cginc index c37ce07..02d0fe0 100644 --- a/math.cginc +++ b/math.cginc @@ -89,5 +89,15 @@ float3 round_hex(float3 hex_coord) { return rounded; } +// Reoriented normal mapping +// https://blog.selfshadow.com/publications/blending-in-detail/ +// Inputs are in tangent space. +float3 blendNormalsHill12(float3 n0, float3 n1) { + n0.z += 1.0; + n1.xy = -n1.xy; + + return normalize(n0 * dot(n0, n1) - n1 * n0.z); +} + #endif // __MATH_INC -- cgit v1.2.3