Sry, I'm trying to understand what's wrong with my voronoi, I managed to narrow it down and I'm quite sure it's a stupid error somewhere. The issue lies somewhere in how I get points distance.
For each pixel I wish to have the position of the first and second closest points in the point cloud. Any other math comes from there.
The code is entirely C++ since I'm using cuda. My "vecNT" classes are similar to GLSL vec2, vec3, uvec2, uvec3 etcc
All the relevant math is done in this class
#Help me fix my vorobroken
44 messages · Page 1 of 1 (latest)
If I remove the randomization, it's always the bottom-right quarter of a point that's wrong, and I'm not understanding how/why
randomized
unrandomized
For my voronoi it didnt take nearly that much code
you can start by returning a sqrt value if your recieving end isnt already doing that
and if its 3D voronoi noise, i recommend having a starting distance of a large number
and if you need, i can send some code, its your choice on what type of code i send, one that makes sense and is in python, c++ or the hellish attempt on scratch
ah I see, the randomized points are centered on the corner of the tile
so you need to subtract 0.5 to it so that its centered on the tile
or actually you can just make your random offset be in the range [0, 1] instead of [-0.5, 0.5], same thing
i'll gladly take a c++ example
but logically is the reasoning right? look at the points in the nearby "regions" and take the 2 closest?
Just 1
I meant to reply to this
But you just want to take the closest 1 point
Actually, I can just use pseudo code or smth
That's easier to do rn
see that's not enough, I don't want just the distance from the point, i want the distance from the edge too
and to know that I need the distance from the 2nd closest point, don't i?
I'm so confused on what you're trying to do...
for a given pixel know how far it is from the center of its cell and the edge
My voronoi noise is a grid of points which are translated by random numbers and then the distance is calculated between the nearest 27 points
that's what I'm doing in my code though
i'm just taking the 2nd closest too because I can't know the edge distance without it
I'm just confused by what you mean edge
i want orange and yellow, not just yellow
just realized my math for orange was wrong regardless
I feel like the edge is calculated by the average of those 2 points
Not the sample
But you can always have a random value corresponding to the closest point
yeah i don't mind it, just trying to understand why my corners act weird rn
the edge calculation is a "later" issue
Alright
Well, I have a grid of pixels let's say
And scale it to 0.01 or so to see the noise
Then I simply repeat for x, y, z values 3 times each
Based on the floor of the sample point
That's my
repeat_distance * (utils::math::floor(position / repeat_distance), where repeat_distance is your 0.01 and position is the sample point
Repeat distance?
the base distance of the points from each other (without randomization)
Hm
ok found out what was wrong: I assumed that the 2nd closest point must be within a 3x3 grid around the sample point. However in some cases it isn't.
Here the sampel point's (cyan) closest point is blue and second closest point (which i used to calculate distance from edge) isn't within a 3x3 grid
so... is there any better way to find the % of the sample point between cell center and edge?
cause scaled to 3 dimensions this goes from 3*3*3 checks to (3*3*3 /*core*/) + ((3*3 /*face "bulge"*/) * 6 /*faces*/)