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 at 04:08 AM

Aubrey Falconer\'s gravatar image

Aubrey Falconer
552 35 45 62

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

2 answers:

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 at 08:32 PM

Tom 1\'s gravatar image

Tom 1
21 1

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

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 at 10:17 AM

Duck\'s gravatar image

Ben Pitt ♦♦
34.4k 77 133 388

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 at 07:33 PM Aubrey Falconer
(comments are locked)
10|3000 characters needed characters left
 moderation talk
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:

x3126
x888
x144

Asked: Dec 24 at 04:08 AM

Seen: 2256 times

Last Updated: Dec 24 at 04:08 AM

powered by Qato - Enterprise Q&A