Correctly Rebuilding Terrain Basemap

I am adding a dynamically generated "seafloor" texture to my terrains by adding a new element to the terrainData's splatPrototypes array. I then get the terrain's AlphaMap, populate the new seafloor channel, and call trnDat.SetAlphamaps(0, 0, alphaMap) to update the terrain.

It works beautifully! ...Except that the seafloor areas are rendered completely black on areas of the terrain that are grater than the terrain's basemapDistance from the camera.

I have tried using trnDat.SetBaseMapDirty(), trnDat.ResetDirtyDetails(), and terrain.Flush() to rebuild the terrain's base map after updating it's AlphaMap, but they either have no effect, or turn all the channels in my terrain's basemap black.

What is the correct way to regenerate a terrain's basemap?



You also need to renormalize the splatmap data. All channels of all splatmaps combined should not exceed 1.0 or you will get weird effects. So if you add something to the alpha channel, you have to reduce all other channels.

When I have done this (and it works correctly for me), the only commands I have called after SetAlphamaps look like this:

terrainData.SetAlphamaps(0, 0, splatmapData);
terrainData.SetDetailLayer(...)   // once for each detail layer
terrain.terrainData = terrainData;  // reassign data to terrain = TerrainLighting.Lightmap;  // assign lightmap (which I also generated)

Maybe simply reassigning the terrainData as I do in the 3rd line above will fix it for you... the other lines, as far as I understand, are unrelated to the splatmaps/basemap, but I included them just in case, because with my project the basemap seems fine and matches the new splatmaps properly.

hope this helps.