Hi,

I’m trying to make a material where the scale of the texture is driven by a map. The problem i have is that i cant’ get a smooth transition between two scales. how can i get rid of the squished lines between the diferent parts?

A “curves” node can provide an arbitrary mapping between an input and an output. You could use this to let you fine-tune the various inputs at one-or-more stages in your noodle.

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…

This is exactly what i’m tring to do. unfortunatly I don’t know the first thing about coding. Would this be possible with nodes? would the same trick work for other generated textures as well?

For GPU rendering, it’s difficult, but not impossible. It will require loops inside loops (an example of a 2d voronoi here). Some functions will be limited, like the cellnoise(), or sampling an area of some bitmap… But you can still get good results with alternatives (noise texture, single point sampling, etc).