Difference between revisions of "A Simple First Megatexture"

From Mod Wiki
Line 19: 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 =
Line 71: Line 72:
 
* In the ''File Name'' field of the '''Image Properties''' section, browse to a generic tiling dirt texture. Remember to hit {{accelkey|enter}}!
 
* In the ''File Name'' field of the '''Image Properties''' section, browse to a generic tiling dirt texture. Remember to hit {{accelkey|enter}}!
 
** I'm using {{filename|textures/megagen/temperate/dirt02_d.tga}}
 
** I'm using {{filename|textures/megagen/temperate/dirt02_d.tga}}
 +
* The ''Scale'' field at the very bottom of the property list allows you to choose how much to tile the texture.
 +
** The default value is 1 1, but you don't want that since it will stretch your texture over the whole mesh, and look really blurry!
 +
** Instead set the Scale to something like 48 48, this means that the texture will be repeated 48 times across each axis of the terrain. This results in a sharper final output.
 +
That's all you need to do for the Diffuse settings in this node.
  
 
=== Distribution ===
 
=== Distribution ===
Line 88: Line 93:
 
* In the ''File Name'' field of the '''Image Properties''' section, browse to the matching normal map for your tiling dirt texture.
 
* In the ''File Name'' field of the '''Image Properties''' section, browse to the matching normal map for your tiling dirt texture.
 
** I'm using {{filename|textures/megagen/temperate/dirt02_local.tga}}
 
** I'm using {{filename|textures/megagen/temperate/dirt02_local.tga}}
 +
* The Local texture's tiling amount is automatically the same as the Diffuse texture.
 +
 +
 +
== Previewing the result ==
 +
[[Image:simplemega_firstnode_preview.jpg|thumb|300px|The Render mode preview of the first node]]
 +
Now we can easily check if this is all set up correctly. You should notice a little icon at the top left of your Terrain Editor which looks like this: [[Image:simplemega_previewbutton.png|MegaTexture Render Preview button]]
 +
 +
* Notice the drop-down arrow on the right of the button. Click it, and select ''"Full"'' instead of ''"None"''.
 +
* Your terrain should change colour to black. This means it's ready for a preview to be rendered onto it.
 +
* Click the button itself now, instead of the drop-down. An "Active Tasks" window should pop up, and when it's done, you should see your dirt texture appear on your terrain model.
 +
* You can switch the camera to Render mode too, which will show your terrain model's shading better.
 +
* If you want a full-resolution preview of a small area, choose ''"Window"'' instead of ''"Full"'' from the drop-down menu.
 +
** This creates a small window that you can move around using {{accelbtn|LMB}}-drag in the XY Top view. Simply position the window where you want to preview the full-resolution MegaTexture, and hit the Render Preview button.
 +
 +
Now any time you add new nodes, or change a node's properties, you can just click the Render Preview button and the view will update with your changes.
 +
{{clear}}
  
  
 
= That's it! =
 
= That's it! =
[[Image:simple_mega_ingame.jpg|thumb|300px|The MegaTexture in-game!]]
+
[[Image:simplemega_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}}

Revision as of 17:03, 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 any 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.

Root node set up to use the correct terrain mesh

Add the terrain mesh

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

  • RMB on the left-hand pane, and choose New -> Tree via the menu.
    • If you already have a Root node, click the "Begin Editing" button instead.
  • 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. The console will probably give you a few WARNING messages, don't worry about these for now, this is because your Megatexture doesn't exist yet!

Important note about nodes

When you are editing properties of nodes (names, numbers, texture sources etc.) always remember to hit enter after changing a value, to make sure that the value is stored. If you just type something in and then click somewhere else without pressing enter, your changes may not be applied.


Create the first texture node

The first texture node's diffuse texture properties

Now that the model is in place, you can start laying down the texture layers (or "nodes") that will make up your MegaTexture.

First you need to create a new Image Source node in the Terrain Editor.

  • RMB on your "Root" node and choose New -> Image Source (or press shifti)
  • This will make a new node called "New Image Renderer". You can rename this using the "Name" property field in the Object section.


You will notice in the top right of the Terrain Editor, a section listing things like "Diffuse", "Distribution", "Distribution Pattern" etc. Selecting one of these will list all of the properties for that section of the current node. The ones we need to worry about are as follows:

Diffuse

This is the colour map of the current node, and it should point to a tiling TGA texture.

  • Make sure the Diffuse section is highlighted in the top right of the Terrain Editor.
  • In the File Name field of the Image Properties section, browse to a generic tiling dirt texture. Remember to hit enter!
    • I'm using textures/megagen/temperate/dirt02_d.tga
  • The Scale field at the very bottom of the property list allows you to choose how much to tile the texture.
    • The default value is 1 1, but you don't want that since it will stretch your texture over the whole mesh, and look really blurry!
    • Instead set the Scale to something like 48 48, this means that the texture will be repeated 48 times across each axis of the terrain. This results in a sharper final output.

That's all you need to do for the Diffuse settings in this node.

Distribution

This is how we control where the layer is drawn (ie. no grass underwater, no sand on angles over 60 degrees etc). It's basically a big mask where white = fully shown and black = fully hidden.

  • Make sure the Distribution section is highlighted in the top right.
  • Since this is our first node, we want to show over the whole terrain. This means the distribution map should be 100% white.
  • You can either assign a pure white TGA texture, or change the Source Type to geometryBased.
    • geometryBased will by default create a fully white map, so if you don't have a white TGA handy, this is faster.

Distribution Pattern

This controls how the current node blends into others. Usually this will be set to a tiling TGA heightmap texture that matches the Diffuse texture.

  • We don't need a Distribution Pattern for the first node, since it doesn't blend with anything. Nodes on top of this one will need Distribution Patterns for more interesting and natural blends though!

Local

This is the normal-map of the current node. This should be a tiling TGA texture representing the local normal information of the matching Diffuse texture.

  • Make sure the Local section is highlighted in the top right.
  • In the File Name field of the Image Properties section, browse to the matching normal map for your tiling dirt texture.
    • I'm using textures/megagen/temperate/dirt02_local.tga
  • The Local texture's tiling amount is automatically the same as the Diffuse texture.


Previewing the result

The Render mode preview of the first node

Now we can easily check if this is all set up correctly. You should notice a little icon at the top left of your Terrain Editor which looks like this: MegaTexture Render Preview button

  • Notice the drop-down arrow on the right of the button. Click it, and select "Full" instead of "None".
  • Your terrain should change colour to black. This means it's ready for a preview to be rendered onto it.
  • Click the button itself now, instead of the drop-down. An "Active Tasks" window should pop up, and when it's done, you should see your dirt texture appear on your terrain model.
  • You can switch the camera to Render mode too, which will show your terrain model's shading better.
  • If you want a full-resolution preview of a small area, choose "Window" instead of "Full" from the drop-down menu.
    • This creates a small window that you can move around using LMB-drag in the XY Top view. Simply position the window where you want to preview the full-resolution MegaTexture, and hit the Render Preview button.

Now any time you add new nodes, or change a node's properties, you can just click the Render Preview button and the view will update with your changes.


That's it!

The MegaTexture in-game!

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

See Also