My procedural terrain is coming along great, although I want biomes, and so I decided I’d go with noise based like just about everything else in that project, but I’ve got an issue where I don’t want to hard code every biome, so I need a way to convert my biome noise(which is just your bog-standard perlin noise) into a whole number that properly associates with a biome within said array.
local BiomeNoise = PerlinNoise(x * 4, z * 4, 54.4562, .005, .05)
local NormalizedNoise = Normalize(BiomeNoise)
local Biome = math.round(NormalizedNoise * #Biomes)
That was my closest attempt, but it has a fairly large flaw, which for some reason, it almost only ever returns the biome that’s at the center of the array, which I DID find a fix for it, but it brought more issues.(the normalize function is simply returning math.clamp(x + .5, 0, 1)
)
If I reduce the modifier on the noise, which slightly affects what it returns, it generates all the biomes, but they’re super small, and rather than the smooth transition, which I was getting with my initial two biome test, it’s generally an abrupt edge, which isn’t terribly optimal.
so do any of you math wizards(or anyone else) know a way I could convert a noise into a pseudo-random integer based on the number of entries in an array, and not have to hard code each and every biome