I'm trying to create a Conway's Game Of Life as a texture on the terrain (the life in this case is "grass"). I attempted creating a script to modify the texture and dragged SplatAlpha 0 from the terrainData into the texture. This however, doesn't appear to modify the splat properly until I go back into the texture painter and suddenly the changes pop in. This may also be causing Unity to crash...
Is there a proper way to do this?
First of all (and it sounds like you probably know this), there's no need to actually modify any Texture objects in order to modify the splat maps on a terrain. They're stored internally as a float[,,] array, and you can edit these values directly.
So, assuming you're calling:
(where yourNewSplatmapData is a float[,,] with valid data inside), I think you then need to do this:
Note - because these are undocumented commands, and UT may upgrade or change the terrain engine in the future, these functions may not work in future versions of the webplayer plugin!
Some thoughts, without having tried this:
-Unity only uses the splat maps directly for rendering for close by terrain segments. For further away parts, it uses a base map, which is precomposed from the splat maps. I don't think there is a runtime API which lets you regenerate the base map. You could, however change the base map distance to be very high, using Terrain.basemapDistance.
-Make sure you are actually modifying the splat maps (by rendering them onto some object). You have to call Texture2D.Apply() after using SetPixels.
answered Nov 19 '09 at 10:21 AM
jonas echterhoff ♦♦