• 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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



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

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

Is there a way to paint tessellation or displacement textures on a terrain? 1 Answer

Alphamaps with new cloned terrain 0 Answers

Terrain Issue [Video] 1 Answer

Terrain textures blurry, but only in scene view 1 Answer

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges