Cubitect / cubiomes

C library that mimics the Minecraft biome generation.
MIT License
556 stars 98 forks source link

How to access climate parameters values #108

Open Rayerdyne opened 10 months ago

Rayerdyne commented 10 months ago

Hi there !

For my project I want to access the "climate maps", that is the arrays of climate parameter values, namely temperature, humidity, continentalness, erosion, depth and weirdness. I found sampleBiomeNoise which I use with the BiomeNoise member in the Generator struct, and get the values I want from the np pointer argument.

However, the values I get this way differ from the typical ranges that are reported in the wiki, taking into account the 10000 factor. E.g. for temperature I expect "about from -2.31 to +2.31", but the [min, max] values when browsing 200 seeds over 500×500 scale 16 range lie around [-1.07, 0.96] (maybe I don't have enough data ?)

So, I'm questioning how to use sampleBiomeNoise, in particular the sample_flag input, for which I'm confused about its effect on px and pz thus on subsequent sampling. I beleive it is set to SAMPLE_NO_SHIFT when called via genBiomesgenBiomeNoiseScaledgenBiomeNoise3D, but I dont get what it does. I redo the test, setting the flag to that value but it didn't change the results I obtained.

I think I could also use sampleClimatePara 6 times, but to me it looks like it would make the same result.

Cubitect commented 7 months ago

This is pretty much all correct. The climate extremes are virtually unreachable and you'll have to actively search for anything close to the limits. To give you a sense for the usual values: all the biomes can generate within the temperature interval from -4501 to 5500. (Also temperature varies between +/-2.2222 not 2.31, contrary to what the wiki says.)

The full biome generation applies a distortion effect by sampling an additional SHIFT noise that is added to the X and Z coordinates. This shift is between -4.0 and 4.0, which corresponds to a maximum offset of one chunk. It's relatively expensive to calculate and the effect is minimal, so you can disable it by setting the SAMPLE_NO_SHIFT flag.

Regarding genBiomes(), the distortion from the SHIFT noise is only ignored by default when the scale is larger than 1:4, since a coordinate shift of less than one chunk will not have a meaningful effect at a scale of 1:16+.