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 AR_Rizvi · Sep 02, 2013 at 07:26 AM · terraindataterraintexturesplatmaps

Spalt Maps Problem....

hi guys i am trying to set textures on terrian by spalt maps but it dsnt work i am using the simple code to set the texures but it returning null value every time i test it with diffrent ways can u guys help me in solving this problem here is the code i am using plz help... thanks

     SplatPrototype[] terrainTexture = new SplatPrototype[4];
     terrainTexture[0] = new SplatPrototype();
     terrainTexture[0].texture = (Texture2D)Resources.Load("TEX/GLO_TIL_BRICK_439_MAP_L9_2013_1");
     terrainTexture[0].tileOffset = new Vector2(0, 0);
     terrainTexture[0].tileSize = new Vector2(15, 15);
         Debug.Log ( terrainTexture[0]);
      Debug.Log ( tex1);
      
      
     terrainTexture[1] = new SplatPrototype();
     terrainTexture[1].texture =(Texture2D)Resources.Load("TEX/GLO_TIL_BRICK_656_MAP_L9_2013_1");
     terrainTexture[1].tileOffset = new Vector2(0, 0);
     terrainTexture[1].tileSize = new Vector2(15, 15);
      
     terrainTexture[2] = new SplatPrototype();
     terrainTexture[2].texture =(Texture2D)Resources.Load("TEX/GLO_TIL_FINERY_180_MAP_L9_2013_1");
     terrainTexture[2].tileOffset = new Vector2(0, 0);
     terrainTexture[2].tileSize = new Vector2(15, 15);
      
      
     terrainTexture[3] = new SplatPrototype();
     terrainTexture[3].texture =(Texture2D)Resources.Load("TEX/GLO_TIL_GRASS_002_MAP_L9_2013_1");
     terrainTexture[3].tileOffset = new Vector2(0, 0);
     terrainTexture[3].tileSize = new Vector2(15, 15);
      
      
     terrainData.splatPrototypes = terrainTexture;
      
      
     float[,,] map = new float[terrainData.heightmapWidth-1,terrainData.heightmapHeight-1, 4]; // needs to be 1
     // For each point on the alphamap...
      
     for (int y = 0; y < terrainData.heightmapWidth-1; y++)
     {
     for (int x = 0; x < terrainData.heightmapHeight-1; x++)
     {
     if(terrainData.GetHeight(y,x)<10)
     map[x, y, 0] = 1.0f;
     else if(terrainData.GetHeight(y,x)<20)
     {
     map[x, y, 0] = 0.5f;
     map[x, y, 1] = 0.5f;
     }
     else if(terrainData.GetHeight(y,x)<30)
     map[x, y, 1] = 1.0f;
     else if(terrainData.GetHeight(y,x)<40)
     {
     map[x, y, 1] = 0.5f;
     map[x, y, 2] = 0.5f;
     }
     else if(terrainData.GetHeight(y,x)<50)
     map[x, y, 2] = 1.0f;
     else if(terrainData.GetHeight(y,x)<60)
     {
     map[x, y, 2] = 0.5f;
     map[x, y, 3] = 0.5f;
 //    print (terrainData.GetHeight(y,x));
     }
     else if(terrainData.GetHeight(y,x)<70)
     map[x, y, 3] = 1.0f;
     else if(terrainData.GetHeight(y,x)<80)
     {
     map[x, y, 3] = 0.5f;
     map[x, y, 4] = 0.5f;
 //    print (terrainData.GetHeight(y,x));
     }
     else if(terrainData.GetHeight(y,x)<90)
     map[x, y, 4] = 1.0f;
     }
     }
     terrainData.SetAlphamaps(0, 0, map);
     }
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

0 Replies

· Add your reply
  • Sort: 

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

16 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

offset and misbehaviour Issue with the 'Paint Texture' tool in the Terrain Editor 0 Answers

Can we use a terrain-style splat shader on custom ground geometry? 1 Answer

Edit terrain by script?? 0 Answers

Getting the texture of a certain point on terrain 1 Answer

Terrain Texture (applied programatically) Disappears When Entering Play Mode 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