The Voronoi texture uses a square grid, which is apparent at lower values of randomness. However, is it possible to use a hexagonal grid instead? Adding the right linear transformation could make the points' locations align with a hexagonal grid, but the circles around each point would distort into ellipses in doing so. More precisely, I would like to reproduce the below image (not made in Blender). 
- 227
- 2
- 6
-
2Related: How To Do UV Indexing in hexagonal pattern? – jachym michal Oct 12 '21 at 07:59
-
1@JachymMichal The remaining problem: random-point-in-hexagon. Or triangle. Which boils down, one way or another, to random-point-in-parallelogram (Sheared cartesian Voronoi x 3 ?). Even then, you have to check against 6 neighbours, AFAIK – Robin Betts Oct 12 '21 at 08:45
-
I will make a video on how you can achieve this. I will upload it in a few hours. Is that okay? Because this is a long process and I am getting tired writinggg! – Abu Hurairah Oct 13 '21 at 08:09
-
I've got as far as random-point-per-hex.. by dividing each hex into 3 parallelograms, randomly selecting one of them. bit pushed for time..next step: check neighbours. will happily share if you'd like to crit. my math. – Robin Betts Oct 13 '21 at 08:48
-
@Kifayat .. are you checking neighbours? If so, have you found an optimisation? – Robin Betts Oct 13 '21 at 08:49
-
Yes! Exactly! I am checking neighbors. That's the only solution in my opinion. I'll share my video so you can see more. – Abu Hurairah Oct 13 '21 at 09:32
-
I used the length node to create circles in each hexagon tile and then I will have to check the neighbors . Oh I also randomized the circles so they exceed their tiles. – Abu Hurairah Oct 13 '21 at 09:34
-
@Kifayat Ahh, OK, I'm being a bit strict about trying to achieve full coverage of the hexagonal area with an even random distribution of points. Which, given the difficulty with repeatable noise, is a bit tricky. The nice thing, though, is that with hexes, you have fewer neighbours to check than with squares! I'm sure being less purist about the math will do no harm.. the look won't be noticeably different. – Robin Betts Oct 13 '21 at 12:11
-
Im keen to see your result! That's a good idea! – Abu Hurairah Oct 13 '21 at 12:31
-
2@Kifayat Sorry for delay .. done the basics, results like this.. will write up as answer when I can.. still unsure how best to get back from distance-to-feature-point to color per Voronoi cell, etc. – Robin Betts Oct 14 '21 at 20:50
-
1Wow! This is amazing! – Abu Hurairah Oct 15 '21 at 06:13
-
1@RobinBetts: Chapeau!!!!!! – Chris Oct 15 '21 at 06:23
2 Answers
Hexagonal Voronoi
A Voronoi texture works by dividing the texture-space into cells, defining a pseudo-random 'feature point' in each cell, which is a function of the cell's location. Then each shading-point looks up the the feature-point in its own and neighbouring cells, returning the distance to the closest feature-point.
Blender's Voronoi works on the basis of rectangular cells. The ask, here, is to base a Voronoi on hexagonal cells.
1. Create a hexagonal grid
That's dealt with at the bottom of this answer. One of the outputs is '2D Index' which is the coordinate in the current texture-space of the centre of each cell.
2. Create a feature-point in each cell
To obtain random points, evenly distributed in a hexagon, the hexagon is divided into 3 rhombuses as shown below. One of those is randomly selected using the X of 3D White Noise. Then random 0-1 multiples,(using Y and Z of the noise) of the U and V vectors for that rhombus yield evenly distributed points inside it. The result is shown on the right:
The nodes for this:
A driven 'Randomness' mix is included to blend between cell-centers and random offsets of them. This should be wired in, but none of this tree is optimized.
3. For each cell, return the coordinates of its own, and its neighbour's centers
(above). '0' is the cell itself, '1' is the cell to the right, and the others are obtained by rotating '1' through multiples of 60 degrees. Again, to optimise, the rotations should be avoided: the resulting vectors should be hard-coded. In this version, I'm avoiding spaghetti at the cost of efficiency.
4. For each shading-point, find the nearest feature point
A small helper-group returns the closer of the points A and B to P:
which is daisy-chained to ...
5. Yield the coordinate of the closest feature-point to the shading point
... when used with the combinations already described.
None of this is optimised for speed. Rotations are used instead of hard-coding, distances are repeatedly calculated instead of being passed on.. and so on. The White Noise is very sensitive to floating-point errors in input values around -1, it seems? So a large number has been added to the input vectors, when it's used, here.
This .gif shows 'Distance', 'Position', and 'Color' outputs of the whole kaboodle, with 'Randomness' being swiped from 0-1:
Settings for your ref: about .7 'Randomness', and a color-ramp:
- 76,260
- 8
- 77
- 190
-
Hi there! Hope u are doing great! I was able to create distance to edge of the hexagons (using ur file) but the problem is that subtracting doesn't really give the distance and it doesn't work nicely (causes some artifacts) at higher randomness. Is there any way we can achieve precise borders? – Abu Hurairah Oct 23 '21 at 16:35
-
Hi @anonymous ! You mean d2e of regular hexagons, or d2e of this Voronoi? – Robin Betts Oct 23 '21 at 17:05
-
-
@anonymous this crossed my mind, too ... I wonder if this could be implemented without everything grinding to a halt? Worth a look, I think... – Robin Betts Oct 23 '21 at 18:45
-
i know that article but i dont understand it at all, id like to do that with nodes – Abu Hurairah Oct 24 '21 at 05:39
-
@anonymous I'll give it a shot.. it involves a second round of neighbour-searches, looking around the cell containing the feature-point found, the first time round, to be closest to the shading point. Can't promise rapid progress :) – Robin Betts Oct 24 '21 at 09:58
-
Voronoi noise is made by tiling circles in a square fashion and randomising the positions of all circles. Since the circles are limited to their tile's size, when you randomly change the position, they exceed their tile size and start to form seams. To eliminate that, we check the neighboring tiles i.e left, right, up, down, etc. This is how the usual voronoi is made. In the case of hexagonal voronoi, we only need to change one thing. We need to tile circles using hexagonal tiles / hexagonal coordinates. You can see how to make them here How To Do UV Indexing in hexagonal pattern? OR you can use the "hextiles" nodegroup in the blend file below. I have made a video how I made this : https://www.youtube.com/watch?v=RbH3_d9j7ro
Here is the blend:
- 402
- 3
- 7
-
To make the circles expand like in the original picture in the question, add a map range node and set it to smoother step. – Abu Hurairah Oct 15 '21 at 08:25
-
Also a very good answer and much work put in! Too bad they don't let you accept two answers at once. – Kevin Kostlan Oct 15 '21 at 21:54
-
-
@anonymous Hmm, just spotted I should strictly be searching another ring of neighbours .. very unusual, but the closest feature point could just be 2 cells away :( it would be a hell of a coincidence.... – Robin Betts Oct 25 '21 at 10:52
-









