- Home /
Different renders of Terrain Splat Protypes in Real Time
Hi, I have made a little Terrain editor in game, but I have a question about Terrain SplatPrototypes: When I change the AlphaMaps of a Splat texture on terrain with my inGmae editor I have a visible differents of color and opacity of Splat, respect the same change with unity editor. I have used the same SplatPrototype and I have set the opacity at 1 in in-game editor and in unity editor but the difference is very visibile.
For change the AlphaMaps I have used this two line of code
alphaMaps[localZ, localX, CurrentTerrainDetailTexture] = CurrentTerrainDetailTextureOpacity;
SceneTerrain.terrainData.SetAlphamaps(0, 0, alphaMaps);
This is the differents between editor and in-game editor results
Editor
InGame
Anyone have an idea of this behaviour?
Answer by svitale · Sep 03, 2018 at 10:09 AM
I have found a solution! To have a look similar of the splat prototype like unity editor is necessary to change the opacity of all other Alphamps in this way:
var alphaMaps = SceneTerrain.terrainData.GetAlphamaps(0, 0, SceneTerrain.terrainData.alphamapWidth, SceneTerrain.terrainData.alphamapHeight);
alphaMaps[localZ, localX, CurrentTerrainDetailTexture] = CurrentTerrainDetailTextureOpacity;
//Set opacity value of all other splatPrototypes in the matrix to 0
for(int i = 0; i < alphaMaps.GetLength(2); i++)
{
if(i != CurrentTerrainDetailTexture)
{
alphaMaps[localZ, localX, i] = 0;
}
}
I hope that this trick can help someone.
Your answer
Follow this Question
Related Questions
Replacing TerrainData#splatProtoypes in 2018.3 1 Answer
How can I get two different terrain instances to use different splat maps? 2 Answers
Deleting terrain splatmap through scripts. 1 Answer
terrainData.SetHeightsDelayLOD seem to have no effect and i dont know why. 1 Answer
Update terrain alphamap at runtime makes my game crawling 3 Answers