Open MarcusElg opened 2 years ago
I just looked at this suggestion, and I think I know of a non-destructive way to implement this. I added mNearestX
and mNearestY
to the class definition and set them using the technique you described.
From there, I added a function that users can call to get the active center. The only hiccup is that this center function needs to be queried every time you poll the noise function, adding one more function into the pipeline. I don't know that there would be a better way to do it without refactoring.
I second this idea, it would be very useful! Because this feature doesn't exist, I'm going to have to write my own noise generation
The cellular/voronoi noise generation is great, it is possible to get both distance and cell index. Unfortunely there isn't a way to get the nearest voronoi point/cell center.
Why is this useful? Cellular noise is very useful for placing biomes in procedural world generation, by making an entire cell a single biome. The biome can then by chosen depending on different noise maps for temperature, humidity etc (Like https://towardsdatascience.com/replicating-minecraft-world-generation-in-python-1b491bc9b9a4 does for example). But this requires the cell position to be able to sample these other noise maps.
How can this be implemented? This is one way that I solved it with my own version of the method. When finding the nearest voronoi point this point can be saved instead of just saving the distance and hash:
This value can then be domain warped and finally divided with the noise frequency to get the position in global space.
I'm probably not the only one wanting this feature and I feel like it would make a lot of sense to have in the library, especially as it is quite simple to implement. I could send a pr myself, I wonder what the best way to return the value is tho as the current function only returns one value.