Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- float[, ,] splatmapData = new float[terrainData.alphamapWidth, terrainData.alphamapHeight, terrainData.alphamapLayers];
- for (int y = 0; y < terrainData.alphamapHeight; y++)
- {
- for (int x = 0; x < terrainData.alphamapWidth; x++)
- {
- // calculate denseness, steepness and wetness for this position, and then...
- Vector4 splat = new Vector4(1, 0, 0, 0);
- splat = Vector4.Lerp(splat, new Vector4(0, 1, 0, 0), denseness);
- splat = Vector4.Lerp(splat, new Vector4(0, 0, 1, 0), steepness);
- splat = Vector4.Lerp(splat, new Vector4(0, 0, 0, 1), wetness);
- splat.Normalize();
- splatmapData[x, y, 0] = splat.x;
- splatmapData[x, y, 1] = splat.y;
- splatmapData[x, y, 2] = splat.z;
- splatmapData[x, y, 3] = splat.w;
- }
- }
- terrainData.SetAlphamaps(0, 0, splatmapData);
Add Comment
Please, Sign In to add comment