Difference between revisions of "A Simple First Megatexture"

From Mod Wiki
(See Also)
(Introduction)
 
(33 intermediate revisions by the same user not shown)
Line 2: Line 2:
 
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.
 
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 =
+
== Introduction ==
 
'''For this tutorial you must:'''
 
'''For this tutorial you must:'''
 
* 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)
Line 17: Line 17:
  
 
'''This tutorial does not cover:'''
 
'''This tutorial does not cover:'''
* How to use Blender/Maya/Lightwave/ZBrush/Mudbox/3DSMax/Photoshop
+
* How to use Photoshop/EarthSculptor/Terragen/WorldMachine
* How to create tiling textures or heightmaps
+
* How to create tiling textures or height-maps
* Anything overly complicated
 
  
 
+
== Creating a MegaTexture material ==
= 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:
 
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" > }
 
  material megatextures/mapname { useTemplate megatextures/default_ambient< "mapname" > }
Line 37: Line 35:
  
  
= Creating the Surface Tree =
+
== 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. The Surface Tree will be saved every time the map is saved, or any time you press the "Save and Unload" button in the Terrain Editor.
 
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. The Surface Tree will be saved every time the map is saved, or any time you press the "Save and Unload" button in the Terrain Editor.
 
[[Image:simplemega_terrainmodel.png|thumb|300px|Root node set up to use the correct terrain mesh]]
 
[[Image:simplemega_terrainmodel.png|thumb|300px|Root node set up to use the correct terrain mesh]]
Line 65: Line 63:
 
* You can rename this new node using the "Name" property field in the '''Object''' section.
 
* You can rename this new node using the "Name" property field in the '''Object''' section.
 
* Rename the node "Dirt".
 
* Rename the node "Dirt".
 
  
 
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.
 
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:
 
The ones we need to worry about are as follows:
  
<big>'''Diffuse'''</big>
+
=== Diffuse ===
----
 
 
This is the colour map of the current node, and it should point to a tiling TGA texture.
 
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.
 
* 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 {{accelkey|enter}} afterwards!
+
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to a generic tiling dirt texture. Remember to hit {{accelkey|enter}} afterwards!
** This example is using {{filename|textures/megagen/temperate/dirt_02_d.tga}}
+
** This example is using {{keyvalue|textures/megagen/temperate/dirt_02_d.tga}}
* The ''Scale'' field at the very bottom of the property list allows you to choose how much to tile the texture.
+
* The {{keyname|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!
+
** The default value is {{keyvalue|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.
+
** Instead set the Scale to something like {{keyvalue|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.
 
That's all you need to do for the Diffuse settings in this node.
  
 
+
=== Distribution ===
<big>'''Distribution'''</big>
 
----
 
 
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''.
 
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.
 
* 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.
 
* 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''.
+
* You can either assign a pure white TGA texture, or change the {{keyname|Source Type}} to {{keyvalue|geometryBased}}.
** ''geometryBased'' will by default create a fully white map, so if you don't have a white TGA handy, this is faster.
+
** {{keyvalue|geometryBased}} will by default create a fully white map, so if you don't have a white TGA handy, this is faster.
  
 
+
=== Distribution Pattern ===
<big>'''Distribution Pattern'''</big>
 
----
 
 
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.
 
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!
 
* 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 ===
<big>'''Local'''</big>
 
----
 
 
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.
 
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.
 
* 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.
+
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching normal map for your tiling dirt texture.
** This example is using {{filename|textures/megagen/temperate/dirt_02_local.tga}}
+
** This example is using {{keyvalue|textures/megagen/temperate/dirt_02_local.tga}}
 
* The Local texture's tiling amount is automatically the same as the Diffuse texture.
 
* The Local texture's tiling amount is automatically the same as the Diffuse texture.
  
 
+
=== Surface Type ===
<big>'''Surface Type'''</big>
 
----
 
 
Your image nodes should all specify a surface type, so that when players walk over or shoot the surface, it gives the correct sound and particle effects.
 
Your image nodes should all specify a surface type, so that when players walk over or shoot the surface, it gives the correct sound and particle effects.
 
* Find the ''Surface Type Properties'' section of the property list.
 
* Find the ''Surface Type Properties'' section of the property list.
* In the '''Type''' field, enter ''dirt''. It should drop down a list of valid surface types as soon as you hit the first letter.
+
* In the {{keyname|Type}} field, enter {{keyvalue|dirt}}. It should drop down a list of valid surface types as soon as you hit the first letter.
 
* Hit {{accelkey|enter}} to accept the surface type.
 
* Hit {{accelkey|enter}} to accept the surface type.
  
 
Your dirt textures will now produce correct "dirt" effects when shot or collided with!
 
Your dirt textures will now produce correct "dirt" effects when shot or collided with!
  
 
+
=== Previewing the result ===
<big>'''Previewing the result'''</big>
 
----
 
 
[[Image:simplemega_firstnode_preview.jpg|thumb|300px|The Render mode preview of the first node]]
 
[[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]]
 
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]]
Line 132: Line 118:
 
'''Important note:''' Running a 3D application such as Blender, Maya, 3dsmax etc. in the background, may prevent a MegaTexture preview being rendered correctly. If your node is set up correctly but the preview render is appearing as black or patchy, make sure you have closed any 3D applications and try re-rendering the preview.
 
'''Important note:''' Running a 3D application such as Blender, Maya, 3dsmax etc. in the background, may prevent a MegaTexture preview being rendered correctly. If your node is set up correctly but the preview render is appearing as black or patchy, make sure you have closed any 3D applications and try re-rendering the preview.
 
{{clear}}
 
{{clear}}
 
  
 
== Adding a second node ==
 
== Adding a second node ==
Line 139: Line 124:
 
* This will make another new node below your "Dirt" node.  
 
* This will make another new node below your "Dirt" node.  
 
* Name this new node "Grass".
 
* Name this new node "Grass".
 
  
 
The Surface Tree hierarchy is rendered from the top down, so nodes ''above'' other nodes in the hierarchy will be rendered ''before'' the other nodes. So currently it'll be rendering our Dirt node, and then rendering the Grass node on top of the dirt.
 
The Surface Tree hierarchy is rendered from the top down, so nodes ''above'' other nodes in the hierarchy will be rendered ''before'' the other nodes. So currently it'll be rendering our Dirt node, and then rendering the Grass node on top of the dirt.
Line 145: Line 129:
 
Again, the main map types need to be specified before the node can be rendered:
 
Again, the main map types need to be specified before the node can be rendered:
  
<big>'''Diffuse'''</big>
+
=== Diffuse ===
----
 
 
* Make sure the Diffuse section is highlighted in the top right of the Terrain Editor.
 
* 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 grass texture.
+
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to a generic tiling grass texture.
** This example is using {{filename|textures/megagen/temperate/grass_04_d.tga}}
+
** This example is using {{keyvalue|textures/megagen/temperate/grass_04_d.tga}}
* Again you will want to set the ''Scale'' value to something other than 1 1, to tile your texture. Let's use 32 32 for this one.
+
* Again you will want to set the {{keyname|Scale}} value to something other than {{keyvalue|1 1}}, to tile your texture. Let's use {{keyvalue|32 32}} for this one.
 
 
  
<big>'''Distribution'''</big>
+
=== Distribution ===
----
 
 
This is important now, since we need to control where this layer is visible. Pure white won't work, since that'll just completely cover our underlying Dirt node!
 
This is important now, since we need to control where this layer is visible. Pure white won't work, since that'll just completely cover our underlying Dirt node!
 
* Make sure the Distribution section is highlighted in the top right.
 
* Make sure the Distribution section is highlighted in the top right.
* Change the "Source Type" from ''texture'' to ''geometryBased''.
+
* Change the {{keyname|Source Type}} from {{keyvalue|texture}} to {{keyvalue|geometryBased}}.
  
 
+
=== Geometric Texture Distribution ===
'''Geometric Texture Distribution'''
 
----
 
 
[[Image:simplemega_geometric_distribution.png|thumb|300px|The geometric texture distribution settings of the second node]]
 
[[Image:simplemega_geometric_distribution.png|thumb|300px|The geometric texture distribution settings of the second node]]
 
This is where it gets interesting! There are many settings to alter, and they can have a drastic effect on how different your terrain looks, so try playing around with different values if you're not happy with the initial results.
 
This is where it gets interesting! There are many settings to alter, and they can have a drastic effect on how different your terrain looks, so try playing around with different values if you're not happy with the initial results.
  
* '''Altitude Lower''' - Enabling this will limit the lower parts of the terrain from receiving this node's textures.
+
* ''Altitude Lower'' - Enabling this will limit the lower parts of the terrain from receiving this node's textures.
** '''Altitude Lower Value''' - The Z height in world units that the node will be drawn above. The default of 0 means that any parts of your terrain mesh below Z=0 will not show any of this node's textures.
+
** {{keyname|Altitude Lower Value}} - The Z height in world units that the node will be drawn above. The default of 0 means that any parts of your terrain mesh below Z=0 will not show any of this node's textures.
** '''Fuzziness''' - The amount of blur applied to the mask, ranges between 0.0 and 1.0. The higher the value, the more blurry the boundary.
+
** {{keyname|Fuzziness}} - The amount of blur applied to the mask, ranges between 0.0 and 1.0. The higher the value, the more blurry the boundary.
* '''Altitude Upper''' - Enabling this will limit the higher parts of the terrain from receiving this node's textures.
+
* ''Altitude Upper'' - Enabling this will limit the higher parts of the terrain from receiving this node's textures.
** '''Altitude Upper Value''' - The Z height in world units that the node will be drawn below. The default of 0 means that any parts of your terrain mesh above Z=0 will not show any of this node's textures.
+
** {{keyname|Altitude Upper Value}} - The Z height in world units that the node will be drawn below. The default of 0 means that any parts of your terrain mesh above Z=0 will not show any of this node's textures.
** '''Fuzziness''' - The amount of blur applied to the mask, ranges between 0.0 and 1.0. The higher the value, the more blurry the boundary.
+
** {{keyname|Fuzziness}} - The amount of blur applied to the mask, ranges between 0.0 and 1.0. The higher the value, the more blurry the boundary.
  
* '''Clamp Distribution To Edge''' - Leave this on Default.
+
* {{keyname|Clamp Distribution To Edge}} - Leave this on Default.
  
* '''Resolution''' - The size in pixels of the resulting mask. The default value of 256 is fine for nearly any terrain model.
+
* {{keyname|Resolution}} - The size in pixels of the resulting mask. The default value of {{keyvalue|256}} is fine for nearly any terrain model.
  
* '''Slope Lower''' - Enabling this will limit shallower angles of the terrain model from receiving this node's textures.
+
* ''Slope Lower'' - Enabling this will limit shallower angles of the terrain model from receiving this node's textures.
** '''Slope Lower Value''' - The angle in degrees that the node will be drawn past. The default angle of 0 will result in no change to your mask.
+
** {{keyname|Slope Lower Value}} - The angle in degrees that the node will be drawn past. The default angle of 0 will result in no change to your mask.
** '''Fuzziness''' - The amount of blur applied to the mask, ranges between 0.0 and 1.0. The higher the value, the more blurry the boundary.
+
** {{keyname|Fuzziness}} - The amount of blur applied to the mask, ranges between 0.0 and 1.0. The higher the value, the more blurry the boundary.
* '''Slope Upper''' - Enabling this will limit the steeper angles of the terrain model from receiving this node's textures. This is great for masking out cliffs from your nodes.
+
* ''Slope Upper'' - Enabling this will limit the steeper angles of the terrain model from receiving this node's textures. This is great for masking out cliffs from your nodes.
** '''Slope Upper Value''' - The angle in degrees that the node will be hidden past. The default angle of 0 will result in a fully black mask.
+
** {{keyname|Slope Upper Value}} - The angle in degrees that the node will be hidden past. The default angle of {{keyvalue|0}} will result in a fully black mask.
** '''Fuzziness''' - The amount of blur applied to the mask, ranges between 0.0 and 1.0. The higher the value, the more blurry the boundary.
+
** {{keyname|Fuzziness}} - The amount of blur applied to the mask, ranges between 0.0 and 1.0. The higher the value, the more blurry the boundary.
  
 
The settings you use for each of these will vary depending on your terrain model, and the type of node you're making. For our Grass node, you can see the settings used for this example in the screenshot above on the right.
 
The settings you use for each of these will vary depending on your terrain model, and the type of node you're making. For our Grass node, you can see the settings used for this example in the screenshot above on the right.
 
{{clear}}
 
{{clear}}
  
 
+
=== Distribution Pattern ===
<big>'''Distribution Pattern'''</big>
 
----
 
 
[[Image:simplemega_dist_ramps.jpg|thumb|300px|The difference between using or not using a Distribution Pattern, and varying Ramp Widths]]
 
[[Image:simplemega_dist_ramps.jpg|thumb|300px|The difference between using or not using a Distribution Pattern, and varying Ramp Widths]]
 
This controls how the the grass will blend into the dirt. If you don't have a Distribution Pattern texture, the grass will just slowly fade into the dirt, which doesn't look very natural!
 
This controls how the the grass will blend into the dirt. If you don't have a Distribution Pattern texture, the grass will just slowly fade into the dirt, which doesn't look very natural!
 
So what we want here is a texture to identify the "height" of the areas of grass. This means that the dirt can blend in based on the height of each clump of grass, so instead of a smooth fade you will get a more natural blend between the grass and the dirt.
 
So what we want here is a texture to identify the "height" of the areas of grass. This means that the dirt can blend in based on the height of each clump of grass, so instead of a smooth fade you will get a more natural blend between the grass and the dirt.
  
If you examine the screenshot to the right, you can see what effect a good Distribution Pattern can have - when the node is rendered with no Distribution Pattern, the blend between the nodes is a simple smooth gradient, which does not look very natural at all. You can also see the difference that the '''Ramp Width''' value makes - this is a very powerful value, so experiment with it until you really understand the effect it has!
+
If you examine the screenshot to the right, you can see what effect a good Distribution Pattern can have - when the node is rendered with no Distribution Pattern, the blend between the nodes is a simple smooth gradient, which does not look very natural at all. You can also see the difference that the {{keyname|Ramp Width}} value makes - this is a very powerful value, so experiment with it until you really understand the effect it has!
  
* Make sure the Distribution Pattern section is highlighted in the top right.
+
* Make sure {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching heightmap or mask for your tiling grass texture.
* In the ''File Name'' field of the '''Image Properties''' section, browse to the matching heightmap or mask for your tiling grass texture.
+
** This example is using {{keyvalue|textures/megagen/temperate/grass_04_mask.tga}}
** This example is using {{filename|textures/megagen/temperate/grass_04_mask.tga}}
+
* The {{keyname|Ramp Width}} should be set to a value lower than the default of {{keyvalue|1}}, since this causes a very blurry blend, which is usually not what you want. Try a value of {{keyvalue|0.25}} and re-render the preview - try a "Window" preview as described earlier to get a full-resolution preview where you can really see {{keyname|Distribution Pattern Texture Scale}} to the same value as the Diffuse Scale, in this case we just use {{keyvalue|32 32}} again.
* The ''Ramp Width'' should be set to a value lower than the default of 1, since this causes a very blurry blend, which is usually not what you want. Try a value of 0.25 and re-render the preview - try a "Window" preview as described earlier to get a full-resolution preview where you can really see the blend working.
 
* '''Important!''' You will also need to set the ''Distribution Pattern Texture Scale'' to the same value as the Diffuse Scale, in this case we just use 32 32 again.
 
 
{{clear}}
 
{{clear}}
  
 
+
=== Local ===
<big>'''Local'''</big>
 
----
 
 
Again we want the normal-map which matches the diffuse texture for the grass.
 
Again we want the normal-map which matches the diffuse texture for the grass.
 
* Make sure the Local section is highlighted in the top right.
 
* 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 grass texture.
+
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching normal map for your tiling grass texture.
** This example is using {{filename|textures/megagen/temperate/grass_04_local.tga}}
+
** This example is using {{keyvalue|textures/megagen/temperate/grass_04_local.tga}}
 
 
  
<big>'''Surface Type'''</big>
+
=== Surface Type ===
----
 
 
Again, you need to specify a surface type, so that when players walk over or shoot the surface, it gives the correct sound and particle effects.
 
Again, you need to specify a surface type, so that when players walk over or shoot the surface, it gives the correct sound and particle effects.
 
* Find the ''Surface Type Properties'' section of the property list.
 
* Find the ''Surface Type Properties'' section of the property list.
* In the '''Type''' field, enter ''grass''. It should drop down a list of valid surface types as soon as you hit the first letter.
+
* In the {{keyname|Type}} field, enter {{keyvalue|grass}}. It should drop down a list of valid surface types as soon as you hit the first letter.
 
* Hit {{accelkey|enter}} to accept the surface type.
 
* Hit {{accelkey|enter}} to accept the surface type.
  
 
Your grass textures should now produce correct "grass" effects when shot or collided with!
 
Your grass textures should now produce correct "grass" effects when shot or collided with!
  
 
+
=== Preview ===
<big>'''Preview again!'''</big>
 
----
 
 
[[Image:simplemega_secondnode_preview.jpg|thumb|300px|The Render mode preview of the second node blended with the first node]]
 
[[Image:simplemega_secondnode_preview.jpg|thumb|300px|The Render mode preview of the second node blended with the first node]]
 
Now that's all set up, you can hit the Render Preview ([[Image:simplemega_previewbutton.png|MegaTexture Render Preview button]]) button again and see what effect the new Grass node has.
 
Now that's all set up, you can hit the Render Preview ([[Image:simplemega_previewbutton.png|MegaTexture Render Preview button]]) button again and see what effect the new Grass node has.
 
If it's being distributed into the wrong places, you can go back into your Distribution settings and tweak the values for the ''geometryBased'' settings. Then you can preview again until it looks right.
 
If it's being distributed into the wrong places, you can go back into your Distribution settings and tweak the values for the ''geometryBased'' settings. Then you can preview again until it looks right.
 
{{clear}}
 
{{clear}}
 
  
 
== Adding a third node ==
 
== Adding a third node ==
Line 233: Line 201:
 
Now that the grass and dirt are in place, we need some rocks to make the terrain look more natural.
 
Now that the grass and dirt are in place, we need some rocks to make the terrain look more natural.
 
* Add a new Image Renderer node below your "Grass" node and name it "Rock".
 
* Add a new Image Renderer node below your "Grass" node and name it "Rock".
 
  
 
Again, the main map types need to be specified before the node can be rendered:
 
Again, the main map types need to be specified before the node can be rendered:
  
<big>'''Diffuse'''</big>
+
=== Diffuse ===
----
+
* Set the '''Diffuse''' texture and scale.
* In the ''File Name'' field of the '''Diffuse''' section, browse to a generic tiling rock texture.
+
** This example is using {{keyvalue|textures/megagen/temperate/rock_01_d.tga}} at a scale of {{keyvalue|32 32}}
** This example is using {{filename|textures/megagen/temperate/rock_01_d.tga}}
 
* Set the ''Scale'' value to 32 32.
 
  
 
+
=== Distribution ===
<big>'''Distribution'''</big>
 
----
 
 
Again we can use Geometric Texture Distribution to easily apply the rock textures only to the cliff-like angles.
 
Again we can use Geometric Texture Distribution to easily apply the rock textures only to the cliff-like angles.
 
* Make sure the Distribution section is highlighted in the top right.
 
* Make sure the Distribution section is highlighted in the top right.
* Change the "Source Type" from ''texture'' to ''geometryBased''.
+
* Change the {{keyname|Source Type}} to {{keyvalue|geometryBased}}.
* To make the rock texture only appear on near vertical surfaces, set the ''Slope Lower Value'' to 23, and the ''Fuzziness'' of Slope Lower to 0.05
+
* To make the rock texture only appear on near vertical surfaces, set the {{keyname|Slope Lower Value}} to {{keyvalue|23}}, and the {{keyname|Fuzziness}} of Slope Lower to {{keyvalue|0.05}}
  
 
+
=== Distribution Pattern ===
<big>'''Distribution Pattern'''</big>
 
----
 
 
Again this will control how the the rocks blend into the other nodes. Again, we want a texture to identify the "height" of the tiling rock texture.
 
Again this will control how the the rocks blend into the other nodes. Again, we want a texture to identify the "height" of the tiling rock texture.
  
 
* Make sure the Distribution Pattern section is highlighted in the top right.
 
* Make sure the Distribution Pattern section is highlighted in the top right.
* In the ''File Name'' field of the '''Image Properties''' section, browse to the matching heightmap or mask for your tiling rock texture.
+
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching heightmap or mask for your tiling rock texture.
** This example is using {{filename|textures/megagen/temperate/rock_01_h.tga}}
+
** This example is using {{keyvalue|textures/megagen/temperate/rock_01_h.tga}}
* The ''Ramp Width'' should be set to a value much lower than the default of 1, since this causes a very blurry blend, which is not natural for rocks blending with dirt. Try a value of 0.1 here, then render a "Window" preview to see how the blending looks.
+
* The {{keyname|Ramp Width}} should be set to a value much lower than the default of {{keyvalue|1}}, since this causes a very blurry blend, which is not natural for rocks blending with dirt. Try a value of {{keyvalue|0.1}} here, then render a "Window" preview to see how the blending looks.
* Remember to set the ''Distribution Pattern Texture Scale'' to the same value as the Diffuse Scale, 32 32.
+
* Remember to set the {{keyname|Distribution Pattern Texture Scale}} to the same value as the Diffuse Scale, {{keyvalue|32 32}}.
 
 
  
<big>'''Local'''</big>
+
=== Local ===
----
 
 
Again we want the normal-map which matches the diffuse texture for the rocks.
 
Again we want the normal-map which matches the diffuse texture for the rocks.
* In the ''File Name'' field of the '''Local''' section, browse to the matching normal map for your tiling rock texture.
+
* In the {{keyname|File Name}} field of the '''Local''' section, browse to the matching normal map for your tiling rock texture.
** This example is using {{filename|textures/megagen/temperate/rock_01_local.tga}}
+
** This example is using {{keyvalue|textures/megagen/temperate/rock_01_local.tga}}
 
 
  
<big>'''Surface Type'''</big>
+
=== Surface Type ===
----
 
 
* Find the ''Surface Type Properties'' section of the property list.
 
* Find the ''Surface Type Properties'' section of the property list.
* In the '''Type''' field, enter ''stone''.
+
* In the {{keyname|Type}} field, enter {{keyvalue|stone}}.
 
* Hit {{accelkey|enter}} to accept the surface type.
 
* Hit {{accelkey|enter}} to accept the surface type.
  
 
Your rock textures should now produce correct "stone" effects when shot or collided with.
 
Your rock textures should now produce correct "stone" effects when shot or collided with.
  
 
+
=== Preview ===
<big>'''Preview again!'''</big>
 
----
 
 
Now that the rocks are set up, you can hit the Render Preview ([[Image:simplemega_previewbutton.png|MegaTexture Render Preview button]]) button again and see what effect the new Rock node has.
 
Now that the rocks are set up, you can hit the Render Preview ([[Image:simplemega_previewbutton.png|MegaTexture Render Preview button]]) button again and see what effect the new Rock node has.
  
Line 286: Line 241:
 
There are other simple changes that can be done in the Terrain Editor to make your MegaTexture look even better.
 
There are other simple changes that can be done in the Terrain Editor to make your MegaTexture look even better.
  
<big>'''Node order'''</big>
+
=== Node order ===
----
 
 
[[Image:simplemega_node_order.png|frame|Click and drag a node to change the order]]
 
[[Image:simplemega_node_order.png|frame|Click and drag a node to change the order]]
 
You may notice, if you look carefully at the blends between the rock and grass nodes, that some areas of the MegaTexture appear to show the rock texture ''on top'' of the grass! This doesn't look very natural, and it's happening because of the node order.
 
You may notice, if you look carefully at the blends between the rock and grass nodes, that some areas of the MegaTexture appear to show the rock texture ''on top'' of the grass! This doesn't look very natural, and it's happening because of the node order.
Line 297: Line 251:
 
* With the Rock node now positioned between the Dirt and Grass nodes, the grass will appear on top of the rocks as well as the dirt, which looks much more natural!
 
* With the Rock node now positioned between the Dirt and Grass nodes, the grass will appear on top of the rocks as well as the dirt, which looks much more natural!
  
 
+
=== Color changes ===
<big>'''Color changes'''</big>
 
----
 
 
Maybe your dirt texture is too bright? Or maybe your grass looks a little ''too'' green?
 
Maybe your dirt texture is too bright? Or maybe your grass looks a little ''too'' green?
 
You can easily fix this from the Terrain Editor itself! No need to create a new image every time you want to tweak the color or brightness, you can set this up on a per-node basis.
 
You can easily fix this from the Terrain Editor itself! No need to create a new image every time you want to tweak the color or brightness, you can set this up on a per-node basis.
Line 305: Line 257:
 
Let's say you want to make the dirt texture darker and a bit more red. Here's how you'd do it:
 
Let's say you want to make the dirt texture darker and a bit more red. Here's how you'd do it:
 
* Select your Dirt node.
 
* Select your Dirt node.
* Look under the ''Color Properties'' area in the property list, and {{accelbtn|LMB}} on the '''Color''' swatch (next to where it says 1 1 1, which is white).
+
* Look under the {{keyname|Color Properties}} area in the property list, and {{accelbtn|LMB}} on the {{keyname|Color}} swatch (next to where it says {{keyvalue|1 1 1}}, which is white).
 
* A color wheel and brightness slider will pop up in a new window. You can use this to darken and tint your texture.
 
* A color wheel and brightness slider will pop up in a new window. You can use this to darken and tint your texture.
 
* Choose a darker brightness, and a color slightly towards red. I used '''RGB Values''' of 225, 220, 220.
 
* Choose a darker brightness, and a color slightly towards red. I used '''RGB Values''' of 225, 220, 220.
Line 311: Line 263:
 
* Re-render your MegaTexture preview. You should notice that the dirt layer looks darker now!
 
* Re-render your MegaTexture preview. You should notice that the dirt layer looks darker now!
  
 
+
=== Texture rotation ===
<big>'''Texture rotation'''</big>
 
----
 
 
If you're building up a lot of layers of tiling textures, it can sometimes become obvious when a texture tiles in a particular direction. You may see repeating patterns extending into the distance when looking in particular directions, especially if all your nodes have the same orientation.
 
If you're building up a lot of layers of tiling textures, it can sometimes become obvious when a texture tiles in a particular direction. You may see repeating patterns extending into the distance when looking in particular directions, especially if all your nodes have the same orientation.
  
An easy way to overcome this is to play with the ''Rotation'' value in the Texture Properties section of the Terrain Editor's property list.
+
An easy way to overcome this is to play with the {{keyname|Rotation}} value in the ''Texture Properties'' section of the Terrain Editor's property list.
For each node, you should also set the ''Distribution Pattern Texture Rotation'' to match the Rotation value if you want your distribution patterns to line up and work correctly.
+
For each node, you should also set the {{keyname|Distribution Pattern Texture Rotation}} to match the {{keyname|Rotation}} value if you want your distribution patterns to line up and work correctly.
  
 
+
== Render the MegaTexture ==
= Render the MegaTexture =
 
 
=== Save the Surface Tree ===
 
=== Save the Surface Tree ===
 
Once you're happy with how the preview looks in the editor, you should make sure that your final Surface Tree is saved. Either click the "Save and Unload" button in the Terrain Editor, or save the whole map.
 
Once you're happy with how the preview looks in the editor, you should make sure that your final Surface Tree is saved. Either click the "Save and Unload" button in the Terrain Editor, or save the whole map.
Line 336: Line 285:
 
Now that your ''.sft'' is saved, go through all the steps outlined in the [[Generate a MegaTexture]] tutorial.
 
Now that your ''.sft'' is saved, go through all the steps outlined in the [[Generate a MegaTexture]] tutorial.
  
 
+
== That's it! ==
= That's it! =
 
 
[[Image:simplemega_ingame.jpg|thumb|300px|The MegaTexture in-game!]]
 
[[Image:simplemega_ingame.jpg|thumb|300px|The MegaTexture in-game!]]
 
You've now created your very own MegaTexture to use in your map!
 
You've now created your very own MegaTexture to use in your map!
Line 344: Line 292:
 
{{clear}}
 
{{clear}}
  
= Troubleshooting =
+
== Troubleshooting ==
 
If your terrain model still shows as red even after you've compiled the MegaTexture, there are a couple of things you should check first:
 
If your terrain model still shows as red even after you've compiled the MegaTexture, there are a couple of things you should check first:
 
* See if the console gives you any warnings about missing ''.stm'' files. If this is the case, you probably forgot to assign any Surface Types to your texture nodes. Double-check them and make sure it's all set up correctly.
 
* See if the console gives you any warnings about missing ''.stm'' files. If this is the case, you probably forgot to assign any Surface Types to your texture nodes. Double-check them and make sure it's all set up correctly.
Line 350: Line 298:
 
* Make sure there aren't any spelling mistakes in your ''.rlt'' file (as described in [[RenderLight|this article]]). If any of the names are inconsistent, the Megatexture will not have been compiled fully.
 
* Make sure there aren't any spelling mistakes in your ''.rlt'' file (as described in [[RenderLight|this article]]). If any of the names are inconsistent, the Megatexture will not have been compiled fully.
  
If your map compile is taking ages (ie. over 2-3 minutes for a 32,000 triangle terrain model) then it's probably because the MegaTexture material is broken. Double-check the issues listed above, and make sure you have run the {{consolecmd|reloaddecls}} console command if you changed any ''.mtr'' or ''.rlt'' files.
+
If your map compile is taking ages (ie. over 2-3 minutes for a 32,000 triangle terrain model) then it's probably because the MegaTexture material is broken. Double-check the issues listed above, and make sure you have run the {{consolecmd|reloadDecls}} console command if you changed any ''.mtr'' or ''.rlt'' files.
  
 
If your ''.mega'' and ''.stm'' files definitely exist, in the right folders, try closing and re-opening the ''.world'' file in editWorld. This should load and display the MegaTexture properly.
 
If your ''.mega'' and ''.stm'' files definitely exist, in the right folders, try closing and re-opening the ''.world'' file in editWorld. This should load and display the MegaTexture properly.
  
 
+
== See Also ==
= See Also =
 
 
* [[An Advanced Terrain and Megatexture]] - 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.

Latest revision as of 16:00, 17 December 2007

A simple MegaTexture, easily created with only 3 texture layers!

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.
  • 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 Photoshop/EarthSculptor/Terragen/WorldMachine
  • How to create tiling textures or height-maps

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. The Surface Tree will be saved every time the map is saved, or any time you press the "Save and Unload" button in the Terrain Editor.

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 new node using the "Name" property field in the Object section.
  • Rename the node "Dirt".

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 afterwards!
    • This example is using textures/megagen/temperate/dirt_02_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.
    • This example is using textures/megagen/temperate/dirt_02_local.tga
  • The Local texture's tiling amount is automatically the same as the Diffuse texture.

Surface Type

Your image nodes should all specify a surface type, so that when players walk over or shoot the surface, it gives the correct sound and particle effects.

  • Find the Surface Type Properties section of the property list.
  • In the Type field, enter dirt. It should drop down a list of valid surface types as soon as you hit the first letter.
  • Hit enter to accept the surface type.

Your dirt textures will now produce correct "dirt" effects when shot or collided with!

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.

Important note: Running a 3D application such as Blender, Maya, 3dsmax etc. in the background, may prevent a MegaTexture preview being rendered correctly. If your node is set up correctly but the preview render is appearing as black or patchy, make sure you have closed any 3D applications and try re-rendering the preview.

Adding a second node

Now that the first layer of dirt is in place, we can try putting some grass on top of it!

  • Again, RMB on your "Root" node and choose New -> Image Source (or press shifti)
  • This will make another new node below your "Dirt" node.
  • Name this new node "Grass".

The Surface Tree hierarchy is rendered from the top down, so nodes above other nodes in the hierarchy will be rendered before the other nodes. So currently it'll be rendering our Dirt node, and then rendering the Grass node on top of the dirt.

Again, the main map types need to be specified before the node can be rendered:

Diffuse

  • 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 grass texture.
    • This example is using textures/megagen/temperate/grass_04_d.tga
  • Again you will want to set the Scale value to something other than 1 1, to tile your texture. Let's use 32 32 for this one.

Distribution

This is important now, since we need to control where this layer is visible. Pure white won't work, since that'll just completely cover our underlying Dirt node!

  • Make sure the Distribution section is highlighted in the top right.
  • Change the Source Type from texture to geometryBased.

Geometric Texture Distribution

The geometric texture distribution settings of the second node

This is where it gets interesting! There are many settings to alter, and they can have a drastic effect on how different your terrain looks, so try playing around with different values if you're not happy with the initial results.

  • Altitude Lower - Enabling this will limit the lower parts of the terrain from receiving this node's textures.
    • Altitude Lower Value - The Z height in world units that the node will be drawn above. The default of 0 means that any parts of your terrain mesh below Z=0 will not show any of this node's textures.
    • Fuzziness - The amount of blur applied to the mask, ranges between 0.0 and 1.0. The higher the value, the more blurry the boundary.
  • Altitude Upper - Enabling this will limit the higher parts of the terrain from receiving this node's textures.
    • Altitude Upper Value - The Z height in world units that the node will be drawn below. The default of 0 means that any parts of your terrain mesh above Z=0 will not show any of this node's textures.
    • Fuzziness - The amount of blur applied to the mask, ranges between 0.0 and 1.0. The higher the value, the more blurry the boundary.
  • Clamp Distribution To Edge - Leave this on Default.
  • Resolution - The size in pixels of the resulting mask. The default value of 256 is fine for nearly any terrain model.
  • Slope Lower - Enabling this will limit shallower angles of the terrain model from receiving this node's textures.
    • Slope Lower Value - The angle in degrees that the node will be drawn past. The default angle of 0 will result in no change to your mask.
    • Fuzziness - The amount of blur applied to the mask, ranges between 0.0 and 1.0. The higher the value, the more blurry the boundary.
  • Slope Upper - Enabling this will limit the steeper angles of the terrain model from receiving this node's textures. This is great for masking out cliffs from your nodes.
    • Slope Upper Value - The angle in degrees that the node will be hidden past. The default angle of 0 will result in a fully black mask.
    • Fuzziness - The amount of blur applied to the mask, ranges between 0.0 and 1.0. The higher the value, the more blurry the boundary.

The settings you use for each of these will vary depending on your terrain model, and the type of node you're making. For our Grass node, you can see the settings used for this example in the screenshot above on the right.

Distribution Pattern

The difference between using or not using a Distribution Pattern, and varying Ramp Widths

This controls how the the grass will blend into the dirt. If you don't have a Distribution Pattern texture, the grass will just slowly fade into the dirt, which doesn't look very natural! So what we want here is a texture to identify the "height" of the areas of grass. This means that the dirt can blend in based on the height of each clump of grass, so instead of a smooth fade you will get a more natural blend between the grass and the dirt.

If you examine the screenshot to the right, you can see what effect a good Distribution Pattern can have - when the node is rendered with no Distribution Pattern, the blend between the nodes is a simple smooth gradient, which does not look very natural at all. You can also see the difference that the Ramp Width value makes - this is a very powerful value, so experiment with it until you really understand the effect it has!

  • Make sure File Name field of the Image Properties section, browse to the matching heightmap or mask for your tiling grass texture.
    • This example is using textures/megagen/temperate/grass_04_mask.tga
  • The Ramp Width should be set to a value lower than the default of 1, since this causes a very blurry blend, which is usually not what you want. Try a value of 0.25 and re-render the preview - try a "Window" preview as described earlier to get a full-resolution preview where you can really see Distribution Pattern Texture Scale to the same value as the Diffuse Scale, in this case we just use 32 32 again.

Local

Again we want the normal-map which matches the diffuse texture for the grass.

  • 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 grass texture.
    • This example is using textures/megagen/temperate/grass_04_local.tga

Surface Type

Again, you need to specify a surface type, so that when players walk over or shoot the surface, it gives the correct sound and particle effects.

  • Find the Surface Type Properties section of the property list.
  • In the Type field, enter grass. It should drop down a list of valid surface types as soon as you hit the first letter.
  • Hit enter to accept the surface type.

Your grass textures should now produce correct "grass" effects when shot or collided with!

Preview

The Render mode preview of the second node blended with the first node

Now that's all set up, you can hit the Render Preview (MegaTexture Render Preview button) button again and see what effect the new Grass node has. If it's being distributed into the wrong places, you can go back into your Distribution settings and tweak the values for the geometryBased settings. Then you can preview again until it looks right.

Adding a third node

The Render mode preview of the third node blended with the other two nodes

Now that the grass and dirt are in place, we need some rocks to make the terrain look more natural.

  • Add a new Image Renderer node below your "Grass" node and name it "Rock".

Again, the main map types need to be specified before the node can be rendered:

Diffuse

  • Set the Diffuse texture and scale.
    • This example is using textures/megagen/temperate/rock_01_d.tga at a scale of 32 32

Distribution

Again we can use Geometric Texture Distribution to easily apply the rock textures only to the cliff-like angles.

  • Make sure the Distribution section is highlighted in the top right.
  • Change the Source Type to geometryBased.
  • To make the rock texture only appear on near vertical surfaces, set the Slope Lower Value to 23, and the Fuzziness of Slope Lower to 0.05

Distribution Pattern

Again this will control how the the rocks blend into the other nodes. Again, we want a texture to identify the "height" of the tiling rock texture.

  • Make sure the Distribution Pattern section is highlighted in the top right.
  • In the File Name field of the Image Properties section, browse to the matching heightmap or mask for your tiling rock texture.
    • This example is using textures/megagen/temperate/rock_01_h.tga
  • The Ramp Width should be set to a value much lower than the default of 1, since this causes a very blurry blend, which is not natural for rocks blending with dirt. Try a value of 0.1 here, then render a "Window" preview to see how the blending looks.
  • Remember to set the Distribution Pattern Texture Scale to the same value as the Diffuse Scale, 32 32.

Local

Again we want the normal-map which matches the diffuse texture for the rocks.

  • In the File Name field of the Local section, browse to the matching normal map for your tiling rock texture.
    • This example is using textures/megagen/temperate/rock_01_local.tga

Surface Type

  • Find the Surface Type Properties section of the property list.
  • In the Type field, enter stone.
  • Hit enter to accept the surface type.

Your rock textures should now produce correct "stone" effects when shot or collided with.

Preview

Now that the rocks are set up, you can hit the Render Preview (MegaTexture Render Preview button) button again and see what effect the new Rock node has.

Further tweaks

There are other simple changes that can be done in the Terrain Editor to make your MegaTexture look even better.

Node order

Click and drag a node to change the order

You may notice, if you look carefully at the blends between the rock and grass nodes, that some areas of the MegaTexture appear to show the rock texture on top of the grass! This doesn't look very natural, and it's happening because of the node order.

Since the Rock node is below the Grass node, it will always be rendered on top of the grass. However, there is an easy way to fix this! In the node list of the Terrain Editor, you can click and drag any node to move it above or below existing nodes.

  • LMB-drag the Rock node and move it up in the list until you see a black bar appear between the Dirt and Grass nodes, as shown on the right.
  • Release LMB when you have positioned the node in the correct place.
  • With the Rock node now positioned between the Dirt and Grass nodes, the grass will appear on top of the rocks as well as the dirt, which looks much more natural!

Color changes

Maybe your dirt texture is too bright? Or maybe your grass looks a little too green? You can easily fix this from the Terrain Editor itself! No need to create a new image every time you want to tweak the color or brightness, you can set this up on a per-node basis.

Let's say you want to make the dirt texture darker and a bit more red. Here's how you'd do it:

  • Select your Dirt node.
  • Look under the Color Properties area in the property list, and LMB on the Color swatch (next to where it says 1 1 1, which is white).
  • A color wheel and brightness slider will pop up in a new window. You can use this to darken and tint your texture.
  • Choose a darker brightness, and a color slightly towards red. I used RGB Values of 225, 220, 220.
  • Hit OK to accept the color.
  • Re-render your MegaTexture preview. You should notice that the dirt layer looks darker now!

Texture rotation

If you're building up a lot of layers of tiling textures, it can sometimes become obvious when a texture tiles in a particular direction. You may see repeating patterns extending into the distance when looking in particular directions, especially if all your nodes have the same orientation.

An easy way to overcome this is to play with the Rotation value in the Texture Properties section of the Terrain Editor's property list. For each node, you should also set the Distribution Pattern Texture Rotation to match the Rotation value if you want your distribution patterns to line up and work correctly.

Render the MegaTexture

Save the Surface Tree

Once you're happy with how the preview looks in the editor, you should make sure that your final Surface Tree is saved. Either click the "Save and Unload" button in the Terrain Editor, or save the whole map.

Compile Only Entities

At this stage, your MegaTexture material is still technically "broken", since no .mega file exists yet. This means that if you try to compile the map, it'll take ages to process the terrain model, since it treats it as a regular model rather than the special case of terrain. Not only will this waste 5-10 minutes of your time, but it'll also produce a broken map.

However, we need to compile the map in order to tell the renderLight process which atmosphere to use when lighting the MegaTexture!

So the solution is to do an Only Entities compile. You can find this in the menu Compile -> 2 - Only Entities in editWorld. This should be done in a few seconds, and compiles all the information that renderLight needs.

Bear in mind that this compile process will not produce a playable map, so you will have to do a full recompile once the MegaTexture is fully rendered.

Run the SDK Launcher

Now that your .sft is saved, go through all the steps outlined in the Generate a MegaTexture tutorial.

That's it!

The MegaTexture in-game!

You've now created your very own MegaTexture to use in your map!

Before you even compile the map, you can get an accurate preview of how it will look in-game by pressing F6 to toggle "anim" mode while in editWorld's "RENDER" Camera view (toggled with F3).

Troubleshooting

If your terrain model still shows as red even after you've compiled the MegaTexture, there are a couple of things you should check first:

  • See if the console gives you any warnings about missing .stm files. If this is the case, you probably forgot to assign any Surface Types to your texture nodes. Double-check them and make sure it's all set up correctly.
  • Make sure there aren't any spelling mistakes or typos in your .mtr material file. The 2nd part of the material should have exactly the same name as your map (the < "mapname" > part described in this section), otherwise it will not be searching for the correct images.
  • Make sure there aren't any spelling mistakes in your .rlt file (as described in this article). If any of the names are inconsistent, the Megatexture will not have been compiled fully.

If your map compile is taking ages (ie. over 2-3 minutes for a 32,000 triangle terrain model) then it's probably because the MegaTexture material is broken. Double-check the issues listed above, and make sure you have run the reloadDecls console command if you changed any .mtr or .rlt files.

If your .mega and .stm files definitely exist, in the right folders, try closing and re-opening the .world file in editWorld. This should load and display the MegaTexture properly.

See Also