x


Correctly Rebuilding Terrain Basemap

I am adding a dynamically generated "seafloor" texture to my terrains by adding a new element to the terrainData's splatPrototypes array. I then get the terrain's AlphaMap, populate the new seafloor channel, and call trnDat.SetAlphamaps(0, 0, alphaMap) to update the terrain.

It works beautifully! ...Except that the seafloor areas are rendered completely black on areas of the terrain that are grater than the terrain's basemapDistance from the camera.

I have tried using trnDat.SetBaseMapDirty(), trnDat.ResetDirtyDetails(), and terrain.Flush() to rebuild the terrain's base map after updating it's AlphaMap, but they either have no effect, or turn all the channels in my terrain's basemap black.

What is the correct way to regenerate a terrain's basemap?

Thanks,

-Aubrey

more ▼

asked Dec 24 '09 at 04:08 AM

Aubrey Falconer gravatar image

Aubrey Falconer
657 45 53 68

(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

When I have done this (and it works correctly for me), the only commands I have called after SetAlphamaps look like this:

terrainData.SetAlphamaps(0, 0, splatmapData);
terrainData.SetDetailLayer(...)   // once for each detail layer
terrain.terrainData = terrainData;  // reassign data to terrain
terrain.lighting = TerrainLighting.Lightmap;  // assign lightmap (which I also generated)
terrainData.RefreshPrototypes();
terrain.Flush();

Maybe simply reassigning the terrainData as I do in the 3rd line above will fix it for you... the other lines, as far as I understand, are unrelated to the splatmaps/basemap, but I included them just in case, because with my project the basemap seems fine and matches the new splatmaps properly.

hope this helps.

more ▼

answered Dec 24 '09 at 10:17 AM

duck gravatar image

duck ♦♦
41k 92 148 415

Thanks! Unfortunately, this still isn't working for me. Here's my complete terrain code: http://pastebin.com/m764df6bd Here's a screenshot of the error in my game: http://img96.imageshack.us/img96/2267/screenshot20091224at112.png

As you can see, on the minimap camera (which is farther from the terrain than the main camera), the seafloor texture is solid black.

What does SetDetailLayer(...) do? Should I be using it instead of directly altering the splatPrototypes array?

Dec 24 '09 at 07:33 PM Aubrey Falconer
(comments are locked)
10|3000 characters needed characters left

You also need to renormalize the splatmap data. All channels of all splatmaps combined should not exceed 1.0 or you will get weird effects. So if you add something to the alpha channel, you have to reduce all other channels.

more ▼

answered Jan 25 '10 at 08:32 PM

Tom 1 gravatar image

Tom 1
37 1

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x5096
x1478
x276

asked: Dec 24 '09 at 04:08 AM

Seen: 3180 times

Last Updated: Dec 24 '09 at 04:08 AM