From 2a5186af2dce81d7d630f2969cfc5bcf2e2ddd66 Mon Sep 17 00:00:00 2001 From: yum Date: Tue, 25 Mar 2025 17:03:16 -0700 Subject: Add letter grid gimmick --- math.cginc | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'math.cginc') diff --git a/math.cginc b/math.cginc index 2f05054..f44aa74 100644 --- a/math.cginc +++ b/math.cginc @@ -55,7 +55,7 @@ float rand3(float3 p) return frac(rand3_hash(p).x); } -float2 domainWarp1(float x, uint octaves, float strength, float scale) +float2 domainWarp1(float x, uint octaves, float strength, float scale, float speed) { [loop] for (uint i = 0; i < octaves; i++) { @@ -66,14 +66,14 @@ float2 domainWarp1(float x, uint octaves, float strength, float scale) return x; } -float2 domainWarp2(float2 uv, uint octaves, float strength, float scale) +float2 domainWarp2(float2 uv, uint octaves, float strength, float scale, float speed) { uv *= 0.001; [loop] for (uint i = 0; i < octaves; i++) { uv += strength * frac(sin(float2( dot(uv * scale, float2(12.9898, 78.233)), - dot(uv * scale, float2(36.7539, 50.3658))) * 43758.5453123)); + dot(uv * scale, float2(36.7539, 50.3658)))) * 43758.5453123); } uv *= 1000; return uv; @@ -198,4 +198,13 @@ float3 luminance(float3 color) { return dot(color, float3(0.2126, 0.7152, 0.0722)); } +float median(float3 x) { + // Get the min and max. + float x_min= min(min(x.r, x.g), x.b); + float x_max = max(max(x.r, x.g), x.b); + + // Compute (x.r + x.g + x.b) - (x_min + x_max). This gives us the median. + return (x.r + x.g + x.b) - (x_min + x_max); +} + #endif // __MATH_INC -- cgit v1.2.3