简体   繁体   English

我如何分配不同世界生成器的影响来生成地形?

[英]How do i distribute the influence of different world generators to generate terrain?

My applogies for the title as I do not know the correct term for my problem.我对标题的申请是因为我不知道我的问题的正确术语。

I'm using Simplex Noise (with 8 octaves) to generate a height map for my terrain.我正在使用 Simplex Noise(8 个八度音阶)为我的地形生成高度 map。 To get the terrain blend in, I calculated which biome fits the location best using a temperature value and a rainfall value and got the squared value via:为了让地形融合,我使用温度值和降雨值计算了哪个生物群落最适合该位置,并通过以下方式获得平方值:

Math.abs((biome.optimumTemperature-temp)*(biome.optimumTemperature-temp) + (biome.optimumRainfall-rain)*(biome.optimumRainfall-rain));

This value is then used to get the biome that affects the point the most (only 3 biomes are tested) ie 1/(squared value) meaning the closer the ideal conditions are the more terrain control the biome has.然后使用该值来获得对点影响最大的生物群落(仅测试 3 个生物群落),即1/(squared value) ,这意味着理想条件越接近,生物群落的地形控制就越多。 But I don't know how to make the sum of Weights equal to 1.但我不知道如何使权重之和等于 1。

Example 1:示例 1:

Biome 0: FOREST Weight:0.04317983014648879  
Biome 1: MOUNTAINS Weight:0.9954832102244979  
Biome 2: PLAINS Weight:0.06793829435632236  

Here, the sum is: ≈1,10660133 which is greater than 1这里,总和是:≈1,10660133,大于 1

Example 2:示例 2:

FOREST Weight:0.01621210578957933  
MOUNTAINS Weight:0.023389024085188184  
PLAINS Weight:0.017797794332510785  

Here, the sum is: ≈0.0573989242 which is less than 1在这里,总和是:≈0.0573989242 小于 1

To prevent an influence that approaches infinity if biome.optimumTemperature = temp and biome.optimumRainfall = rain meaning that later on it would become 1 / 0 (Bad) I have clamped the squared value to a maximum of 1 for each of the 3.为了防止在biome.optimumTemperature = tempbiome.optimumRainfall = rain的情况下接近无穷大的影响,这意味着稍后它将变为 1 / 0(坏),我已将 3 个中的每一个的平方值限制为最大值 1。

My question is how do I distribute the influence to all 3 biomes according to the conditions?我的问题是如何根据条件将影响分配到所有 3 个生物群系?

Note: it is okay for a biome to have an influence of 1 if it matches temp and rain perfectly but in that case the other 2 biomes should have an influence of 0.注意:如果一个生物群系与温度和降雨完美匹配,则它的影响力为 1 是可以的,但在这种情况下,其他 2 个生物群系的影响力应该为 0。

It seems like you want to normalize the numbers.看起来你想规范化数字。 This is done by dividing each number by the total sum:这是通过将每个数字除以总和来完成的:

double a, b, c;
double sum = a + b + c;
double normalizedA = a / sum;
double normalizedB = b / sum;
double normalizedC = c / sum;

This ensures that the total sum of the new values becomes 1 (plus or minus any rounding errors from dealing with floating-point numbers) while retaining the relative sizes of the different numbers.这确保了新值的总和变为 1(加上或减去处理浮点数的任何舍入误差),同时保留不同数字的相对大小。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM