Where do you access the points that are used to draw textures in nodes?

This thread prompted me to explore more general blender ideas Control Voronoi distribution (cell size) with second texture
where the goal is to control the jittering of voronoi cells via another image. I tied playing around with all kinds of mapping and xyz setups but none of them quite did the trick, so it occurred to be that native blender nodes might not even have the capacity to let one edit the draw points of a texture.

Hence me coming here and asking: where do I find an option to modify the draw points that control procedural textures? Is this a script node I need to add separately to control their jittering via the shading of another texture?

The built in voronoi node has no control over point distribution. There are .OSL scripts for editable voronoi point locations though.

You mean itā€™s just a flawed design? Thereā€™s no way to modify the node and youā€™d have to make a completely new one from scratch? Canā€™t you just copy and paste whatever script comprises the node and add some bit of code that indexes the locations of each point and then modifies those locations?

Itā€™s a limited design. The current node system doesnā€™t have a good way to transmit point data to the shader, so there isnā€™t currently a way to modify those points.

The good news is, as Blender is open source software, you absolutely can modify that node to take in those points somehow and recompile the program.

There are existing scripts out there that you can plug into the .osl node that will probably do what you want, and will probably be much easier than coding it in C and recompiling. Do some googling, or search around this forum for 'voronoi .osl script"

OSL node? But I didnā€™t enable OSL language, this is all in whatever the default language is, probably Python or C++ or something.

Here is what I am talking about:


When you enable Open Shading Language, you can use the script node in cycles CPU rendering. If you find an .osl script, you can copy paste that into the text editor, and load that text object into the script node.

Now, you have access to the code of the voronoi texture, and you can modify it as you see fit.

1 Like

Thank you, Iā€™ll give it a try.

Hereā€™s a link to the osl script I copy pasted: https://github.com/varkenvarken/osl-shaders/blob/master/Voronoi.osl

No. Itā€™s a ā€œtime savingā€ design!

When a procedural texture is called, itā€™s called only for a specific point (sample). This has the advantage of allowing parallel computing of multiple samples, but it creates a gap between each sample, as they donā€™t ā€˜communicateā€™ with each others.

Voronoi is an expensive calculation to be executed in this kind of paralllel environment, and thatā€™s why our ā€˜Voronoiā€™ texture uses the ā€˜Worleyā€™ algorithm (by Steven Worley), and not a true Voronoi calculation.

The big problem of a true Voronoi procedural, is that for each sample, we need to loop over all points
in its vicinity to calculate the minimum distance to the sampling coordinate (and this lookup must be done for every sample!).

This is not suitable for ā€˜realtimeā€™/parallel computing, as it might happen that the closest cell point might well be far away from the sampling point, which requires lots of calls to the featured points list.

On the other hand, the Worley Noise is simpler. It uses a grid of 27 cells (3x3x3 in the 3D/4D version) around the sampling point, and all samples perform the same operation! Its calculation is pretty straigth forward, and also easy to implement in parallel computing.

As SterlingRoth said, a true Voronoi can be implemented in OSL, but I can tell you that is quite expensive on its own. Even with a good lookup structure for your point data, it will be slow (exponentially slow, depending on the number of points in your list)!

2 Likes