From da12f242c6d8da930aa3c2e90fd21a637cd1f195 Mon Sep 17 00:00:00 2001 From: yum Date: Mon, 20 Jul 2026 16:35:51 -0700 Subject: Add glitter normal map override option --- math.cginc | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'math.cginc') diff --git a/math.cginc b/math.cginc index 0692440..270ca15 100755 --- a/math.cginc +++ b/math.cginc @@ -334,4 +334,12 @@ float3 srgb_to_linear(float3 srgb_color) { return lerp(lo, hi, step(0.04045f, srgb_color)); } +float3x3 tbn_from_normal_tangent(float3 normal, float4 tangent) { + float3 n = normal; + float3 t = tangent.xyz; + t = normalize(t - n * dot(n, t)); // Gram-Schmidt to avoid skew + float3 b = normalize(cross(n, t)) * tangent.w; + return float3x3(t, b, n); +} + #endif // __MATH_INC -- cgit v1.2.3