Documentation/Programming Tutorials/How to Create a Terrain for NeoAxis using L3DT
From NeoAxis Engine Wiki
| Language: | Status: | Not Approved |
Overview
This is intended to be as simple a guide as I can manage to creating a terrain, importing it into your neoaxis world and putting a water plane on it.
Acknowledgements
- I am heavily indebted to Night Hawk's excellent tutorial, http://www.neoaxisgroup.com/phpBB2/viewtopic.php?t=2419, which I used as a basis for my first attempt at a terrain with L3DT. To some extent this document just follows his process, and it could be said all I've done is a bit of layout and minor changes (for updates to NeoAxis and L3DT)
- I suggest you read Night Hawk's tutorial as well as it is less minimal than mine and also has useful comments from forum users.
- It is a good idea when learning a new development environment to try to see things from multiple points of view.
Also a big thank you to all the NeoAxis community for their help.
Before you start
- You have installed and run NeoAxis, get from http://www.neoaxisgroup.com/neoaxis/downloads
- All the NeoAxis demos run okay for you.
- You know how to start the neoaxis map editor.
- You have downloaded and installed L3DT, get this from http://www.bundysoft.com/L3DT/downloads/standard.php
Versions
Tested with L3DT Std 2.7 (unregistered) and NeoAxis 0.59 (indie licence)
Summary
- First we create a suitable project in NeoAxis and prepare it for working with your new terrain
- Creating terrain files which will work with NeoAxis using L3DT
- Copying the terrain files to your NeoAxis project
- Then we create a water plane
- Finally we consider what things you might want to try next with terrains
Creating a suitable project in NeoAxis
Note. We do this first because of the side effects of saving a map in NeoAxis - it will delete or overwrite layer mask files
To start with
- Start up the NeoAxis map editor
- Create a new project, File/New Project
- Pick a new directory name under the Maps directory, e.g. Maps\My Snowy RPG or something more appropriate
- The main pane will be all black except for some text in the top left corner saying No lights
- Within your new map
- Create a HeightmapTerrain object and place it.
- To do this open the Types/Base tree in the Entity Types folder and left click on HeightmapTerrain
- The main pane will display the text Creating \"HeightmapTerrain\" entity (Click here to create)
- Do what it says and left click once in the main window pane
- A grassy flat plain appears, use the right mouse click and drag to rotate the camera.
- Create a SkyDome (or SkyBox if you prefer)
- To do this scroll the Entity Types window until you can see SkyDome and click it
- Then click in the main pane to create it
- A sky appears with moving clouds
- Save your map (File/Save)
- Open a explorer window (in Windows itself) and look at what has been created for you so far
- For example I need to look in D:\Program Files\NeoAxis Engine Indie SDK 0.59\Game\Bin\Data\Maps\My Snowy RPG
- Your directory will be different, but once you find the SDK it will be in the \Game\Bin\Data\Maps subtree
- Within here you will see a HeightmapTerrain subdirectory alongside your Map.map file
- Look inside HeightmapTerrain and you will see Heightmap.raw, Holes.raw and Layer1Mask.png
- The Heightmap is flat for now, we will be replacing that file entirely with one from L3DT
- Holes.raw is beyond the scope of this page, suffice to say it marks holes on your map through which players and AIs can pass. We will leave the NeoAxis created default holes alone.
- Layer1Mask.png is a mask file which controls where the Layer1 image should be overlayed on top of Layer0. Layer0 is the green grass for example.
Now we need to create all the layers we will use
because when you create and save layers NeoAxis splats over the top of any files you put into this directory, and we don't want to get into the mess I got into the first time I tried ;-), sooo....
- Select the HeightmapTerrain object in the Map Heirarchy window
- The properties window should display its Entity and HeightmapTerrain properties
- Change the heightmap size to 1024x1024 and answer Yes, This takes a few seconds
- Change Horizontal Size to 2048, another short wait (this controls the apparent size to the player)
- Leave masks size at 1024x1024
- Change VerticalSize to 200, (this controls how magnified the vertical positions are)
- ... you can modify these settings later once we get your terrain loaded
- Now the HeightmapTerrain/Layers need editing in their properties window popup
- Click on the word Layers in the properties window
- Click the mini-button ellipsis ... which is displayed to the right, after the word (Collection)
- The Layer Collection Editor is displayed
- In the Layer Collection Editor popup
- Click the Add button 3 times, until you have a total of 5 layers numbered 0,1,2,3,4
- Click OK, we will revisit this window later
- Do another save, File/Save (or Ctrl+S)
- Now, once again, Open a explorer window (in Windows itself) and look at the added structure
in the \Game\Bin\Data\Maps subtree
- You should find Layer1Mask.png and also Layer2... Layer3 and Layer4 masks.
- Close NeoAxis map editor
Creating a compatible terrain in L3DT
- Start up L3DT
- Create a new project, File/New Project
There is a multipage wizard which creates the project
- Select project type: leave as the default Designable map (recommended), click Next>>
- Heightfield size: leave all defaults 1024x1024, 10m horizontal scale giving a world size of 10 x 10 kilometres, click Next>>
- Design map size: leave as the default HF/DM ratio 64 giving 16x16 pixels, click Next>>
- Design map parameters: Adjust the sliders as you feel, pick a climate, click Next>>
- Calculation queue: switch on all the checkboxes except Water map, click Next>>
- Light mapping: leave all this as defaults, click Next>>
- Light mapping: (again) switch off the Water effects checkbox, should show LM size = 1024 x 1024 pixels, click Next>>
- Texture settings: Switch on the first 5 checkboxes (Use light map, interpolate textures, allow strata overlays, max. anti-aliasing and make high-resolution texture
- Move the slider next to Max. anti-aliasing all the way to the right, 32x
- Increase the TX/HF ratio spinner under Make high-resolution texture, to show 2
- TX size = 2048 x 2048 pixels should be displayed after the options, click Next>>
Click OK and let L3DT generate your files, this may take several minutes depending on your computer.
You should now see a lovely overhead picture of your terrain, save the L3DT project to disk somewhere sensible, but NOT in the NeoAxis tree (File/Save/Save Project As)
for example to the /My Games/L3DT maps/ folder
Exporting your files from L3DT
- Start L3DT again (if not still open) and open your project file
- Exporting the Heightfield
- Click the Heightfield tab (there's a row of tabs under the command buttons, under the menu) which is second from the left
- Export the Heightfield by selecting File/Export/Export Active Map
- Change the file format to RAW
- Set the options for export by clicking the Options button
- Doubleclick the word false on the line InvertY(bool)=false
- Type the filename Heightmap into the filename field, when you tab out of this field it will automatically append .raw
- Click OK
- Exporting the main colour map
This is going to become Layer 0, or the base layer, of our terrain
- Click the Texturefield tab (the rightmost tab, to the right of where you found Heightfield)
- Export the Texturefield by selecting File/Export/Export Active Map
- Change the file format to PNG
- Type the filename Layer0 into the filename field, .png will be appended
- Click OK (the width and height will be 2048x2048)
- Now we are going to quickly check progress so far from the NeoAxis map editor
Copying the first set of terrain files to your NeoAxis project and testing
- If NeoAxis map editor is running then close it
- Open two explorer windows
- Point one at the NeoAxis Heightmap directory for your map
In my case SDK\Game\Bin\Data\Maps\My Snowy RPG\HeightmapTerrain
- Point the other at your L3DT directory
In my case D:\My Games\L3DT maps
- Copy the Layer0.png file from L3DT to the NeoAxis directory
- Copy the Heightmap.raw file from L3DT to NeoAxis - it will overwrite the existing one and prompt you for this
- Restart NeoAxis map editor and open your map
- If you are disappointed by a sky cut through by random green lines, please don't be...
- Point the camera at the sky (right-click and drag)
- Fly forwards (press W) - you probably know NeoAxis uses WASD/QE for navigation by now
- Notice that the green texture is bumpy
- Now we will point Layer 0 at the correct image file
- Tick the checkbox by HeightmapTerrain under Map in the MapHeirarchy
- Click the word Layers (you may have to scroll the Properties pane down)
- In the Layer Collection Editor ensure 0(base) is selected
- Click BaseMap and then click the ellipsis (...) which appears to the right of the pathname
- Open Maps\My Snowy RPG\HeightmapTerrain (or wherever you found your NeoAxis files)
- Click Layer0.png and OK
- Click BaseScale and change the number from 10 to 2048
- Click DetailMap and then click on the filename and use End and then Shift Home to select the whole string, and then cut it (delete key)
- Finally click OK to the Layer Collection Editor
Tada !! A snowy mountainscape, or a tropical beach or whatever...
Exporting the Terrain Normals and your first layer from L3DT
The process is similar to what you did before, but a bit more involved because each layer involves a mask as well as an image file
- Close the NeoAxis map editor if it is still open
- Start L3DT again (if not still open) and open your project file
- Exporting the terrain normals
Terrain normals are values representing the angle between the normal of the slope of the surface (ie. right angles to the slope of the surface) and the incoming light direction - recall that you could have set the sunlight direction when you clicked through the terrain generating dialogs in L3DT earlier
- Click the Terrain normals tab (roughly in the middle of the row of tabs)
- As before, File/Export/Export Active Map
- File name TerrainNormals.png
- Click OK
Note. How many layers you end up with depends on the type of terrain you have generated, for example Snowy only gets 2, but others may get 6 or 7. You can only export 3 more layers than the base layer to NeoAxis as it stands Someone please correct me, but that's more than enough for now
- Generating the layers
- Select Operations/Alpha Maps/Generate Maps
- ...Alpha Maps can generate the layer masks we need...
- Layer masks tell NeoAxis where to draw different materials over the top of the underlying terrain colour map
- Make a note of the layers materials, listed in the left hand panel, you will need to find a detail texture file for each of these
- Click Next
- On Alpha map options change the image file format to PNG and click OK
- Looking at the layers
- Click the alpha_1 tab
- snow; 91% cover; alpha id 1
- - We don't need to export this as a layer mask, but for your information this shows where
- - (the white parts) the main colour map is the dominant feature
- - and where (the black parts) the other texture layers will be on top
- Click the alpha_2 tab
- rock1; 9% cover; alpha id 2
- - This is the first (optional) layer of a different material, in my case rock
- - (the white parts) where rock cover appears and a separate rock layer will be drawn on top
- - We are going to export this as Layer1Mask.png
- - (Note. Layer0 doesn't have a mask, it's just everywhere!)
- you may have more layers... in general each alpha id should be exported as the id-1 layer
- for example alpha id 4 would be exported as Layer3Mask.png
- Exporting one layer
- Click the Alpha_2 tab and then File/Export/Export Active Map
- Change the Image file format to png
- Click the Options button and change the InvertY(bool) setting to =true
- Type the appropriate layer mask filename, so for Alpha_2 we use Layer1Mask (the .png is added automatically)
- Click OK, L3DT takes a few seconds to generate the layer mask file
- For each extra layer to export, starting from _3
- Click the Alpha_n tab, e.g. Alpha_3, and then File/Export/Export Active Map
- Change the Image file format to png
- Click the Options button and change the InvertY(bool) setting to =true
- Type the File name to use, which will be for our layer mask so e.g. Layer2Mask for Alpha_3 etc.
- Click OK
Repeat this until layer masks for 2-N have been exported
- Now some file copying and back to NeoAxis to see your layers
Copying the second group of export files and testing
- If NeoAxis map editor is running then close it
- Open two explorer windows
- Point one at the NeoAxis Heightmap directory for your map
In my case SDK\Game\Bin\Data\Maps\My Snowy RPG\HeightmapTerrain
- Point the other at your L3DT directory
In my case D:\My Games\L3DT maps
- Copy the LayerNmask.png files from the L3DT directory to the NeoAxis one
- For each layer you also need to provide a texture file (which you can get an artist friend to improve on later, so for now I suggest, as did Night Hawk, that you use the TankDemo textures.
- So point the L3DT explorer window at SDK\Game\Bin\Data\Maps\TankDemo\Resources\Terrain
- and copy the dds texture files from there to your HeightmapTerrain directory
At this point someone will think, myself included, that a better layout of files for the art pipeline would make sense...
- by which I mean arrange directories and contents more efficiently for the separate but combined purposes of art creators, programmers, project building and so on.
- Someone is welcome to write a wiki section about that ! talk about a contentious topic
- by which I mean arrange directories and contents more efficiently for the separate but combined purposes of art creators, programmers, project building and so on.
- Restart NeoAxis map editor
- Nothing has changed yet... we haven't set the new things up in the Layer Collection Editor
- Fly up to get a nice downwards view from a decent height and then
- Open the Layer Collection Editor (select Map/HeightmapTerrain, then click Layers, then click ellipsis (...)
- For each layer after Layer0
- Pick one of the texture files to use, generally start with the bigger scale textures and move to smaller ones (such as sand/scattered pebbles)
- Set up the BaseMap to the same as layer 0, e.g. Layer0.png, and set the BaseScale to the same, e.g. 2048
- Then setup the DetailMap entry to your material for this layer, e.g. Rock_Diffuse.dds, you can experiment with different DetailScale settings
- and then setup the normal - where you have a normal file, which you do for your Layer0 (already setup), and also for the TankDemo textures
Note that the Layer<n>Mask files are automatically used by NeoAxis - You must have given them the right filenames, e.g. Layer2Mask.png for them to work
- If everything has worked you now have a snowy/desert/rocky map with extra sand/rocks/pebbles
- Experiment with the Basescale settings for the layers other than Layer 0
- You can click the [+] to the left of Layers in the properties window and edit the individual layers from there... you have to use the Layer Collection Editor to add new layers however.
Note. If you delete a layer then NeoAxis will remove the mask.. if you create it again it will create an empty mask... so work on copies of data from L3DT rather than pointing L3DT at your NeoAxis working directories.
Creating a water plane in NeoAxis and testing
todo
Other things to try and pitfalls
- Creating a bigger terrain
- Using modified shaders to improve the look of your terrain
If you notice any mistakes please do fix this page ;-)
or if you have any suggestions then just add a comment and I'll incorporate or find out what is involved.
Authors
Night Hawk (wrote the more extensive original tutorial, on forums, see link at top) and mrexcessive
Credits
Night Hawk for help getting this right
Suggestions area
- you may want better textures... we all do I think... snow seems to be a particular problem because of the clipping to white problem
- Night Hawk suggests using greyscale detail textures
- If your snow field clips to white out... try using darker and lower contrast detail textures
- Unless you are a dds file wizard and graphics savant... then export them to PNG and use a graphics program to make them into tiles. Yes I know DDS files support variable resolutions and clever things, but that's why professional artists are essential on 3D projects... I'm a programmer, if you are a programmer - stick to code and use tilable PNGs for graphics !! (just my 2c worth)
- Howto export DDS to good PNG
- First install the Microsoft DirectX 9 SDK... you probably have this already
- Double click a DDS file (e.g. Rock_Diffuse.dds from the TankDemo)
- Use an art program (I have Corel Paint Shop Pro Photo XI, but please don't hold that against me) to capture the screen
- Trim the texture so it has no extraneous lines
- Use the tiling feature of your art program (Effects/Image Effects/Seamless Tiling) or a tiling program to make a tileable texture
- Convert it to Greyscale
- Save it as PNG to a workspace directory e.g. \My Games\Textures\Rock_Tile_Greyscale_A1.png
- Try it out... repeat until looks nice enough so you can get back to coding ;-)
- If you can persuade a friendly artist person to make you some lovely textures as DDS with normals... then do, and ask them if you can post them to the forums !
- If you are a friendly artist person who can explain to a newb 3D person like me how to make lovely DDS files and have them look nice in my snow map (or any other type of map) then _Pretty Please_ write a wiki page about it... or email a rough of your article to me as a text file (mrexcessive _at_no_spam_thing_ gmail _dot_ com) and I will turn it into wikiness and iterate it with you
- Howto export DDS to good PNG