I Need MATH Help to shift the Voronoi texture start position by half of a cell unit

I’m using Voronoi to make a pixelated screen/dot-matrix/score-board texture effect.


It works perfectly with square images but with rectangular images I have to divide the width by the height and use the resulting value as the Y scale of the mapping node controlling the “dots pixels”.

In this example the Y scale needs to be two:


(other files might have wild and crazy aspect ratios)

It works except the “color pixels” are half a “unit?” off from the “dot pixels” along the Y axis.

This is the lower left corner of the image plane:


I need to somehow move the dot grid down by half of a dot so that colored areas don’t start/stop in the middle of a circle. I can do this manually for any one particular voronoi scale value.

My problem is when I change the value that controls the scale of both Voronoi nodes I always have to manually make that change which means I can’t make a good animation out of it. I need a magic formula that I can plug the scale value into that perfectly calculates the Y Location offset as the scale value is changed.

dot pixelate halftone effect .blend (370.1 KB)

Hey !

So the good new is I fixed the issue, the bad new is I’ve done it in a completely different way…

dot pixelate halftone effect 1.blend (397.5 KB)

There are two different things, a bit like what you’ve done, the dot pattern, and the pixelate effect :

1/ creating the dot pattern, for that I make a grid based on the UV :


As each tile is now going from 0,0 to 1,1 in the UV, we can take the center of that (which is 0.5 , 0.5) and calculate the distance. That will give us a gradient :

and get a circle from that using a coloramp :

2/ give a pixelate effect to the texture :
For that, it’s just a matter of using the snap function in the UV :


Obviously if you’re not used to these function like snap, modulo, distance what I’ve made could be a bit disturbing.
But it was simpler to take the road I’m used too …

Last thing :
Make sure to set the texture interpolation to closest :
image

Feel free to ask questions if needed !

3 Likes

Thanks. I’ll probably just use your file. I do really wish though that there was a simple way to calculate that “half of a voronoi cell” value :frowning: I could have just bought the Dead Pixel add-on for $5 too but I really really want to figure out this “half of a voronoi cell” thing.

1 Like

Hum, maybe that’s possible ! I didn’t put too much effort on solving that :smiley:
probably once figured out that will look simple :smiley:
What disturbed me is that both voronoi don’t have the same mapping (one of them got the 1,2,1 scale) . I think it would have been simpler if that was the case.

dear god, what vector math node didn’t you use

hahaha , I’m having too much geo nodes and vector math these days :smiley:

2 Likes

how does yours handle random aspect ratios?

is there any other node that conveniently provides a grid like voronoi but without that annoying offset?

You have to set it here , similarly to what you’ve done in the first mapping node :
image

Hum, the issue is more on how the 2 voronoi are mapped in your case.
Because they have different mapping they won’t match anymore. Maybe there is a way to calculate the offset , or making it so that it work by keeping the same mapping.
As you’ve seen, if you disable both mapping node, grids are aligned but the voronoi pattern make some ellipsis rather than circles.

It was simpler for me to go in a solution that I know, but it’s probably possible to make it work using the voronoi.

1 Like

Many hours and many math nodes later, I doubt there is a solution I could ever come up with that doesn’t use the vector math stuff you used.

The main thing all my attempts fails to do is to keep the color/pixel details in their original general area as the color blocks enlarge in size. Instead I just keep scaling the coordinates up until the details leave the canvas or down until the image texture repeats.

1 Like

Arf ok !
At least it’s great to take the time to see that’s not as easy as it looks !
Feel free to poke me if you want to look more into the nodes I used so at some point you can redo that yourself !
These can look quite scary but with time they can become artist friendly !