Re: Eroded and Enhanced Terrain
Posted: Tue Oct 19, 2021 1:34 am
I really don't know what to even look for. Perhaps this section of TerrainComputer.cs is relevant?
Code: Select all
/// <summary>
/// Replaces the heightmap buffer in the WoodsFile with a 1000x500 version of the Interesting Terrains heightmap.
/// </summary>
public static void InitializeWoodsFileHeightmap()
{
var woodsFile = DaggerfallUnity.Instance.ContentReader.WoodsFileReader;
var original = woodsFile.Buffer;
originalHeightmapBuffer = new byte[original.Length];
for (int i = 0; i < original.Length; i++)
{
originalHeightmapBuffer[i] = original[i];
}
var alteredHeights = new ComputeBuffer(original.Length, sizeof(float));
var cs = UnityEngine.Object.Instantiate(InterestingTerrains.mainHeightComputer);
var k = cs.FindKernel("CSMain");
cs.SetFloat("newHeight", Constants.TERRAIN_HEIGHT);
cs.SetFloat("maxTerrainHeight", 2308.5f);
cs.SetFloat("scaledOceanElevation", 27.2f);
cs.SetFloat("baseHeightScale", 8f);
cs.SetFloat("noiseMapScale", 4f);
cs.SetFloat("extraNoiseScale", 10f);
cs.SetVector("terrainSize", new Vector2(WoodsFile.MapWidth, WoodsFile.MapHeight));
cs.SetVector("terrainPosition", Vector2.zero);
cs.SetTexture(k, "BiomeMap", InterestingTerrains.biomeMap);
cs.SetTexture(k, "DerivMap", InterestingTerrains.derivMap);
cs.SetBuffer(k, "Result", alteredHeights);
InterestingTerrains.instance.csParams.ApplyToCS(cs);
cs.Dispatch(k, WoodsFile.MapWidth / 10, WoodsFile.MapHeight / 5, 1);
var floatHeights = new float[original.Length];
alteredHeights.GetData(floatHeights);
alteredHeightmapBuffer = Utility.ToBytes(floatHeights);
woodsFile.Buffer = alteredHeightmapBuffer;
baseHeightmap = new Texture2D(WoodsFile.MapWidth, WoodsFile.MapHeight);
baseHeightmap.SetPixels32(ToBasemap(alteredHeightmapBuffer));
baseHeightmap.Apply();
alteredHeights.Release();
alteredHeights.Dispose();
}