summaryrefslogtreecommitdiffstats
path: root/math.cginc
diff options
context:
space:
mode:
authoryum <yum.food.vr@gmail.com>2025-02-27 18:02:04 -0800
committeryum <yum.food.vr@gmail.com>2025-02-27 18:02:04 -0800
commitef6b610577f851d8c70840f945c0ec2161450302 (patch)
tree19c24eb03adb6b735ef1ed1789b42699b2871659 /math.cginc
parentd10dca271fd69606bde8e0a0e104db9140bfe52e (diff)
Add detail maps
Diffstat (limited to 'math.cginc')
-rw-r--r--math.cginc10
1 files changed, 10 insertions, 0 deletions
diff --git a/math.cginc b/math.cginc
index 85fe4ea..436cc56 100644
--- a/math.cginc
+++ b/math.cginc
@@ -184,6 +184,16 @@ float4 alphaBlend(float4 behind, float4 front) {
return float4(front.rgb * front.a + behind.rgb * (1 - front.a), front.a + behind.a * (1 - front.a));
}
+// 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