TTP Map Tutorial: Terrain Part 1
Let's start by adding a Terrain to our map so that we can actually test it. To do that we need to add a Simple model and adjust its parameters to our needs. So in this part of the tutorial we will
- add a Simple model and position it;
- create a mesh for that Simple model;
- create a shader for the mesh and set its material attributes.
Adding a Simple model and Positioning it
To add a Simple model entity simply move your mouse over the viewport and press Ins. By default this action adds a Simple model to the world at the position the mouse points at. In the viewport you should now see something like this:
The green box is a place holder for the mesh that we are about to create.
Also note the yellow outline around the edges of the box. They indicate that this entity is currently selected which is important for the following. If there's no selection outline around the entity, select it.
Now we want to position the Simple model at world spawn, i.e. coordinates (0, 0, 0). To do that, we need the Tools panel of the Property group. It is activated/toggled by pressing Q. If you don't see the Tools panel after pressing Q, simply press Q again. Now you can edit the values X, Y, and Z to position the Simple model. Tab ↹ switches from the current line to the next.
On the right you can see what the Tools panel should look like after editing the position data.
Creating a Mesh
Now it's time to make the Simple model look like a floor. For that we need the mesh editor of Serious Editor because we are going to create a new mesh. To activate the mesh editor you can double-click on the Simple model in the viewport. Alternatively, if the Simple model is selected
- press E, or
- select the mesh editor from the dropdown menu in the bottom left corner of the viewport.
Don't worry that the green box disappears once the mesh editor is activated. This is due to the fact that it is just a place holder until a new mesh is added:
- 1. Select the Create tab in the Command bar group on the right of the editor.
- 2. In the Create tab select 'Terrain'. The top right corner of the viewport will now show 'Tool.Primitive.TerrainTool'.
- 3. If the Tools panel of the Property group is not active anymore, toggle it with Q.
- 4. In the Tools panel expand 'Box guide', and then expand 'Box size'.
- 5. Edit the values of Box size X and Box size Z to '64'. Box size Y can be anything (but should be '0') because terrain meshes do not have height.
Note: Terrain needs height parameter if you're going to make terrain outside the editor. In programs like Earth Sculptor and World Machine you can export Heightmap after making terrain. Then you can use that heightmap to use terrain in SED.
Note: Consider that your terrain surely can be bigger than 64x64. In case of some 512x512 terrains you'll need more polygons. That can be changed in the same tool which you use to create terrain, just look at the top of it to find "X segments" and "Y segments". Those are amount of polygons per side. The final number of polygons is calculated by multiplying each of these parameters.
- 6. Move your mouse outside the Tools panel and press D to exit the terrain tool.
And that's it already. The mesh editor automtically adds the right amount of polygons for a terrain with 16 x 16 segments/polygons. Now there's only one thing left to do so that we will have a terrain that the player can actually walk on. In the Mesh panel of the Property group the parameter 'Enable collision mesh' needs to be checked so that the player will not fall through the floor.
If you exit the mesh editor (by pressing E), you can already test this creation with T. Ok, it doesn't look or feel right yet but we'll get there with our next step:
Shading the Terrain
To apply a shader (i.e. a texture) to the terrain mesh we need to return to the mesh editor (E) and do the following:
- 1. Activate the Layer panel of the Property group. If it doesn't show at the bottom of the Property group window press Alt+1.
- 2. Expand 'Polygon maps' and open the dropdown menu displayed on the right by clicking in the value field of the 'Default' line. Select 'New' → 'ShaderPreset'. It should be noted that this dropdown menu is called 'resource control' because it is used for every parameter that requires a pointer to a resource.
- 3. Add a new configuration by clicking on the yellow plus sign.
- 4. Open the resource control for the newly added 'Shader' parameter and select 'Browse'.
- 5. In the dialog that opens select 'Standard' by double-clicking on it.
- 6. In the newly added standard shader in the Layer panel search for the entry called 'base texture' and open the resource control for it. Select 'Browse' in the dropdown menu.
- 7. A File List Dialog opens that let's you choose the texture you want to apply to the mesh. For this tutorial I chose
- 8. In the entry below 'base texture' called 'base uvmap' type 'Y-plane'.
- 9. Move your mouse over the viewport and move until it says 'Shader' in the second field of the top left corner of the viewport.
You should now see the floor texture applied to the terrain mesh in the viewport. Go ahead and test what it looks like in-game. You will see that the texture appears too small and very repetitive. That is due to the UV map setting 'Y-plane' which takes the texture specified in 'base texture' and fits it into a square of 1 x 1 meter on the plane that cuts the y axis. To change that we have to adjust the stretch of the texture. Right under the base uvmap entry you can find 'base strech u' and 'base stretch v'. Set the values for both parameters to 0.25 and you will see that the size of the tiles looks more like it.
Now what still looks a bit odd is that the floor is all flat even though the texture suggests indentations. This can be corrected. We will use a height map and a normal map to adjust the rendering of the base texture. A height map adds height data to the base texture, a normal map is used to generate a more detailed shading of the base texture.
- 1. Go to the entry 'height map' in the Layer panel, open the resource control and select 'Browse'. Select file
- 2. Three entries below that you can choose a 'normal map' with the resource control. Browse for the file
- 3. To adjust the stretch of the normal map to the stretch of the base map set both 'normal stretch u' and 'normal stretch v' to 0.25.
- 4. In testing I found the bumps of the texture too strong so I adjusted the 'heigth bias' to 2.5 and the 'bump strength' to 0.25. But that's just my personal preference.
If you want to, test the result of each of these actions in-game (don't forget to switch between world and mesh editor). Play around a bit with the above parameters to see how these few parameters influence the feel of the texture.
Now there's only one thing that's missing: you may have noticed that there is no sound when you walk on the floor. To add sound we need to attribute a material to the mesh. To do so minimize the shader and right underneath it you will see the entry 'Material attributes'. With the resource control browse for
And there you go (literally when you test it ;).