OFAC tut 3dsmax ogremax terrainmodelling

From OpenFrag

Jump to: navigation, search

Contents

Introduction

In this tutorial we'll look into how to create, edit and texture a terrain. It's assumed you have the knowledge of the previous tutorials.
Tutorial files: Download

Creating a terrain mesh

  • Create a plane at (0,0,0) in your scene, with dimensions 150*150 units and 40*40 segs. Name this object Terrain

  • Now we'll review 2 options to make this plane into a terrain.

#1 - Through mesh editing

  • Convert the plane to an editable poly

  • Enable soft selection
  • Create a basic terrain layout, I made a river and a mountain.

  • A tip: You can use use the Noise modifier to create a rough terrain within seconds.

Optional - Creating a heightmap from this mesh

  • This is a really neat tutorial to create a heightmap from your mesh: 3ds Max Heightmaps - Ogre3D Wiki
  • When we apply this to our own terrain we'll end up with this:


#2 - Using a heightmap

  • Add a displacement modifier to the plane
  • As bitmap, choose the heightmap we generated before.
  • Set strength to 20, it should look now something like this:

  • Convert the model to an editable poly to settle it all.

Well, that was easy, now let's paint the thing!

Vertex painting the mesh

  • Apply the VertexPaint modifier to the plane
  • With the current shader, we can use 3 layers of textures + one lightmap texture. This implies we'll be using the 3 base colors to define the layers, which are Red, Green and blue.
  • Make sure the Vertex color display is set to Shaded

  • Paint the terrain as you wish, of course this method is very useful for defining roads, rivers, mountains etc.

Well, that's done. Now we're going to apply the material.

Setting up the material

A few things first

  • Set your export directory as your base directory in the Scene settings
  • Add $(ExportDir)..\..\..\Projects\VisualStudio\OgreMaxViewer.exe "$(ExportFilePath)" to your After Export events.
  • Make sure the shader and the textures are in your export directory (they're in the tutorial files).
  • Refresh your ogre resources, by Ogremax --> Refresh Ogre Resources.
  • Keep in mind (otherwise artifacts will occur):
    • Use UV-Channel 1 for diffuse unwrap
    • Use UV-Channel 3 for lightmap unwrap

Creating the material

  • Create an Ogremax material and name it Terrain
  • Add the pass and technique, as done in the third tutorial.
  • In the first 3 texture units, add respectively sand (sand_068.jpg), rock (rock_02.jpg) and grass (herbe_3.jpg)

  • Enable the VertexTextureBlendVS_LM as the Vertex shader.

  • Enable the VertexTextureBlendPS_Lm as the Pixel shader, set the lightmapping to 0 for now and all the scales to 10.

  • Apply the material to your terrain, it should be something like this:

  • Now export the scene to check if everything is alright, don't forget to add a camera first!:

Creating and adding a lightmap

There are several ways to light a scene, in this case we'll use a skylight, which is simple but effective.

  • In your Pass, set the Render to Texture destination to 4
  • Create a skylight in your scene.
  • Go to Rendering ---> Render to Texture (0)
  • Set the output path to the export directory

  • Add a lighting map
  • Set the target map slot to: Technique 1

  • Select the Output Into Source option

  • Now, before rendering it, first go to Rendering --> Advanced Lighting --> Light tracer

  • In the render to texture window, click render, something like this should appear:

Note that the bitmap is saved to the fourth map slot in your material.


  • In the pixel shader, set the intensity to 1 and use_lm to 1.
  • Now export again and you should have your lightmap applied!

Note that in our map we don't have any overhangs or objects casting shadows on the ground, so the existence of the lightmap is barely noticeable here, feel free to add for example a box on the terrain and render the lightmap again, you'll see it casts nice shadows on the ground.

Conclusion

Well, that's about it. In fact, it's really easy to use multi-texturing and lightmaps on your terrain once you get the hang of it. Feel free to experiment with different models, types of light etc.

Personal tools
OpenFrag