diff options
Diffstat (limited to 'math.cginc')
| -rwxr-xr-x | math.cginc | 8 |
1 files changed, 8 insertions, 0 deletions
@@ -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 |
