public static void ComputeTemperature(World world, int seed) { double[,] tempMap = world.GetOrAddMap <double>("temperature"); int[,] heightMap = world.GetMap <int>("height"); int seaLevel = (int)world.GetProperty("sealevel"); int equator = (int)world.GetProperty("equator"); int planetHeight = (int)world.GetProperty("planetheight"); //from roughly the hottest and coldest annual temperature, in kelvin //-30C to 30C double equatorTemp = 303; double poleTemp = 263; double tempDistrib = planetHeight / 2.0; world.SetProperty("maxtemp", equatorTemp); world.SetProperty("mintemp", poleTemp); for (int x = 0; x < world.Width; x++) { for (int y = 0; y < world.Height; y++) { double newTemp = TerrainGenDemo.Lerp(equatorTemp, poleTemp, Math.Abs(equator - y) / tempDistrib); newTemp -= Math.Max(heightMap[x, y] - seaLevel, 0) * 0.07; newTemp = Math.Max(newTemp, 1); tempMap[x, y] = newTemp; } } }