summaryrefslogtreecommitdiffstats
path: root/math.cginc
diff options
context:
space:
mode:
Diffstat (limited to 'math.cginc')
-rw-r--r--math.cginc9
1 files changed, 9 insertions, 0 deletions
diff --git a/math.cginc b/math.cginc
index f3af30a..85fe4ea 100644
--- a/math.cginc
+++ b/math.cginc
@@ -5,7 +5,9 @@
#define PI 3.14159265358979323846264
#define TAU (2 * PI)
+#define HALF_PI (PI * 0.5)
#define PHI 1.618033989
+#define SQRT_2_RCP 0.707106781
float pow5(float x)
{
@@ -175,6 +177,13 @@ void domainWarp3Normals(inout float3 normal, inout float3 tangent, float3 basePo
tangent = normalize(mul(J, tangent));
}
+// Alpha blend `dst` onto `src`.
+// Imagine two transparent planes. We're rendering a situation where you're
+// looking through `front` at `behind`.
+float4 alphaBlend(float4 behind, float4 front) {
+ return float4(front.rgb * front.a + behind.rgb * (1 - front.a), front.a + behind.a * (1 - front.a));
+}
+
#endif // __MATH_INC