How could I select random terrain grass columns in my game and change them for snow?
I don’t want to use raycasting from the sky because it can select columns already converted to snow, leaving grass patches which can remain for a very long time, based on RNG.
I want to somehow select a 2D cross-section of the map and efficiently select columns which have grass in them and convert the grass to snow. I can’t use a loop for this, because this will mean the grass is converted to snow in a printing fashion, not a random fashion
This method doesn’t need to be all that fast, as long as it can do a 2048 x 2048 area in around half an hour, I’m not too picky
Imagine a 2D math.noise-based texture overlayed on your terrain. The values represent how slowly an area gets covered in snow.
In a loop, check the math.noise(x, z) using the position of the terrain block. If the result is higher than the current time, you can change it to snow.
If you give more details about your requirements (e.g. does the terrain change shape over time? do you need the whole column changed or just the topmost block?) I may be able to give more detailed help.
It’d help if we knew what data structure you were using to store your columns in.
You could do it how Minecraft does it: pick a random column in the area, check if that column is exposed to air, and then add a layer of snow on top of it. Like I mentioned, since we don’t know your data structure, this implementation is assuming quite a bit.
Ended up using Perlin noise to generate noise between -1 and 1.
I then ran a loop which went from -1 to 1 in small steps, and went through the map in a grid-like fashion, saving the position to a table if the noise for that grid position is close to the step value.
I then just ran a separate loop which goes through all the positions, converts them to Region3 and replaces grass with snow in that small region. The region size I used was a 6x350x6 region.
No clue how well I explained that, but that’s how I did it. Still has a noticeable print effect because changing 100,000 odd cells to snow at one time isn’t the best for performance. But it does set ALL grass to snow and does it randomly, which is nice