• 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 Pizmovc · Apr 17, 2015 at 10:26 PM · terrainresolutionheightmapterraindatadebug.log

Why does assigning heightmapResolution increase the size of my terrain?

So I've been trying to generate a terrain using code and I've come across a lot of problems. The most recent one is the fact that when I assign heightmapResolution the size of my terrain increases by a factor of some power of two.

For example, if my heightmapResolution is 513, then my terrain size increases by a factor of 16. If my heightmapResolution is 257, then my terrain size increases by a factor of 8.

I must stress that the size increase happens only in X and Z axis. Height remains unchanged.

 Debug.Log (terrainData.size);
 terrainData.heightmapResolution = heightmapResolution;
 Debug.Log(terrainData.size);

The change is already visible in the second Debug.Log.

Any ideas as to why?

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
4
Best Answer Wiki

Answer by Pizmovc · Apr 19, 2015 at 03:05 PM

I figured it out.

I had to set the heightmap resolution before I set the terrain size. Here is the final code that works as intended.

 terrainData.heightmapResolution = heightmapResolution;
 terrainData.size = new Vector3(width, height - sandBaseHeight, length);
 terrainData.baseMapResolution = baseMapResolution;
 terrainData.SetDetailResolution((int)detailResolution.x, (int)detailResolution.y);
 terrainData.alphamapResolution = aplhaMapResolution;

 Debug.Log ("Terrain size: " + terrainData.size); //Correct terrain size

Hope this helps someone else!

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
avatar image
0

Answer by siaran · Apr 17, 2015 at 11:58 PM

This is a bit simplified and it's late so I may be wrong, but:

Terrain is built off of a height map. The resolution of this heightmap is the size of this map. Increasing the resolution of the heightmap therefore also increases the size of the terrain, unless you change the...well, the distance in worldspace between heightmap samples, basically. Not sure what variable that is, though.

Comment
Add comment · 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 Pizmovc · Apr 18, 2015 at 12:20 AM 0
Share

So is there some $$anonymous$$imal distance between two vertexes? Because I see no other explanation for the increased terrain size. The resolution of the heightmap should just affect how small of an area you can assign different height to, no? It should basically just give you finer control over height.

That is at least how I understand it. I may be completely wrong :)

There really should be better documentation for terrain. There are just one sentence descriptions for various variables and functions. Not much to go on.

avatar image siaran · Apr 18, 2015 at 10:25 AM 0
Share

There should be some variable that gives you a denser sampling that'd decrease your terrain size yes, but idk which one that would be or if it's even accesible. Like you said the documentation on terrain isn't great. Try experimenting with the accesible varialbes I guess?

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

heightmapWidth and heightmapHeight always equal 1 Answer

How can I programmatically stretch a Terrain? 1 Answer

Ridges on terrain with lowering/raising height? 1 Answer

I've written a script to create dynamic height maps. How do I use those height maps to generate dynamic procedural terrains? 1 Answer

Why a basic unity terrain has low resolution on the borders? (image included) 1 Answer


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