Синтаксис:
Используется csharp
splatmapData = terrainData.GetAlphamaps(0, 0, alphamapResolution, alphamapResolution);
// splatmapData = new float[terrainData.alphamapWidth, terrainData.alphamapHeight, terrainData.alphamapLayers];
for (int y = 0; y < aWidth; y++)
{
for (int x = 0; x < aWidth; x++)
{
float height = terrainData.GetHeight(x, y);
Vector3 splat = new Vector3(0, 1, 0);
if ( height < 0.2 )
{
splat = Vector3.Lerp(splat, new Vector3(0, 0, 1), (height));
}
else if (height > 0.7)
{
splat = Vector3.Lerp(splat, new Vector3(0, 0, 1), (height - 0.7f) * 2);
}
else { splat = Vector3.Lerp(splat, new Vector3(1, 0, 0), (height - 0.1f) * 2); }
splat.Normalize();
splatmapData[x, y, 0] = splat.y;
splatmapData[x, y, 1] = splat.x;
splatmapData[x, y, 2] = splat.z;
}
}
terrainData.SetAlphamaps(0, 0, splatmapData);