summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoryum <yum.food.vr@gmail.com>2026-04-12 17:21:42 -0700
committeryum <yum.food.vr@gmail.com>2026-04-12 17:21:42 -0700
commit66035e375c585f301602c150c26f3699dfb7b055 (patch)
tree4bf9f1aa7e8c42ed51c26e6a04ac56a048c0d2f2
parent900637fddb09fe7e3dda4e2da5fe7c7a8970f91a (diff)
Improve naming in voronoi function
-rwxr-xr-xmath.cginc8
1 files changed, 4 insertions, 4 deletions
diff --git a/math.cginc b/math.cginc
index ee70495..b79d9b6 100755
--- a/math.cginc
+++ b/math.cginc
@@ -215,8 +215,8 @@ float3 domain_warp_3d_tex(Texture3D noise_tex, SamplerState s, float3 uvw,
// Return distance to the nearest cell edge in a Voronoi pattern.
float voronoi_edge_distance(float3 x) {
- float3 p = floor(x);
- float3 f = frac(x);
+ float3 x_floor = floor(x);
+ float3 x_frac = frac(x);
float d1 = 1e6;
float d2 = 1e6;
float3 p1 = 0;
@@ -225,8 +225,8 @@ float voronoi_edge_distance(float3 x) {
for (int k = -1; k <= 1; k++) {
for (int j = -1; j <= 1; j++) {
for (int i = -1; i <= 1; i++) {
- float3 b = float3(i, j, k);
- float3 r = b + hash33_fast(p + b) - f;
+ float3 cell_offset = float3(i, j, k);
+ float3 r = cell_offset + hash33_fast(x_floor + cell_offset) - x_frac;
float d = dot(r, r);
if (d < d1) {
d2 = d1;