Difference between revisions of "A Simple First Megatexture"

From Mod Wiki
Line 5: Line 5:
 
* Have a terrain model UV-mapped in the 0-1 range (covered in the simple first terrain tutorial)
 
* Have a terrain model UV-mapped in the 0-1 range (covered in the simple first terrain tutorial)
 
* Have access to some tiling textures. TODO: Link to MegaTexture media!
 
* Have access to some tiling textures. TODO: Link to MegaTexture media!
 +
* Have a little understanding the ETQW material system
  
 
If you don't have either of the above things, you are not ready to do this tutorial!
 
If you don't have either of the above things, you are not ready to do this tutorial!
Line 18: Line 19:
 
* How to create tiling textures or heightmaps
 
* How to create tiling textures or heightmaps
 
* Anything overly complicated
 
* Anything overly complicated
 +
  
 
== Creating a MegaTexture Material ==
 
== Creating a MegaTexture Material ==
Here is an example:
+
Firstly you need to create a new material for your terrain to use. If you have never made a new material before, read the article on [[Adding Custom Textures]]. All you need to do is create (or use an existing) ''.mtr'' file and place a material declaration in it, in the manner shown here:
  material megatextures/<mapname>
+
  material megatextures/mapname { useTemplate megatextures/default_ambient< "mapname" > }
 +
 
 +
This material would automatically search for a MegaTexture called {{filename|mapname.mega}} in the {{filename|/megatextures/}} folder. This example material uses the ''"default_ambient"'' template, which expects a 3-channel RGB MegaTexture. These are generated by the default settings of the [[Generate a MegaTexture|MegaTexture tab in the SDK Launcher]].
  
== Assigning a Material ==
+
Obviously you would want to use the actual name of your map instead of "mapname", for consistency's sake and ease of reference.
[[Image:simpleterrain_textured.png|thumb|200px|Textured terrain mesh]]
 
It is not possible to assign materials to terrain meshes in EditWorld, you must do this process in your modelling application. You can then re-export your terrain model to LWO, ASE, or OBJ format.
 
  
Setting the mesh material differs between modelling packages. Usually it is just the high-level name of the material applied to your terrain mesh (the name of any bitmaps assigned will not make a difference).
+
Remember that if you made a new ''.mtr'' file after the game or editor was started, you'll have to restart the whole game and editor before it will read your new file.
  
Due to an oddity with the OBJ format, the material name {{filename|megatextures/<mapname>}} is not valid inside an OBJ file. Instead, the material should be named {{filename|megatextures__<mapname>}}, where the slashes are replaced by double underscores (single underscores will not work!).
+
=== Assigning the Material ===
 +
You should assign the material you just created by naming a material in your 3D application and applying it to your terrain mesh, then export the model to your preferred format (LWO, ASE or OBJ).
 +
Tips on this process can be found in the [[A Simple First Terrain|simple first terrain tutorial]].
  
If you are using Lightwave, 3ds Max, or Maya, you should not have to text-edit any files, just set the material name in the relevant section of the material editor.
 
  
editWorld can then be told to reload the OBJ (now with a proper material declaration) via ''Misc -> Reload -> Models'' or clicking the "Reload Models" button.
+
== Creating the Surface Tree ==
 +
As described in the Simple First Terrain tutorial, terrain models are set up in the Terrain Editor, accessible via {{accelkey|shift}}{{accelkey|N}} in [[editWorld]]. This tool creates a Surface Tree file ({{filename|.sft}}) that contains all the information about the terrain, including roads, stamps, and detail texture information that MegaGen needs to generate a MegaTexture.
  
''Instead of using the concrete texture, you can use one of the existing Megatextures. For example, to use Area22's megatexture, simply set the mesh's material name to {{filename|megatextures__area22}}.''
+
=== Add the Terrain Mesh ===
{{clear}}
+
[[Image:simpleterrain_terraineditor2.png|thumb|300px|Root node set up to use the correct terrain mesh]]
 +
Here's how you bring the terrain mesh into the surface tree:
 +
* Press ''"Begin Editing"'' at the bottom of the Terrain Editor window.
 +
* {{accelbtn|RMB}} on the left-hand pane and create a new Tree via the menu.
 +
* Click on the Root node, and set {{keyname|Model}} to the name of the terrain mesh, in this case {{keyvalue|models/terrain/simpleterrain.obj}}.
 +
* Press {{accelkey|enter}} to confirm the selection, and the terrain should appear in the 3D view.
  
== Creating the Surface Tree ==
+
Be aware that your terrain model will probably appear bright orange or red. Don't worry, this is because your Megatexture doesn't exist yet!
Terrains are set up in the Terrain Editor, accessible via {{accelkey|shift}}{{accelkey|N}} in [[editWorld]]. This tool creates a Surface Tree file ({{filename|.sft}}) that contains all the information about the terrain, including roads, stamps, and detail texture information that MegaGen needs to generate a MegaTexture.
 
 
{{clear}}
 
{{clear}}
  
[[Image:simpleterrain_terraineditor2.png|thumb|200px|Root node set up to use the correct terrain mesh]]
 
To set the mesh to the map, first press 'Begin Editing' at the bottom of the Terrain Editor window. Then {{accelbtn|RMB}} on the left-hand pane and create a new Tree via the menu. This creates a Root node on which all the terrain information resides. Clicking on the Root node allows a model to be specified - set {{keyname|Model}} to the name of the terrain mesh, in this case {{keyvalue|models/terrain/simpleterrain.obj}}. Press {{accelkey|enter}} to confirm and the terrain should appear in the 3D view, with the red placeholder material.
 
{{clear}}
 
  
 
== That's it! ==
 
== That's it! ==
[[Image:simpleterrain_ingame.png|thumb|400px|Terrain in-game]]
+
[[Image:simple_mega_ingame.jpg|thumb|300px|The MegaTexture in-game!]]
 
You've now created a map with your very own MegaTexture!
 
You've now created a map with your very own MegaTexture!
 
{{clear}}
 
{{clear}}
  
== Terrain Mesh UVs ==
 
If you find your MegaTexture is not displaying correctly, it may mean your mesh UVs are incorrect. Consult your modelling package to find out how to reset or unwrap the UVs on the terrain mesh.
 
 
=== Important ===
 
Terrain model UV coordinates are expected to be inside the 0.0-1.0 UV range. If they are not, you may find that your terrain flickers or stretches when compiled into the map. If you are experiencing these problems, try a simple Planar Map from above, to project UV coordinates down onto your terrain mesh. (Blender instructions: select all the UV faces, hit {{accelkey|u}} and select 'Unwrap')
 
{{clear}}
 
  
 
== See Also ==
 
== See Also ==
* [[An Advanced Terrain and Megatexturel]] - an advanced guide for complete MegaTexture creation
+
* [[An Advanced Terrain and Megatexture]] - an advanced guide for complete MegaTexture creation
 
* [[Generate a MegaTexture]] - steps for generating a MegaTexture from the SDK launcher.
 
* [[Generate a MegaTexture]] - steps for generating a MegaTexture from the SDK launcher.
  

Revision as of 14:43, 11 December 2007

So now that you've made A Simple First Terrain, no doubt you'll want to apply a MegaTexture to it! This MegaTexture won't be as detailed or as attractive as an advanced MegaTexture, but will demonstrate the basics of creating a Surface Tree, assigning textures, and compiling it all into a working MegaTexture file.

Introduction

For this tutorial you must:

  • Have a terrain model UV-mapped in the 0-1 range (covered in the simple first terrain tutorial)
  • Have access to some tiling textures. TODO: Link to MegaTexture media!
  • Have a little understanding the ETQW material system

If you don't have either of the above things, you are not ready to do this tutorial!

This tutorial covers:

  • How to set up a MegaTexture material
  • How to create a Surface Tree
  • How to add texture nodes in the Terrain Editor
  • How to render and compile a full MegaTexture

This tutorial does not cover:

  • How to use Blender/Maya/Lightwave/ZBrush/Mudbox/3DSMax/Photoshop
  • How to create tiling textures or heightmaps
  • Anything overly complicated


Creating a MegaTexture Material

Firstly you need to create a new material for your terrain to use. If you have never made a new material before, read the article on Adding Custom Textures. All you need to do is create (or use an existing) .mtr file and place a material declaration in it, in the manner shown here:

material megatextures/mapname		{ useTemplate megatextures/default_ambient< "mapname" > }

This material would automatically search for a MegaTexture called mapname.mega in the /megatextures/ folder. This example material uses the "default_ambient" template, which expects a 3-channel RGB MegaTexture. These are generated by the default settings of the MegaTexture tab in the SDK Launcher.

Obviously you would want to use the actual name of your map instead of "mapname", for consistency's sake and ease of reference.

Remember that if you made a new .mtr file after the game or editor was started, you'll have to restart the whole game and editor before it will read your new file.

Assigning the Material

You should assign the material you just created by naming a material in your 3D application and applying it to your terrain mesh, then export the model to your preferred format (LWO, ASE or OBJ). Tips on this process can be found in the simple first terrain tutorial.


Creating the Surface Tree

As described in the Simple First Terrain tutorial, terrain models are set up in the Terrain Editor, accessible via shiftN in editWorld. This tool creates a Surface Tree file (.sft) that contains all the information about the terrain, including roads, stamps, and detail texture information that MegaGen needs to generate a MegaTexture.

Add the Terrain Mesh

Root node set up to use the correct terrain mesh

Here's how you bring the terrain mesh into the surface tree:

  • Press "Begin Editing" at the bottom of the Terrain Editor window.
  • RMB on the left-hand pane and create a new Tree via the menu.
  • Click on the Root node, and set Model to the name of the terrain mesh, in this case models/terrain/simpleterrain.obj.
  • Press enter to confirm the selection, and the terrain should appear in the 3D view.

Be aware that your terrain model will probably appear bright orange or red. Don't worry, this is because your Megatexture doesn't exist yet!


That's it!

File:Simple mega ingame.jpg
The MegaTexture in-game!

You've now created a map with your very own MegaTexture!


See Also