Hi, I am experimenting with Terrain splatmap to spawn specific particles after Raycasting from player gun to the terrain. So far, I have created a terrain with only 1 patch, with 16 chunks, each chunk size = 63
(that makes the patch width = height = 25,200 world unit). I also have upto 5 terrain layers, that make the terrain use 2 splatmaps from my understanding.
Currently, here what I did to get a pointer to an array of splatmap:
private Terrain _terrain;
public override void OnStart()
{
_terrain = Actor.As<Terrain>();
Int2 patchCoord = new Int2(0, 0); // Assuming that only one patch located at coord: (0,0)
Task.Run(() =>
{
unsafe
{
// Get the first splatmap containing layer 0 to layer 3
Color32* splatMapPtr = TerrainTools.GetSplatMapData(_terrain, ref patchCoord, 0);
for (int i = 0; i < 65536; i++)
{
var data = splatMapPtr[i];
Debug.Log(data.ToString()); // Print out in format: R, G, B, A
}
}
});
}
I choose the number 65,536
after looking into the SceneData folder and find a splatmap there with the width and height dimension: 256x256.
I’m wondering is this the right appoach because I also tested printing the array at 999999
, it still able to print out (0,0,0,0)
, perhaps it is storing the default values?;
Thanks!