#Chebyshev Voronoi Edges
1 messages ยท Page 1 of 1 (latest)
inline float2 voronoi_noise_randomVector (float2 UV, float offset)
{
float2x2 m = float2x2(15.27, 47.63, 99.41, 89.98);
UV = frac(sin(mul(UV, m)) * 46839.32);
return float2(sin(UV.y*+offset)*0.5+0.5, cos(UV.x*offset)*0.5+0.5);
}
float EuclideanSquared(float2 v){
return dot(v, v);
}
float Chebyshev(float2 v){
return max(abs(v.x), abs(v.y));
}
void ChebyshevVoronoiF1F2_float(float2 UV, float AngleOffset, float CellDensity, out float F1, out float F2, out float Cells)
{
float2 g = floor(UV * CellDensity);
float2 f = frac(UV * CellDensity);
float3 res = float3(8.0, 8.0, 8.0);
for(int y=-1; y<=1; y++){
for(int x=-1; x<=1; x++){
float2 lattice = float2(x, y);
float2 offset = voronoi_noise_randomVector(g + lattice, AngleOffset);
float2 v = lattice + offset - f;
float d = Chebyshev(v);
if(d < res.x){
res.y = res.x;
res.x = d;
res.z = offset.x;
}else if (d < res.y){
res.y = d;
}
}
}
F1 = sqrt(res.x);
F2 = sqrt(res.y);
Cells = res.z;
}
@haughty sedge Moved into thread
Setup in graph looks like this -
It's basically the "less accurate" F2-F1 method I mention on my old site (https://cyangamedev.wordpress.com/2019/07/16/voronoi/), but with distance method swapped out
progress on my end as well, I managed to get it working but to do so I had to gut ALL the features
so my version has none of the good stuff yours has
reading your post and code now ๐
mine currently looks like this:
float2 rnd2(float2 p)
{
float2 sines = sin(float2(dot(p, float2(127.1, 311.7)), dot(p, float2(269.5, 183.3))));
return frac(sines * 43758.5453);
}
float2 srnd2(float2 p)
{
return 2 * rnd2(p) - 1;
}
void NewVoronoi_float(float2 UV, float Time, out float cellDist)
{
UV /= 100.0;
float m = 1e9, m2, v;
const int N = 3;
const float R = .5;
for (int k = 0; k < N * N; k++)
{
float2 iU = floor(UV) + .5;
float2 g = iU + float2(k % N, k / N) - 1.0;
float2 p = g + srnd2(g) * R - UV
+ .1 * sin(Time + float2(1.6, 0) + 3.14 * srnd2(g));
p = abs(p);
v = max(p.x, p.y);
if (v < m)
{
m2 = m;
m = v;
}
else if (v < m2)
{
m2 = v;
}
}
v = m2 - m;
cellDist = v;
}```
and is based on directly porting this shadertoy:
https://www.shadertoy.com/view/MtlyR8
Ah neat, I think it's doing the same sort of thing
It does leave some gaps in the result but I'm not too sure how to make it more accurate atm
Honestly gaps are fine, I expected the output to look a little messy for its use (going for a circuit board look) so the unfilled triangles here and there likely wont be noticable
this person has a solve that has no gaps
but their solve is massive comparatively
and does a ton of stuff I can't easily parse due to not being sure which stuff does what bit 
Thank you again as usual, your insight is always instrumental for overcoming the final bugfixing hurdles 
I hope someday I can do the same for others ๐ฃ perseverance!
Interesting, yeah looks quite complicated. I think it's mostly because with the euclidean version there's a simple midpoint between two points which is perpendicular to the edge.
With other distance functions you don't have that so I guess it requires more complex maths. It's a bit beyond my knowledge too though.
Same
๐ฆ