summaryrefslogtreecommitdiffstats
path: root/math.cginc
diff options
context:
space:
mode:
authoryum <yum.food.vr@gmail.com>2025-03-25 17:03:16 -0700
committeryum <yum.food.vr@gmail.com>2025-03-25 17:03:16 -0700
commit2a5186af2dce81d7d630f2969cfc5bcf2e2ddd66 (patch)
tree4ed8dac2899cc5e250551585391dc96f51dfe423 /math.cginc
parentb377dd05175d5bffaeef9c55051cd396c127daef (diff)
Add letter grid gimmick
Diffstat (limited to 'math.cginc')
-rw-r--r--math.cginc15
1 files changed, 12 insertions, 3 deletions
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