In other words, if F1 returns point X as closest, and another F2 returns the same X as closest, is it possible to ensure that they are always set to the same color?

I assumed this would be the default, but now I'm not sure. I'm working with building a separate program that uses cell noise, and had an idea for finding (and potentially blurring) edges between cells by using |F2-F1| to get an idea of proximity. (When F1 and F2 feature points are equidistant, we should be on the edge between the two.) Naturally, being more programmer than mathematician, I thought I'd check it out in Blender first before implementing it in C or C#.

I'm getting a texture which partially does what I anticipated it would—blur at the edges—but also has a lot of hard edges. My suspicion is that either my math is wrong, or that they're showing up because I'm expecting F1 and F2 to return the same color for the same point, and they aren't.

Illustration of the issue

As you can see above, for some edges it's smoothing perfectly; but for others I have a hard difference. Some of them even smooth to an odd color that doesn't appear to be a simple interpolation of the ones involved. You can see my method in the bottom workspace. Note that parameters for F1 and F2 are always identical.

If I could ensure that F1 and F2 always returned the same color for the same point, I could verify that my math is correct; but they seem to work a little differently.

One thought that came to mind is to generate a random color based on the feature point, available from position, but I'm not currently 100% sure how to do this. I'm aware of "Smooth F1", but since this is an experiment for a program I'm writing, it's more important that I know how to do it with an F1/F2 comparison so I can check my math.


1 Answer 1


So let's simplify your idea a little bit, and look at some raw-er data:

enter image description here

Same voronoi, top and bottom. Top is F2 distance - F1 distance. I've marked some centers roughly with empties so we can keep track of them.

The first thing we should notice is that F2-F1 isn't normalized to the maximum cell radius. That isn't some value we can get. So the highlighted empties, for instance, are all black, because other points are relatively near, and so F2-F1 is small. This is going to impact what we get out of your blurring technique.

This is why the cells aren't a uniform color. F2 is always greater than F1, so we're always mixing. If we only want to mix at the edges, we need to make some choices about limits to that mixing. We can establish those limits with a map range node:

enter image description here

So what I'm saying is that as F2 approaches F1, we want to be mixing half way between the two colors. (This is pretty important: if we mixed 0.0 at equal distance, we'd get banding.) And if we're 0.13 units away or more, I don't want to be mixing at all, I just want to use F1.color. And here, we have uniform color in the centers of our cells, and blending between them, just like we want.

But be careful, because notice what we're doing at the previously highlighted point. At this point, F2 is always less than 0.13 units further than F1, so we're always mixing. Again, these aren't normalized to the cell size, and we can't normalize them, not while keeping the texture procedural (we could bake and do some calculations, but then, we could could also just run it through a blur in GIMP if we baked....)

Notice also what's happening at the "corners" of our cells, where F1 and F2 approach the same distance as a hypothetical F3. At this point, we have discontinuities, because adjacent points are calculating different colors for our F2. One is using the other's F3.

Unfortunately, Blender doesn't give us an F3, which is what we'd need to create a fully smoothed Voronoi. Since you're using Blender to plan out something you're going to do elsewhere, you might be able to get yourself an F3. If you did, you'd be determining the mix color not from F2.color, but from a mix between F2.color and F3.color very similar to your F1-F2 mix, by the distance from F2 to F3.

But even though Blender doesn't give us an F3 to create a fully smoothed Voronoi, it's mostly okay, because it provides us the exact same thing in the form of Smooth F1 color:

enter image description here

However, we still have the problem that the smoothing factor is in absolute distances, rather than relative to the maximum radius of our cell. Determining the maximum radius of our cell is not something we can do in parallel on all samples, not to my knowledge (maybe there's some genius algorithm out there, sometimes I'm surprised.)

  • $\begingroup$ Good thinking! I'm using this for a noise modulation, and "close enough" will generally do the job for me. There are a number of cheats I can use to avoid those discontinuities. $\endgroup$ May 26, 2022 at 20:48
  • $\begingroup$ I've considered simply separating it into monochrome textures by feature point, and applying a blur kernel to each texture, but it leads to incongruities and discontinuities at edge points in what should be an infinite texture; so procedural is generally best-case. $\endgroup$ May 26, 2022 at 20:58
  • 1
    $\begingroup$ Oversample, blur, then crop, if that's the problem. $\endgroup$
    – Nathan
    May 26, 2022 at 21:10
  • 1
    $\begingroup$ I think you meant "overscan" by oversample, right? "Overscan" as in, gather more texture elements than I intend to keep by treading over the edge of texture by the margin necessary for the blur matrix, and then crop, right? "Oversample" usually relates to significantly exceeding the Nyquist frequency in DSP. $\endgroup$ Jun 14, 2022 at 4:08
  • $\begingroup$ @MichaelMacha Yes, thank you. $\endgroup$
    – Nathan
    Jun 14, 2022 at 4:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .