Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • 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
0
Question by AaronC · May 29, 2010 at 03:44 AM · terrainmaskterraindataswapsplatmaps

Unity Terrain Texture Swap...how to?

Hi 3 scenarios:

  1. I have one texture, a map covering whole terrain-no tiling. Can I by script swap that entire texture for another also with no tiling? How would I do that?

  2. say I am using 3 or four splatmaps, can I swap one of these out for another texture at runtime also? so ingame I can swap out grass for dirt for example?

  3. can you use a greyscale mask to define where certain splatmaps are painted?

Many thanks AC

Comment
Add comment
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
0

Answer by dex · May 30, 2012 at 06:17 PM

I am currently using the following function, but it does not seem efficient enough, so i am also looking for a better solution.

 // Load specified texture and only that texture in given terrain
 void LoadTerrain(TerrainData terrain_data, int texture_level) {

     float[, ,] alphas = terrain_data.GetAlphamaps(0, 0, terrain_data.alphamapWidth, terrain_data.alphamapHeight);

     // make sure every grid on the terrain is modified
     for (int i = 0; i < terrain_data.alphamapWidth; i++) {
         for (int j = 0; j < terrain_data.alphamapHeight; j++) {

             // make sure only set layer is visible
             for (int k = 0; k < terrain_data.alphamapLayers; k++) {
                 if (k == texture_level) {
                     alphas[i, j, k] = 1;
                 } else {
                     alphas[i, j, k] = 0;
                 }
             }
         }
     }

     // apply the new alpha
     terrain_data.SetAlphamaps(0, 0, alphas);
 }
Comment
Add comment · Show 1 · 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
0

Answer by ScroodgeM · Jul 19, 2012 at 06:11 PM

http://answers.unity3d.com/questions/285816/change-terrain-texture-and-tree-at-runtime.html#answer-285924

a little upgraded script that allows to change texture without full repainting, e.g. it saves paint map and changes texture.

Comment
Add comment · 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.

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Procedural terrain generation based on color mask 0 Answers

How can I get two different terrain instances to use different splat maps? 2 Answers

How to set Flatten HeightMap in Unity 4.2 1 Answer

Material: What is a "Mask map" and when to use it? 0 Answers

SetAlphaMaps Opacity Gradient 0 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