From 0264f5e767b0b54e82b7c11457b491be555be577 Mon Sep 17 00:00:00 2001 From: yum Date: Wed, 26 Feb 2025 01:18:09 -0800 Subject: Add glitter and more masked stencil channels --- math.cginc | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'math.cginc') 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 -- cgit v1.2.3