public static byte GetTheoreticalByte(Vector3 pos, Vector3 offset0, Vector3 offset1, Vector3 offset2) { float moisture = CalculateNoiseValue(pos, offset2, 0.001f); float rockiness = CalculateNoiseValue(pos, offset2, 0.003f); Biome biome = World.GetIdealBiome(moisture, rockiness); //float heightBase = biome.minHeight; //float maxHeight = biome.maxHeight; //float heightSwing = maxHeight - heightBase; float blobValue = CalculateNoiseValue(pos, offset1, 0.05f); float mountainValue = CalculateNoiseValue(pos, offset0, 0.009f); //mountainValue += biome.mountainPowerBonus; //if (mountainValue < 0) mountainValue = 0; //if (biome.mountainPower != 1) //mountainValue = Mathf.Pow(mountainValue, biome.mountainPower); //Mathf.Sqrt(mountainValue); byte brick = biome.GetBrick(Mathf.FloorToInt(pos.y), mountainValue, blobValue, moisture, rockiness); //mountainValue *= heightSwing; //mountainValue += heightBase; //mountainValue += (blobValue * 10) - 5f; //if (mountainValue >= pos.y) return(brick); //return 0; }
public static byte CalculteByte(Vector3 worldPos, Vector3 offset0, Vector3 offset1, Vector3 offset2) { float biomeValue = CalculateNoise(worldPos, offset1, 0.02f); int biomeIndex = Mathf.FloorToInt(biomeValue * World.Instance.biomes.Length); Biome biome = World.Instance.biomes[biomeIndex]; float heightBase = biome.minHeight; float maxHeight = biome.maxHeight; float mountainHeight = maxHeight - heightBase; //Debug.Log(height+" "+ heightBase+" "+ maxHeight+" "+mountainHeight); float mountainValue = CalculateNoise(worldPos, offset0, 0.009f); float smallMountainValue = CalculateNoise(worldPos, offset2, 0.05f); mountainValue += biome.mountainPowerBonus; if (mountainValue < 0) { mountainValue = 0; } mountainValue = Mathf.Pow(mountainValue, biome.mountainPower); byte brick = biome.GetBrick(Mathf.FloorToInt(worldPos.y), mountainValue, smallMountainValue, null); mountainValue *= mountainHeight; mountainValue += heightBase; //mountainValue += CalculateNoise(worldPos, offset1, 0.02f) * 5 - 5; mountainValue += smallMountainValue * 10 - 5; ////large scale means more steep, less fluent, ////so we should make the value less important, because we want it overall to be fluent ////this is to add more detail to the map generated with scalel 0.007 ////but without the map generated with scale 0.007, this will just be blobs of small island //float noise = CalculateNoise(worldPos, offset0, 0.05f); ////this means on ground this value are more prone to have value(because noise is larger when y is smaller) //noise /= ((float)worldPos.y / 5.0f); //noise = Mathf.Max(noise, CalculateNoise(worldPos, offset1, 0.02f)); //noise /= ((float)worldPos.y / 5.0f); //noise = Mathf.Max(noise, CalculateNoise(worldPos, offset2, 0.007f)); ////Debug.Log("noise " + noiseX + " " + noiseY + " " + noiseZ+" "+noise); ////float halfHeightFloat = width / 2f; ////y smaller means height is smaller ////this makes ground solid and don't have mesh on sky ////noise += (halfHeightFloat - (float)y) / halfHeightFloat; //if (noise > 0.2f) //{ // return brick; //} if (mountainValue >= worldPos.y) { return(brick); } return(0); }