• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
Question by Aubrey-Falconer · Dec 24, 2009 at 04:08 AM · terrainrenderer

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

Comment
jashan
Mikael-H

People who like this

2 Show 0
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
Best Answer

Answer by duck · Dec 24, 2009 at 10:17 AM

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.

Comment

People who like this

0 Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Aubrey-Falconer · Dec 24, 2009 at 07:33 PM 0
Share

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?

avatar image b1gry4n Aubrey-Falconer · Oct 01, 2016 at 07:48 PM 0
Share

This is an old post, but I thought I would share for anyone else stumbling on this.

I was getting weird results from my procedural splatmap as well, particularly my basemap was blocky and popping in and out. By simply setting the resolution of the basemap prior to applying the splat info it solved my problem.

terrain.terrainData.baseMapResolution = (i set mine to my splat map resolution)

avatar image

Answer by Tom 1 · Jan 25, 2010 at 08:32 PM

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.

Comment
DocSWAB
twobob

People who like this

2 Show 0 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

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

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

1 Person is following this question.

avatar image

Related Questions

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

URP Post-Processing not working properly with Terrain on Build 0 Answers

Changing two different objects renderer colour 1 Answer

Procedurally generating terrain? 0 Answers

Inserting heights in TerrainData 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges