Unity3d terrain Creation

Source: Internet
Author: User

The unity3d manual describes two terrain creation methods:

1. Use height tools to draw directly in sceneview

Ii. Using External tools to create heightmaps

 

 

It is very easy to draw terrain directly, but it is only suitable for creating small area maps. For real game projects, it is too complicated to pull the terrain. Generally, we use external tools, such as PS, for example, Max is used to create a height chart, export it as a grayscale image, and convert it into a terrain in the engine.


Unity3d also supports this method, that is, the method for importing heightmap. However, the format of heightmap must be a 16-bit raw grayscale image, however, there is no more description in this manual.


It doesn't matter. unity3d provides a method to export the terrain to heightmap. We can make a small map to export it and see it.


As shown in, set the terrain length, width, and height to 2 units, and the terrain precision to 33. This value is the minimum value that can be set. This indicates that there will be 17 height values in a unit, that is, 16 edges. Export the terrain to a 16-bit raw file.



 


According to the above data, the raw file will consist of 33*33 16-bit data, so the file size should be 16*16*2 = 2178 bytes. This is also true for Exported Files, proving that our inference is correct.


Note that the heightmap resolution here must be 2 plus 1 by the power of n times. As for why, find a document about heightmap and you will understand it.


 

Since our inference is verified to be correct, try to create a heightmap in PS and put it in unity3d. The heightmap we created is 129*129 pixels. If we make an unity3d unit composed of four pixels, the map size is (129-1)/4 = 32, that is, 32*32. The height value does not need to be too large. a height of 12 is enough.


After being imported to unity3d, a layer of texture is refreshed and several trees are planted. The final result looks like this:


 


Not bad. In fact, I didn't have such a good art cell. After playing with PS for a long time, I decided to go online to find a ready-made heightmap (pipeline)



Well, there should be no major problem in scenario creation. Next, let's take a look at how to put two moving items in.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.