This happens because the voronoi texture is not creating points with smaller distances between each other, but scaling the whole coordinate system. As a result you get all those squished parts.
To really avoid this problem, we need to jump inside the voronoi loop…
here’s a quick n’ dirt example how to do it:
#include "stdosl.h"
color cellnoise_color(point p)
{
float r = cellnoise(p);
float g = cellnoise(point(p[1], p[0], p[2]));
float b = cellnoise(point(p[1], p[2], p[0]));
return color(r, g, b);
}
void voronoiD(string dtex, point p, float scale, int count, float da)
{
int xx, yy, zz, xi, yi, zi;
xi = (int)floor(p[0]*scale);
yi = (int)floor(p[1]*scale);
zi = (int)floor(p[2]*scale);
vector phase=vector(2344.3245, 213156.12314, 12314.2135549);
da = 1e10;
for (xx = xi - 1; xx <= xi + 1; xx++) {
for (yy = yi - 1; yy <= yi + 1; yy++) {
for (zz = zi - 1; zz <= zi + 1; zz++) {
float r=texture(dtex, xx/scale, 1-yy/scale, 1/scale, 0.0, 0.0, 1/scale);
float ist=floor(r*r*r*count+1);
int ri=(int)ist;
int dd;
for(dd=0; dd<=ri; dd++){
point ip = point(xx, yy, zz);
point vp = (point)cellnoise_color(ip+dd+phase);
point pd = p*scale - (vp + ip);
float d = length(pd);
vp += point(xx, yy, zz);
da = min(da, d);
}
}
}
}
}
shader node_voronoi_texture(
string densitytexture="",
float Scale = 5.0,
int count=5,
point Vector = P,
output float Fac1 = 0.0)
{
point p = Vector;
float da;
voronoiD(densitytexture, p, Scale, count, da);
Fac1 = fabs(da);
}
There’s still a lot that can be improved here, but it’s already good to give the idea…