Reproduced Chinese tutorial for t4m plugin in Unity

Source: Internet
Author: User

PS: Original source: http://blog.csdn.net/tianmao111/article/details/46482963

What is T4M? Why do you use it?

It is a topographic (terrain) tool.
It is an alternative to unity terrain for all geometry created by 3D development tools (MAYA,EARTHSCULPTO,3DS Max,blender, etc.).
Initially, it was used only for mobile devices, but more people found some other benefits:


T4M is a tool that allows users to import geometry into unity as a terrain (terrain).
T4M for web and for mobile are very small at compile time, with only one draw call, fast loading speed and powerful performance (same as for legacy devices).


So I decided to target all the platforms and put forward a complete set of solutions (e.g. elevation tool yet).
For each imported geometry, t4m includes texture drawing, drawing trees and grass, and a detail (LOD) system and billboard.
T4m can also convert the unity terrain to include mixed textures (blend texture), 4 times-fold textures (an enhanced texture performance and storage removal transparency map) (the first four splat textures) geometry, and use all of its advantages over an imported geometry +t4m system.

All features are compatible with Unity free and Pro editions.

Characteristics:

Shader Model (Iphone,ipad,andoid,web,pc,mac,flash naci)
Convert terrain to t4m, maintain all textures and blend textures (it uses 4 times-fold textures)
Convert your own imported mesh (you are free to make terrain with other 3D software)
Draw and place any object you want, under the new drawing system
Integrated Detail (LOD) system
Integrated signage System
Draw directly from material material
Best Refresh Preview
Compatible with Unity terrain shaders, you can use your own shader
Returns or resets the already painted operation
Add your own paint brushes (64*64)
Compatible with real-time shadows, light maps and directional illumination maps

In advance, this tutorial uses the t4m v2.41 version, Unity is the 4.6.3 Pro version, please ensure the same as possible to avoid discrepancies

A good start, you need to follow these steps:

1: Add the 26,27,28,29,30 layer as shown in:

2: Open the main interface of t4m via the menu window->t4m Source codes:

The tab buttons on the top are listed in the following order:
1: Converter
2: Optimization
3: My t4m
4: Painting Brush
5: Plant
6:lod Details
7: Billboard
Right button: Activation/Deactivation Controller

Conversion function:

Add a gameobject as follows:

To put a script on the object

Select this game object and the interface should be displayed at this time. If the current interface is different from this one, please click the Controls button in the upper right corner to ensure that the current value is activated

At this point we name Myterrain, note that the Newprefab option can be selected, the impact is described below.
Click the Process button and if successful, you should see the following prompt:

The new catalog T4mobj will be found in your project at this time. If you choose not to select the Newprefab option before, the result will be the same

At this point, a new script is mounted on the prefab

In addition to mounting the T4mobj SC script above, a new component is mounted on the prefab as follows:

If you choose the Newprefab option, you will follow the same

Note that at this time, there will be more than one terrain prefab in the terrains directory.
Well, your model is ready.

Terrain conversion to t4m

I randomly set up a map as follows:

At this point the t4m operation interface is as follows:

Start a name again.
If you want to make sure that the texture is a multiple of 4, select the Keep the textures option here without the tube
Adjust the quality you want with the sliders (actually adjust the number of vertices you want)

Note that the following is the vertex display: What is the function? What does it mean to look at the explanation and know it as an approximate sign?
Look at the bottom of the equipment are ticked, when you adjust the top slider, it is possible that the bottom of the hook will become yellow exclamation mark


You will find that some devices are no longer supported as the sliders represent the number of vertices that are becoming larger.
OK, we click the Process button and the following options appear:

Did you see those buttons? The functions are as follows:

1: Keep your conversion results and destroy the prototype
2: Modify the options to open a new conversion until the best effect
3: Perform top two actions and continue

Note: If you select too many vertices, unity automatically splits the mesh into several parts. Don't worry, t4m will use the split terrain.

Okay, now your terrain is ready to use.

Optimization

In, you can adjust the quality and compression rate of the T4m game object

Optimization of load time is the best load times to ease the burden on the Unity engine
Level slider, a total of 4 levels, each selection will see the following corresponding description:

Level0: Reduce the 3D engine burden by simply organizing the vertex order
level1:level0+ Lower mesh compression (low mesh destruction)
level2:level0+ Moderate mesh compression (moderate mesh destruction)
level3:level0+ High mesh compression (grid appalling)

My t4m.

Select the 3rd tab option, such as:

Note, select shader Model 1 o'clock, at this time there are 3 shader support

T4m_2 2 for 2 textures
LM for compatible illumination map
2DC means 2 draw call (so the number of upload vertices is also * *)

Similarly, Shader model2,3 have some Shader support, which is not listed here, and I'll explain it in a separate section.

t4m settings

Master t4m object: A t4m main object is a standalone game object used to control camera, detail (LOD) and billboard, you can just use one in the scene.
If you have more than one T4m object, the Scenecamera parameter can be adjusted to rely solely on the primary object.

Scene Camera: By default, T4M looks for the main camera in the scene, but you can use a different camera to view details (LOD), billboards, or hierarchy culling distances. The

Activate lod,activate billboard are switches for details and billboard systems, respectively.

Active layerculldistance: You can use 4 different view distances, by using layers.
This is a good idea for the performance of mobile devices.

Maximum Distance of View:
If the layerculldistance option is turned on, you can adjust the distance between the camera and the Terrain object (the model we converted earlier).

said half a day what is the level distance? Do you remember the layer we built before? Did you find that their names are exactly the same as the 4 distance names in? Yes, they are.
For example: closedistance you set 30, then the objects within the close layer will be hidden when the distance from the camera is greater than 30, is this clear?

When you have finished all your adjustments, click the Update button

ATS Mobile Foliage

This system specifically adjusts the wind direction, the frequency of wind, the frequency of wind blowing, You can also download the specified settings to the assets store. Look at the title also know that this is mainly used for mobile devices.


Draw

If you want to draw, you have to add some materials, so we must first select the following tab

I don't have to say much about painting brushes. What do the 5 sliders below do? He represents your map granularity, 1 indicates a degree of fineness, the greater the value, the more smooth the surface, the more detailed.
Joinx/y indicates whether the same value is used for x, Y.

Select a material tab, such as:


Before selecting a material, you must select the material type (Material type), first select Classic (default)
Click the small circle to the right of texture to add, select the material you are interested in, then click on the specified black triangle to place the selected material in the top list. In this diagram, I have selected 4 graphs.
You can re-adjust the material with the Modify function by selecting the diagram in the top list.

One might ask, how did the number of black triangles come from? Let's take a look at the previous section where we set up a Shadermodel version.

See, here are 2 texture mixes, click on the update below and look back at the bottom interface:


There are only 2 small triangles left. This is how the number of textures that can be blended is determined by the degree to which different graphics cards support different versions of Shadermodel.
By repeating the above steps, you can mix the desired effects.

If you want to use bump mapping, then you have to go back to the Myt4m interface

Select a bumped related shader, point update. At this point the drawing interface becomes the bottom of the image


At this point the Modify list has more bump maps, I have selected a bump map.
The use of the material type selection substances is not described at this stage.

Painting Brush:

You can add your own brush in the following directory

You can add a 2D png image of your favorite 64*64 as a new brush, and don't forget to keep 1 pixels blank at each edge of the picture.

Plant

Add a tree model by adding a to List option and click on the corresponding black triangle button. The tree model is now added to the list.


At the bottom of each tree model is a menu to select the owning layer


There is also a checkbox above the menu, which allows you to randomly draw one of the tree models with all the tick marks, and t4m is automatically selected.

Plantmode: You can choose to draw the tree to follow the normals, or to tilt the terrain surface
Localsize: You can increase or decrease the size of the tree
Sizevar: Random number, which allows you to choose a random size between-localsize and localsize. is 0 o'clock, which means no random.
Y Origin corrector: The tree start y offset correction allows you to adjust the distance between the start of the tree and the ground.
Createcollider: If you select it, T4M creates a mesh collider script on each tree instance.
Static object: Creates static objects for lighting map shadows, or static batch processing for Unity Pro.
Group Name: Creates a folder on the stage for grouping objects.

Figure 1


The main function of Spacing distances is to avoid overlapping between game objects.
Safe zone: In a circular safe zone, no other objects appear. When you draw, your brush will show a circle, if there is already a tree in the radius of the circle, click again, there will be no response. This value is the radius of the security zone (the minimum distance between the tree and the tree), as follows:

If you select the Random Spacing option, the menu will look like Figure 1.
Note that the random Instance zone can never be less than the safe zone value. When safe zone is less than the random Instance zone, the paint brush will look like this:


In this case, the green area is always safe, the yellow circle represents the random instance area, and the yellow coil represents the random distance computed between the safe area and the random instance.
Each time it is plotted, the distance is recalculated based on these two values, which is more realistic than using a fixed value.
In a word, the yellow coil is the real safe zone.

You can set the value of the random rotation, and the panel looks like this:
Randomly rotates each drawn object to increase the realism of the scene.
The X and y values affect the tilt of the object, and the Y value adjusts the up rotation.

Hold down the SHIFT key and this is the erase mode, as shown in:

It allows you to remove objects that have already been drawn.

Hold down the CTRL key (PC) or cmd key (MAC), which is the replacement mode, as shown in:

It allows you to replace all the trees in the yellow area, replacing the new tree that you selected in the tree list.
The new tree inherits the rotation and position of the substituted person.

When you select a tree and then press the G and H keys, you will find that the model you selected rotates in a different direction along the Y axis, as shown below:

When you press the "+" and "-" keys on the keypad (note that you must be a keypad). Adjusts the distance offset between the tree object Origin (pivot) and the ground.

LOD Systems

Mass control: Each object is managed by the same algorithm, so that all the details are changed at the same time, the visual effect is not very good.
Independent control: Each object is managed by itself, so the details change is process-wise, the best effect.

The Max View distance:t4m out the detail object based on the script.
However, if the Layerculldistance option (review myt4m) is activated and the distance between the object's layer and the camera is less than the value of the maximum view distance, then the maximum view distance method has no effect. Because Layerculldistance will handle culling before the script.
The layerculldistance option is simply to choose layerculldistance culling.
The smaller the value of the Maximum View distance, the more severe the culling.

LOD Update Interval in seconde: This value is important because it is a time interval to refresh the state of the detail object. Note that the value is not too small, which adds to the burden on the mobile device.

LOD2 is the distance you want to change the LOD1 detail object with the LOD2 detail object. 0 means that only LOD1 detail objects will be visible, greater than this value indicates that the LOD2 detail object replaces the LOD1 detail object.
Similarly, if the distance is greater than the value of LOD3, the LOD3 detail object replaces the LOD2 detail object.

Click on the Activate button and you'll see LOD details on all scenes.
Note that each time you draw another new object, you will have to re-click the Activate button to update it.

Maybe someone would ask LOD1 what is it? Don't worry, here's the introduction.

LOD Designers

A menu to create t4m-compatible detail objects


LOD Meshes

LOD1 Close: The largest and most meticulous grid here
LOD2 Medium: Medium detail grid put here
LOD3 far: Worst detail grid put here

LOD Setup

Place the Meshcollider in this Lod: as it says, add a collider to the selected LOD mesh object.

LOD Shader Menu

NEW: Use the specified shader to create the material, and select the main or bump map according to the different shader.
Already Exist: Selecting a material that already exists

I've set up the corresponding 3 grids.

Once you've set up the 3 LOD setups, you can click the Construct button to generate the detail object, such as:

You can find the object you generated in the Lodobjects directory.
I don't have a choice to build a new material here, and if you create a new material, you'll find the material you created under Lodobjects/material.
Note that if you do not set the complete 3 material, you will be prompted to complete the calculation of the formula.

Let's take a look at Mylod.

Advertising Board


The setting of the billboard is basically the same as the Lod object, please refer to the above explanation.
BillBoard Rotation Axis: You can choose to rotate along the y axis or all axes.
Remember to re-click the Activate button every time you add a new object to the terrain, and then update it.

The creation of billboards is also similar to the creation of Lod objects.
Select the Custom option, you will need to select the grid yourself.
Okay, no problem. Click the Activate button and the following directory appears:

Reproduced Chinese tutorial for t4m plugin in Unity

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.