[Unity] 4.3 terrain Editor, unity4.3 terrain

Source: Internet
Author: User
Tags unity 5

[Unity] 4.3 terrain Editor, unity4.3 terrain

Classification: Unity, C #, VS2015

Created on: 1. Introduction

Unity has a fully functional terrain editor that allows you to crop mountains, valleys, plains, Highlands, and other terrain in real time using a paint brush. The Unity terrain editor also provides functions such as real-time drawing of surface texture, tree planting, and arrangement of Large-area flushed grass. It is worth mentioning that the terrain editor in Unity supports the Level of Detail function, which allows you to adjust the terrain blocks (patches) based on the distance between the camera and the terrain ups and downs) the degree of density of the grid. Distant or flat terrain blocks use sparse grids, and close or steep terrain blocks use dense grids. This will make the game scenario real, fine, and not affect performance.

Note: terrain is somewhat different from other game objects. Terrain supports Position transformation in the Transform component, but for Rotation and scale) the operation is invalid. Ii. How to Create a terrain

You must be familiar with the following basic concepts before creating a terrain and plotting functions such as mountains, valleys, plains, Highlands, planting trees, and arrangement of wide-faced flushed lawns.

1. Add a terrain object

First, Create a new scenario, and then open "Terrain"> "Create Terrain" in the menu bar to Create a Terrain object:

A new terrain resource is created in the project, in the current scenario, add a terrain instance (the Project view and Hierarchy view contain the terrain-related files at the same time), as shown in:

After creating a Terrain object, you can see the components mounted to the object in the viewer view. In addition to the Transform component, there is also a Terrain component and a Terrain Collider (Terrain collision) component) component.

2. Terrain Components

The Terrain component consists of seven option buttons that allow you to draw Terrain fluctuations, surface textures, or additional details such as trees, grass, or stones:

The first three buttons are used to draw the Terrain Height.

(1) button 1 -- increase/decrease the height

Click this option. On the expanded tab, set the Brush Size, Opacity, and Brushes used for painting ), then you can draw the terrain by clicking or dragging the mouse in the scenario.

When you click the mouse, the height is increased. When you press the mouse, the height of the mouse increases until the maximum value is reached. To reduce the height, press Shift and then click the mouse.

(2) button 2 -- spray height

Click the 2nd button option at the beginning of the left side to enter the spray height mode. This mode is generally used to draw a smooth terrain, such as a highlands or Canyon.

Set the Brush Size, Opacity, Height, and Brushes used for painting ), you can use the mouse to move any part of the Earth to the desired height.

(3) button 3 -- smooth height

Click the 3rd button option at the beginning of the left side to enter the smooth height mode. This mode is used to soften the height difference of the area to make the terrain more smooth.

(4) button 4 -- draw texture

Click the 4th button option at the beginning of the Left to enter the texture painting mode. Click Edit Texture to add, Edit, and remove textures. Repeat the "Add Texture" process to Add multiple textures.

After adding a terrain texture, select the expected terrain texture, and you can use this texture to drag the left mouse button to draw the texture of the terrain, as shown in:

You can select different textures and drag the mouse to draw different types of terrain textures in the same scenario.

(5) button 5-planting trees

Click the 5th button option on the left to enter the tree planting mode.

Click Edit Tree to add, Edit, and remove trees. Repeat the "Add Tree" process to Add multiple trees.

Select the Tree to use and set the Tree Density (Tree Density) as the appropriate value. Then, you can draw the Tree in the scene. At this time, the current mouse position is marked as blue highlighted, as shown in, click.

You can plant trees wherever you click on the terrain. Hold down the left mouse button and drag the mouse to continuously plant trees on the terrain. Press Shift and click the ground to erase the tree planted in the corresponding position.

Settings ):

Bush Size: the Size of the brush. Set the size of the brush when planting trees. The value range is 1 ~ In the range of 100.

Tree Density: Tree Density. Controls the spacing of tree objects. The larger the value, the more dense the trees and the smaller the spacing. The value range is 10 to 10 ~ In the range of 100.

Tree Height: The base Height of the Tree. The larger the value, the higher the tree. The value range is 50 ~ In the range of 200.

Color Variation: the random variable value that can be used for the Color of each tree. The value ranges from 0 ~ Between 1.

(6) button 6-Grass Planting

Click the 6th button option at the beginning of the Left to enter the Paint Details mode, which allows you to draw lawns (using Grass Texture) and the Detail Mesh that specifies the detailed description of the lawn ).

The Target Strength in Settings indicates the Target Strength, which is used to control the grass planting and the shadow generated when the detailed mesh is added. The value range is 0 ~ Between 1.

Click Edit Details ...], In the shortcut menu that appears, select Add Grass Texture, select a lawn Texture, set relevant parameters, and click Add to Add a lawn:

Details Texture: Lawn image.

Min Width, Max Wdth, and Min Height: set the minimum Width, maximum Width, and minimum Height of the lawn.

Noise Spread: Noise range. Used to control the size of Grass-generated clusters. The lower the value, the lower the noise.

Healthy Color: Healthy Color. The color is obvious in the noise center.

Dry Color: Dry Color. The color is obvious at the edge of the noise wave.

Billboard: a Billboard. If this option is selected, the grass will always face the main camera as the camera rotates.

Click Edit Details ...], In the shortcut menu that appears, select Add Details, select a grass preset, set relevant parameters, and click Add to Add a grass preset:

After these two options, you can use the mouse to plant grass in the scenario.

Press Shift to delete the selected detail grid, and press Ctrl to delete the selected detail grid.

(7) button 7-terrain parameter settings

Click the 7th button option on the left to enter the terrain setting mode.

The parameters on the Basic Settings tab are as follows:

Draw: whether to Draw the basic terrain.

Pixel Erroe: Pixel tolerance. Pixel error allowed when displaying the terrain grid. It is a parameter of the terrain level-4 system.

Base Map Dist: basic Map distance. Set the distance for displaying high-resolution terrain maps.

Cast Shadows: projection. Set whether the terrain is shadow.

Mterial: material. Click the circle button on the right to specify materials for the terrain.

Parameters on the Tree & Details Objects tab are as follows:

Draw: If this option is selected, all trees, grass, and detail models are rendered.

Bake Light Probes:

Detail Distance: Detailed Distance. This parameter is used to set the distance from the camera to stop rendering details.

Collect Detail Patches:

Detail Density: Detail Density. This item is used to control the density of details. The default value is 1. If this value is adjusted to a smaller value, the over-encrypted terrain details will not be rendered.

Tree Distance: the Distance between trees. This parameter is used to set the distance from the camera to stop rendering the tree object. The higher the value, the farther tree will be rendered.

Billboard Start: starts a Billboard. This option is used to determine the distance from the camera to render the tree as a billboard.

Fade Length: gradient distance. This item is used to control the transition speed of the tree object from the model to the billboard. If the value is set to 0, the model changes to a billboard.

Max Mesh Trees: Maximum Mesh tree. This item is used to control the maximum number of all model trees on the terrain.

The parameters on the Wind Settings for Grass tab are as follows:

Speed: Speed. The top is used to set the speed at which the wind blows.

Size: Size. This item is used to set the impact of the wind.

Bending: Bending. This item is used to determine the degree of bending of vegetation by wind.

Crass Tint: Specifies the color of grass. This item is used to set the overall color of all grass and detail grids.

The parameters under the [Resolution] tab are used to set relevant attributes after adding a terrain object. The parameter description is as follows:

HeightMap Resolution: height graph Resolution.

Detail Resolution: detailed Resolution. Controls the map resolution of lawns and detail grids. To improve the rendering performance, set this number to a lower value, for example, 512 or 256.

Base Texture Resolution: basic Texture Resolution, used to replace the compound Texture Resolution of a splash map at a certain distance. Iii. Example (Demo05)

This section describes the basic steps for actual operations. After you are familiar with these basic steps, you can draw various beautiful terrain. After following these basic steps, you can get the following simple example:

1. Add a terrain object

In the hierarchy view, right-click and choose "Terrain"> "Create Terrain" to Create a Terrain. In this case, a Terrain component named New Terrain is automatically added under the Assets of the Project.

Drag and Drop New Terrain under Assets of the Project to the demo05subfolder and rename it Demo05Terrain ].

After selecting the Terrain in Hierarchy, you can use the F (Focus) Key to easily navigate the Terrain. After you press F, no matter where the mouse is located, it will be moved to the center of the Scene View. In this way, you can polish a region, quickly move to another region, and modify other things. If you press the F key and the mouse does not hover over a certain area of the Terrain, the entire Terrain will be placed at the center of the Scene View.

2. Set the terrain length and width

In the view chart, click button 7 in the terrain component, modify the parameter settings under the Resolution tab, and set the terrain Length (Length) Width to 2000, other Default values:

The following is the default value after the terrain is first created in Unity 5.3.4:

Width (Terrain Width): 500

Length (Terrain Length): 500

The Height is 600.

Heightmap Resolution: 513

Detail Resolution: 1024

Detail Resolution Per Path: 8

Control Texture Resolution: 512

Base Texture Resolution: 1024

3. Draw Mountains

In the view chart, click button 1 in the terrain component, and then draw the initial effect of the mountains on the terrain. This step mainly grasps the effect of the mountains from the overall perspective, just draw the rough ups and downs of the mountains:

In the Brushes bar, select the paint style to add a detailed structure to the mountains to simulate the ridge effect:

4. Draw a flat ground

Draw a smooth area of the mountains, as shown in:

Tip: by holding Shift and clicking or holding the left mouse button, you can get the height of the corresponding position of the paint shape in real time and set the height to the height of the brush.

5. Add materials to the terrain (optional)

Right-click the Demo05 folder and create a material in the folder:

Name it Demo05Material ]:

Select the Demo05Material material and click the button on the right of the Shader in the Inspector view. In the displayed list box, choose Nature> Terrain> Diffuse to specify the shade for the terrain material:

Select the terrain. In the Inspector view, click button 7, and then click the circle button on the right of the Material item. In the displayed Sehct Matmal dialog box, specify the created texture for the terrain:

Note: The terrain material is not required. Generally, the texture of the terrain is not set to change the rendering Shader of the terrain. If this material is set to null, Unity uses a set of built-in terrain materials.

6. Add a texture

Click button 4 in the Terrain editor to switch to the Paint Textures mode. Click Edit Texture and select Add Texture. The Add Terrain Texture dialog box is displayed, click the Select button on the top of Texture and specify a Texture as the first layer Texture of the terrain in the Select Texture2D dialog box that appears:

After the first layer texture is specified, Unity will automatically tile the first layer texture on the whole terrain. To modify the tile size, click Edit Texture and select Edit Texture, in the displayed dialog box, adjust the value in the X and Y directions of the Size item.

After the first layer texture is specified, you can specify other textures for the terrain to enrich the terrain effect. The method is the same as that for the first layer texture. Specify the texture and then select the new texture. Use the paint brush to draw the texture to the terrain.

7. Add a pavement

The method is the same as "6. add texture.

Below is the added pavement texture:

The following figure shows the effect of adding a pavement:

8. Add a tree

After the texture of the terrain is drawn, add a tree for the terrain. Click button 5 in the terrain editor to switch to the Place Trees mode. Click Edit Trees and select Add Tree ], in the Add Tree dialog box that appears, click the circle button on the top right of the Tree to go To the Se! In the "ect CameObject" dialog box, specify the-tree as the terrain tree (repeat this operation to add multiple trees ):

After adding a tree, select a tree in the Trees preview box. After setting the appropriate parameters, you can use the paint brush to plant Trees on the terrain:

If you want to modify parameters such as the style of the added Tree or the extent of the affected wind volume, select the Tree to be edited in the Tree preview box and click Edit Trees, select Edit Tree and Edit it in the displayed dialog box.

To Remove a Tree, click Edit Trees and select Remove Tree.

9. Add grass and shrubs

After creating the tree, add the grass, shrubs, and other details to the terrain.

Click button 6 in the terrain editor to switch to the Paint Deails mode, and then add lawn, shrubs, and other details. The usage is similar to the method used to add trees. I will not go into details here.

10. set other parameters

When you are familiar with it, you can use the options in the terrain Editor "button 7" to set the effect of wind and grass and trees. Finally, add a light source to make the entire scenario look bright and beautiful.

Related Article

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.