Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- data = terrain.terrainData;
- int w = data.alphamapWidth;
- float[,,] splatmapData = data.GetAlphamaps(0, 0, w, w);
- Color[] mapColors = targetTexture.GetPixels();
- int numSplatMaps = splatmapData.GetLength(2);
- for (int z=0; z<numSplatMaps; ++z)
- {
- for (int y=0; y<w; ++y)
- {
- for (int x=0; x<w; ++x)
- {
- mapColors[x*w + y][z] = splatmapData[x,y,z];
- }
- }
- }
- targetTexture.SetPixels( mapColors );
- var bytes = targetTexture.EncodeToPNG();
- File.WriteAllBytes(Application.dataPath + "/"+targetTexture.name+".png", bytes);
Advertisement
Add Comment
Please, Sign In to add comment