|
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? Thanks.
(comments are locked)
|
|
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! good luck! I didn't know about that! Thanks. I've been coding unityscript in gvim and can't easily see undocumented functions... I started to try this, but after I setup a C# version I found SetBaseMapDirty() which I called after modifying the texture and that worked! So thanks for the pointers!
Nov 20 '09 at 02:27 AM
duhprey
(comments are locked)
|
|
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. Duck's answer below actually makes much more sense. I thought the SetAlphamaps() method was only available to the editor, but he is right, that is the best way to modify splat maps.
Nov 19 '09 at 12:57 PM
jonas echterhoff ♦♦
(comments are locked)
|
