<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>https://wiki.splashdamage.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Ducks</id>
	<title>Mod Wiki - User contributions [en-gb]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.splashdamage.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Ducks"/>
	<link rel="alternate" type="text/html" href="https://wiki.splashdamage.com/index.php/Special:Contributions/Ducks"/>
	<updated>2026-04-07T14:25:36Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.31.0</generator>
	<entry>
		<id>https://wiki.splashdamage.com/index.php?title=File:Water_alltogether_cam.jpg&amp;diff=4095</id>
		<title>File:Water alltogether cam.jpg</title>
		<link rel="alternate" type="text/html" href="https://wiki.splashdamage.com/index.php?title=File:Water_alltogether_cam.jpg&amp;diff=4095"/>
		<updated>2008-01-07T10:57:30Z</updated>

		<summary type="html">&lt;p&gt;Ducks: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Ducks</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.splashdamage.com/index.php?title=File:Water_light_editor.jpg&amp;diff=4094</id>
		<title>File:Water light editor.jpg</title>
		<link rel="alternate" type="text/html" href="https://wiki.splashdamage.com/index.php?title=File:Water_light_editor.jpg&amp;diff=4094"/>
		<updated>2008-01-07T10:57:20Z</updated>

		<summary type="html">&lt;p&gt;Ducks: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Ducks</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.splashdamage.com/index.php?title=Map_Troubleshooting&amp;diff=4093</id>
		<title>Map Troubleshooting</title>
		<link rel="alternate" type="text/html" href="https://wiki.splashdamage.com/index.php?title=Map_Troubleshooting&amp;diff=4093"/>
		<updated>2008-01-03T14:46:52Z</updated>

		<summary type="html">&lt;p&gt;Ducks: /* Compile Issues */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page serves as a list of common issues that you may encounter while creating or editing a map of your own. Solutions or workarounds are provided wherever possible. '''Bugs and bug reports do not belong here!''' If you encounter an issue that is not answered or listed on this page, you are advised to try one of the [[#Additional Resources|support sites]] for guidance. Alternatively, try the [[Talk:Level Design Troubleshooting|talk page]] for this topic.&lt;br /&gt;
&lt;br /&gt;
* Note: This page assumes you are using the default key shortcuts.&lt;br /&gt;
* '''See also [[How do I]] page for a quick reference to common tasks.'''&lt;br /&gt;
&lt;br /&gt;
== General Questions ==&lt;br /&gt;
&lt;br /&gt;
=== How do I run the SDK? ===&lt;br /&gt;
After you've installed the ETQW SDK, you can launch it by running the 'SDK Launcher' shortcut from the Start Menu (it's usually found in 'Programs &amp;amp;gt; id Software &amp;amp;gt; Enemy Territory - QUAKE Wars(TM) SDK')&lt;br /&gt;
&lt;br /&gt;
=== How do I configure the SDK Launcher? ===&lt;br /&gt;
The SDK Launcher requires a retail path and a save path. These should typically be the place where you installed ETQW, for example 'C:\Program Files\id Software\Enemy Territory - QUAKE Wars'&lt;br /&gt;
&lt;br /&gt;
=== How do I launch the level editor, editWorld? ===&lt;br /&gt;
On the SDK Launcher, tick the 'editWorld' tickbox and then press 'Launch SDK'. This will load the game and it's built-in editor.&lt;br /&gt;
&lt;br /&gt;
Alternatively, you can run the SDK build of the game and use the {{consolecmd|editWorld}} console command.&lt;br /&gt;
&lt;br /&gt;
== Editor Issues ==&lt;br /&gt;
&lt;br /&gt;
=== I can't select a brush/surface ===&lt;br /&gt;
You're too close! '''Try moving the camera further away''' from the object you're trying to select. Otherwise the editor will assume you're intentionally inside the object and therefore don't want to select it.&lt;br /&gt;
&lt;br /&gt;
=== I can only select one object and not anything underneath it ===&lt;br /&gt;
Shift-clicking to select an object only lets you select the 'nearest' (or 'topmost') object, be it a brush, surface or entity. '''Use {{accelkey|Alt}}{{accelkey|Shift}}{{accelbtn|LMB}}''' to drill down through multiple objects, to the one you want to select.&lt;br /&gt;
&lt;br /&gt;
=== I pressed something and everything vanished ===&lt;br /&gt;
You may have accidentally hidden them. Pressing {{accelkey|H}} hides the selected objects. Pressing {{accelkey|Ctrl}}{{accelkey|Shift}}{{accelkey|H}} hides all the unselected objects. '''Pressing {{accelkey|Shift}}{{accelkey|H}} brings them all back.''' If that didn't do it, try {{accelkey|Ctrl}}{{accelkey|Z}} to undo the last edit you made.&lt;br /&gt;
&lt;br /&gt;
=== I can't stretch brushes anymore, only move them ===&lt;br /&gt;
You may have accidentally turned the 'Move selection mode (no size)' option on. '''Toggle it by pressing {{accelkey|W}}.'''&lt;br /&gt;
&lt;br /&gt;
=== 'Nothing to build' ===&lt;br /&gt;
Usually, you can stretch brushes by dragging from one of its surfaces using the mouse. However, if the surface you're trying to move is at a strange angle, or the brush is malformed, then you are not allowed to stretch it. '''This can often be overcome by selecting the brush and using {{accelkey|Ctrl}}{{accelkey|G}} to snap its vertices to the grid.'''&lt;br /&gt;
&lt;br /&gt;
=== editWorld crashes when I load big maps (or lots of small ones) ===&lt;br /&gt;
This is most often caused by low memory. '''Try using the 'Open Low Memory' command''' from the File menu instead and see if that works. It is advised to have at least 1GB of memory when editing large maps, and 2GB or more is preferable. &lt;br /&gt;
&lt;br /&gt;
=== A brush shows up as red in vertex manipulation mode ===&lt;br /&gt;
This indicates that '''the brush is malformed''', and hence editWorld will only let you fix or delete it. All brushes must have sides that are completely flat, and form a convex object (i.e. there aren't any holes or dents). Usually this can be fixed by selecting the object and pressing {{accelkey|Ctrl}}{{accelkey|G}}, which will snap its vertices to the grid and tries to fix any errors. If this doesn't work, you are best off deleting the brush and creating a new one.&lt;br /&gt;
&lt;br /&gt;
=== How do I compile my map? ===&lt;br /&gt;
From the 'Compile' menu of editWorld, select '1 - Compile'. Remember to watch the console ({{accelkey|O}}) for any warnings or errors - these will appear in yellow and red.&lt;br /&gt;
&lt;br /&gt;
=== 'WARNING: Couldn't load image:' ===&lt;br /&gt;
This often happens when trying to select a texture that doesn't actually exist. Currently the SDK refers to many textures that were not shipped with the game. You are advised to simply ignore these textures.&lt;br /&gt;
&lt;br /&gt;
=== 'WARNING: Failed to load image program:' ===&lt;br /&gt;
As above.&lt;br /&gt;
&lt;br /&gt;
=== Textures show up as red or yellow squares ===&lt;br /&gt;
As above - this happens when the texture images don't exist, or when there is a problem with the material file.&lt;br /&gt;
&lt;br /&gt;
=== The atmosphere doesn't display in Render mode ===&lt;br /&gt;
Check that your Render mode's atmosphere settings are correct - you can do this by clicking the drop-down menu arrow on the right of this button: [[Image:editworld_atmos_button.png|Show the atmosphere in Render mode]]. You should choose ''&amp;quot;atmosphere (&amp;lt;atmos name&amp;gt;)&amp;quot;'' if you have an Atmosphere entity in your map. You should only need to do this once, it will save the setting with the ''.world'' file.&lt;br /&gt;
&lt;br /&gt;
You can also use this button to try out different atmospheres without changing the map's atmosphere entity.&lt;br /&gt;
&lt;br /&gt;
== Compile Issues ==&lt;br /&gt;
&lt;br /&gt;
=== 'Warning: No entities in open -- no filling' ===&lt;br /&gt;
There aren't any entities in the map. You need at least one. Try adding an [[Entity info_player_start|info_player_start]] entity to get started.&lt;br /&gt;
&lt;br /&gt;
=== 'Warning: entity reached from outside -- no filling' ===&lt;br /&gt;
There is an entity on the outside of the map, in the void. This is the same problem as a leak (see below.)&lt;br /&gt;
&lt;br /&gt;
=== 'Warning: (entity name): Entity leaked' ===&lt;br /&gt;
This means either a) you have an entity outside your map, or b) you have a 'leak' in your map. When you get this error, editWorld will indicate in the 3D view which entity leaked, and the path it leaked through. If you follow the path, it should lead you to a hole in your map - which might be a missing wall or ceiling, or just a tiny gap between brushes that leads to the void outside. Any holes or gaps must be sealed. This error will occur once for each leak in your map.&lt;br /&gt;
&lt;br /&gt;
Remember that entities, patches and even some special textures do not seal the level - you need to have brushwork (even just using the caulk texture) to stop entities leaking into the void. Use the leak path to work out where the leak is occurring.&lt;br /&gt;
&lt;br /&gt;
=== My map takes hours and hours to compile ===&lt;br /&gt;
This often happens if you have large brushes in your level with tiling textures on them, since the compiler needs to split it up into smaller chunks. Try increasing the texture scale, reducing the size of the brush, or cutting the brush up into smaller parts yourself. (This does not apply to brushes with 'special' textures, such as caulk hulls.)&lt;br /&gt;
&lt;br /&gt;
== Game Issues ==&lt;br /&gt;
&lt;br /&gt;
=== The game can't see my map ===&lt;br /&gt;
First, ensure that your map has compiled correctly and is in the correct directory - there should be a few files named {{filename|''yourmap''.world}}, {{filename|''yourmap''.entities}}, {{filename|''yourmap''.cmb}}, and {{filename|''yourmap''.procb}} in the {{filename|base/maps}} folder of ETQW.&lt;br /&gt;
&lt;br /&gt;
=== {{consolecmd|devmap}} only lists campaign maps ===&lt;br /&gt;
Use {{consolecmd|si_rules sdGameRulesObjective}} to change the game mode. {{consolecmd|devmap}} will then show non-campaign maps. &lt;br /&gt;
&lt;br /&gt;
Alternatively, you can create a new campaign file in {{filename|base\def\campaigns\}} with your map specified in it, but this should only be used if you intend to create a campaign.&lt;br /&gt;
&lt;br /&gt;
=== 'spawn map denied: unknown campaign' ===&lt;br /&gt;
As above - set {{consolecmd|si_rules sdGameRulesObjective}} before trying to run your map.&lt;br /&gt;
&lt;br /&gt;
=== I can't build constructibles or capture spawns ===&lt;br /&gt;
The game may still be in warmup mode - press {{accelkey|f3}} to confirm you're ready and the game should start after 30 seconds.&lt;br /&gt;
&lt;br /&gt;
=== I made a door but it only opens sideways ===&lt;br /&gt;
Make sure the {{keyname|move_delta}} value is a vector, for example '0 0 128' (which is a vector indicating '0 units right, 0 units forwards and 128 units up')&lt;br /&gt;
&lt;br /&gt;
== Lighting Issues ==&lt;br /&gt;
&lt;br /&gt;
=== My map is pitch-black ===&lt;br /&gt;
The area either lacks [[Lighting Basics|lights]], has no ambience set, or is completely in shadow. If there are no lights, try adding some. Make sure they work in editWorld in Render Mode (usually toggled with {{accelkey|F3}}).&lt;br /&gt;
&lt;br /&gt;
=== My map is multi-coloured green and purple ===&lt;br /&gt;
This indicates that an ambience ([[Entity light_ambient|light_ambient]]) has not been specified for the area, or has been given a bad ambience to use.  Check that there is exactly one [[Entity light_ambient|light_ambient]] entity in the affected area, and that it specifies an ambience ({{keyname|Ambient Cubemap}}) that is both valid and not meant to produce multicoloured lighting. Ambient Cubemaps {{keyvalue|_blank}} and {{keyvalue|_default}} produce this sort of lighting, so make sure you're not using those - try something like {{keyvalue|area22}} instead.&lt;br /&gt;
&lt;br /&gt;
== Collision Issues ==&lt;br /&gt;
TODO &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Graphical Issues ==&lt;br /&gt;
&lt;br /&gt;
=== How do I make sky ===&lt;br /&gt;
Texture the brushes you want to appear as sky with the '[[Common Textures#common/caulk|common/caulk]]' texture. You'll also need an '[[Entity atmosphere|atmosphere]]' entity in your level, specifying the atmosphere you wish to use.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
* [http://community.enemyterritory.com/forums/forumdisplay.php?f=24 QUAKE Wars Mods and Editing] for mapping issues&lt;br /&gt;
* [http://community.enemyterritory.com/forums/forumdisplay.php?f=28 QUAKE Wars Bugs &amp;amp; Tech Help] for suspected bugs&lt;br /&gt;
&lt;br /&gt;
[[Category:Level Design]]&lt;/div&gt;</summary>
		<author><name>Ducks</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.splashdamage.com/index.php?title=Map_Troubleshooting&amp;diff=4092</id>
		<title>Map Troubleshooting</title>
		<link rel="alternate" type="text/html" href="https://wiki.splashdamage.com/index.php?title=Map_Troubleshooting&amp;diff=4092"/>
		<updated>2008-01-03T14:44:04Z</updated>

		<summary type="html">&lt;p&gt;Ducks: /* Game Issues */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page serves as a list of common issues that you may encounter while creating or editing a map of your own. Solutions or workarounds are provided wherever possible. '''Bugs and bug reports do not belong here!''' If you encounter an issue that is not answered or listed on this page, you are advised to try one of the [[#Additional Resources|support sites]] for guidance. Alternatively, try the [[Talk:Level Design Troubleshooting|talk page]] for this topic.&lt;br /&gt;
&lt;br /&gt;
* Note: This page assumes you are using the default key shortcuts.&lt;br /&gt;
* '''See also [[How do I]] page for a quick reference to common tasks.'''&lt;br /&gt;
&lt;br /&gt;
== General Questions ==&lt;br /&gt;
&lt;br /&gt;
=== How do I run the SDK? ===&lt;br /&gt;
After you've installed the ETQW SDK, you can launch it by running the 'SDK Launcher' shortcut from the Start Menu (it's usually found in 'Programs &amp;amp;gt; id Software &amp;amp;gt; Enemy Territory - QUAKE Wars(TM) SDK')&lt;br /&gt;
&lt;br /&gt;
=== How do I configure the SDK Launcher? ===&lt;br /&gt;
The SDK Launcher requires a retail path and a save path. These should typically be the place where you installed ETQW, for example 'C:\Program Files\id Software\Enemy Territory - QUAKE Wars'&lt;br /&gt;
&lt;br /&gt;
=== How do I launch the level editor, editWorld? ===&lt;br /&gt;
On the SDK Launcher, tick the 'editWorld' tickbox and then press 'Launch SDK'. This will load the game and it's built-in editor.&lt;br /&gt;
&lt;br /&gt;
Alternatively, you can run the SDK build of the game and use the {{consolecmd|editWorld}} console command.&lt;br /&gt;
&lt;br /&gt;
== Editor Issues ==&lt;br /&gt;
&lt;br /&gt;
=== I can't select a brush/surface ===&lt;br /&gt;
You're too close! '''Try moving the camera further away''' from the object you're trying to select. Otherwise the editor will assume you're intentionally inside the object and therefore don't want to select it.&lt;br /&gt;
&lt;br /&gt;
=== I can only select one object and not anything underneath it ===&lt;br /&gt;
Shift-clicking to select an object only lets you select the 'nearest' (or 'topmost') object, be it a brush, surface or entity. '''Use {{accelkey|Alt}}{{accelkey|Shift}}{{accelbtn|LMB}}''' to drill down through multiple objects, to the one you want to select.&lt;br /&gt;
&lt;br /&gt;
=== I pressed something and everything vanished ===&lt;br /&gt;
You may have accidentally hidden them. Pressing {{accelkey|H}} hides the selected objects. Pressing {{accelkey|Ctrl}}{{accelkey|Shift}}{{accelkey|H}} hides all the unselected objects. '''Pressing {{accelkey|Shift}}{{accelkey|H}} brings them all back.''' If that didn't do it, try {{accelkey|Ctrl}}{{accelkey|Z}} to undo the last edit you made.&lt;br /&gt;
&lt;br /&gt;
=== I can't stretch brushes anymore, only move them ===&lt;br /&gt;
You may have accidentally turned the 'Move selection mode (no size)' option on. '''Toggle it by pressing {{accelkey|W}}.'''&lt;br /&gt;
&lt;br /&gt;
=== 'Nothing to build' ===&lt;br /&gt;
Usually, you can stretch brushes by dragging from one of its surfaces using the mouse. However, if the surface you're trying to move is at a strange angle, or the brush is malformed, then you are not allowed to stretch it. '''This can often be overcome by selecting the brush and using {{accelkey|Ctrl}}{{accelkey|G}} to snap its vertices to the grid.'''&lt;br /&gt;
&lt;br /&gt;
=== editWorld crashes when I load big maps (or lots of small ones) ===&lt;br /&gt;
This is most often caused by low memory. '''Try using the 'Open Low Memory' command''' from the File menu instead and see if that works. It is advised to have at least 1GB of memory when editing large maps, and 2GB or more is preferable. &lt;br /&gt;
&lt;br /&gt;
=== A brush shows up as red in vertex manipulation mode ===&lt;br /&gt;
This indicates that '''the brush is malformed''', and hence editWorld will only let you fix or delete it. All brushes must have sides that are completely flat, and form a convex object (i.e. there aren't any holes or dents). Usually this can be fixed by selecting the object and pressing {{accelkey|Ctrl}}{{accelkey|G}}, which will snap its vertices to the grid and tries to fix any errors. If this doesn't work, you are best off deleting the brush and creating a new one.&lt;br /&gt;
&lt;br /&gt;
=== How do I compile my map? ===&lt;br /&gt;
From the 'Compile' menu of editWorld, select '1 - Compile'. Remember to watch the console ({{accelkey|O}}) for any warnings or errors - these will appear in yellow and red.&lt;br /&gt;
&lt;br /&gt;
=== 'WARNING: Couldn't load image:' ===&lt;br /&gt;
This often happens when trying to select a texture that doesn't actually exist. Currently the SDK refers to many textures that were not shipped with the game. You are advised to simply ignore these textures.&lt;br /&gt;
&lt;br /&gt;
=== 'WARNING: Failed to load image program:' ===&lt;br /&gt;
As above.&lt;br /&gt;
&lt;br /&gt;
=== Textures show up as red or yellow squares ===&lt;br /&gt;
As above - this happens when the texture images don't exist, or when there is a problem with the material file.&lt;br /&gt;
&lt;br /&gt;
=== The atmosphere doesn't display in Render mode ===&lt;br /&gt;
Check that your Render mode's atmosphere settings are correct - you can do this by clicking the drop-down menu arrow on the right of this button: [[Image:editworld_atmos_button.png|Show the atmosphere in Render mode]]. You should choose ''&amp;quot;atmosphere (&amp;lt;atmos name&amp;gt;)&amp;quot;'' if you have an Atmosphere entity in your map. You should only need to do this once, it will save the setting with the ''.world'' file.&lt;br /&gt;
&lt;br /&gt;
You can also use this button to try out different atmospheres without changing the map's atmosphere entity.&lt;br /&gt;
&lt;br /&gt;
== Compile Issues ==&lt;br /&gt;
&lt;br /&gt;
=== 'Warning: No entities in open -- no filling' ===&lt;br /&gt;
There aren't any entities in the map. You need at least one. Try adding an [[Entity info_player_start|info_player_start]] entity to get started.&lt;br /&gt;
&lt;br /&gt;
=== 'Warning: entity reached from outside -- no filling' ===&lt;br /&gt;
There is an entity on the outside of the map, in the void. This is the same problem as a leak (see below.)&lt;br /&gt;
&lt;br /&gt;
=== 'Warning: (entity name): Entity leaked' ===&lt;br /&gt;
This means either a) you have an entity outside your map, or b) you have a 'leak' in your map. When you get this error, editWorld will indicate in the 3D view which entity leaked, and the path it leaked through. If you follow the path, it should lead you to a hole in your map - which might be a missing wall or ceiling, or just a tiny gap between brushes that leads to the void outside. Any holes or gaps must be sealed. This error will occur once for each leak in your map.&lt;br /&gt;
&lt;br /&gt;
Remember that entities, patches and even some special textures do not seal the level - you need to have brushwork (even just using the caulk texture) to stop entities leaking into the void. Use the leak path to work out where the leak is occurring.&lt;br /&gt;
&lt;br /&gt;
== Game Issues ==&lt;br /&gt;
&lt;br /&gt;
=== The game can't see my map ===&lt;br /&gt;
First, ensure that your map has compiled correctly and is in the correct directory - there should be a few files named {{filename|''yourmap''.world}}, {{filename|''yourmap''.entities}}, {{filename|''yourmap''.cmb}}, and {{filename|''yourmap''.procb}} in the {{filename|base/maps}} folder of ETQW.&lt;br /&gt;
&lt;br /&gt;
=== {{consolecmd|devmap}} only lists campaign maps ===&lt;br /&gt;
Use {{consolecmd|si_rules sdGameRulesObjective}} to change the game mode. {{consolecmd|devmap}} will then show non-campaign maps. &lt;br /&gt;
&lt;br /&gt;
Alternatively, you can create a new campaign file in {{filename|base\def\campaigns\}} with your map specified in it, but this should only be used if you intend to create a campaign.&lt;br /&gt;
&lt;br /&gt;
=== 'spawn map denied: unknown campaign' ===&lt;br /&gt;
As above - set {{consolecmd|si_rules sdGameRulesObjective}} before trying to run your map.&lt;br /&gt;
&lt;br /&gt;
=== I can't build constructibles or capture spawns ===&lt;br /&gt;
The game may still be in warmup mode - press {{accelkey|f3}} to confirm you're ready and the game should start after 30 seconds.&lt;br /&gt;
&lt;br /&gt;
=== I made a door but it only opens sideways ===&lt;br /&gt;
Make sure the {{keyname|move_delta}} value is a vector, for example '0 0 128' (which is a vector indicating '0 units right, 0 units forwards and 128 units up')&lt;br /&gt;
&lt;br /&gt;
== Lighting Issues ==&lt;br /&gt;
&lt;br /&gt;
=== My map is pitch-black ===&lt;br /&gt;
The area either lacks [[Lighting Basics|lights]], has no ambience set, or is completely in shadow. If there are no lights, try adding some. Make sure they work in editWorld in Render Mode (usually toggled with {{accelkey|F3}}).&lt;br /&gt;
&lt;br /&gt;
=== My map is multi-coloured green and purple ===&lt;br /&gt;
This indicates that an ambience ([[Entity light_ambient|light_ambient]]) has not been specified for the area, or has been given a bad ambience to use.  Check that there is exactly one [[Entity light_ambient|light_ambient]] entity in the affected area, and that it specifies an ambience ({{keyname|Ambient Cubemap}}) that is both valid and not meant to produce multicoloured lighting. Ambient Cubemaps {{keyvalue|_blank}} and {{keyvalue|_default}} produce this sort of lighting, so make sure you're not using those - try something like {{keyvalue|area22}} instead.&lt;br /&gt;
&lt;br /&gt;
== Collision Issues ==&lt;br /&gt;
TODO &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Graphical Issues ==&lt;br /&gt;
&lt;br /&gt;
=== How do I make sky ===&lt;br /&gt;
Texture the brushes you want to appear as sky with the '[[Common Textures#common/caulk|common/caulk]]' texture. You'll also need an '[[Entity atmosphere|atmosphere]]' entity in your level, specifying the atmosphere you wish to use.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
* [http://community.enemyterritory.com/forums/forumdisplay.php?f=24 QUAKE Wars Mods and Editing] for mapping issues&lt;br /&gt;
* [http://community.enemyterritory.com/forums/forumdisplay.php?f=28 QUAKE Wars Bugs &amp;amp; Tech Help] for suspected bugs&lt;br /&gt;
&lt;br /&gt;
[[Category:Level Design]]&lt;/div&gt;</summary>
		<author><name>Ducks</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.splashdamage.com/index.php?title=Collision_Meshes&amp;diff=4090</id>
		<title>Collision Meshes</title>
		<link rel="alternate" type="text/html" href="https://wiki.splashdamage.com/index.php?title=Collision_Meshes&amp;diff=4090"/>
		<updated>2008-01-03T13:40:22Z</updated>

		<summary type="html">&lt;p&gt;Ducks: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
Collision meshes are used to improve in-game physics performance. They can also be used to stop players or vehicles catching on small protrusions from meshes, and generally smoothing out player movement over complex shapes.&lt;br /&gt;
&lt;br /&gt;
== Collision Meshes for Mapobject Models ==&lt;br /&gt;
When you make a model to be used as a mapobject, by default all the triangles are used as collision parts. This means that bullets, projectiles, players and vehicles collision all have to be calculated against every polygon in the model. Most of the time this is unnecessary (especially for player and vehicle collision) and reduces run-time performance in the game.&lt;br /&gt;
&lt;br /&gt;
Therefore, we can make optimised versions of the mesh, and store them in the same model file with a specific &amp;quot;collision&amp;quot; materials so that the game will only calculate collisions against the optimised versions.&amp;lt;includeonly&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{main|Collision Meshes}}&amp;lt;/includeonly&amp;gt;&amp;lt;noinclude&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== A Simple Example ===&lt;br /&gt;
[[Image:teapot_mesh.jpg|right|thumb|A small but detailed teapot model.]]&lt;br /&gt;
Here's a teapot model that we want to use in the game. It's not very big, but it has 1600 triangles!&lt;br /&gt;
At the moment, all the model's triangles will be used to calculate collision, which isn't very efficient or necessary.&lt;br /&gt;
&lt;br /&gt;
We could set ''&amp;quot;nonsolid&amp;quot;'' on the teapot's material, but that would mean that players could walk through the object and bullets wouldn't collide with it, which is usually not what you want!&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
==== Vehicle and Player Collision ====&lt;br /&gt;
[[Image:teapot_vehicleplayerclip.jpg|right|thumb|The vehicle and player collision mesh for the teapot, made of 15 polygons.]]&lt;br /&gt;
We usually make really simple shapes that serve as collision models for vehicle and player physics. Most of the time, especially on small objects, the player will not be able to tell they are walking over or around a box or simple cylinder instead of the actual visible mesh.&lt;br /&gt;
&lt;br /&gt;
In fact, in a lot of cases, a simpler vehicle and player collision mesh also makes movement around the world feel smoother, since there aren't any small poking-out pieces to get stuck on.&lt;br /&gt;
&lt;br /&gt;
The vehicle and player collision mesh we've created here is only 18 triangles! It should be fine for the player to walk around without getting stuck, and is much cheaper for collision physics calculations.&lt;br /&gt;
&lt;br /&gt;
For this mesh we use &amp;quot;&amp;lt;tt&amp;gt;textures/common/vehicleplayer_clip&amp;lt;/tt&amp;gt;&amp;quot; to make sure it collides with only vehicles and players (more info at the bottom of this page).&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Bullet Collision ====&lt;br /&gt;
[[Image:teapot_bulletclip.jpg|right|thumb|The bullet collision mesh for the teapot, made of 160 polygons.]]&lt;br /&gt;
Most of the time, the very simple shape used for player and vehicle collision is not enough to support complex surface interactions like drawing bullet decals onto the mesh. Additionally, a mesh that is simplified for player and vehicle collision might create invisible collision in places where you should be able to shoot bullets through (in this case, the teapot's handle).&lt;br /&gt;
&lt;br /&gt;
Therefore, we need to make a bullet collision mesh. At only 160 polygons, this bullet collision mesh is 10 times less detailed than the visible teapot mesh. This is still keeping enough information about the shape and volume of the teapot to create an accurate representation of how bullets might collide with it.&lt;br /&gt;
&lt;br /&gt;
For this mesh we use &amp;quot;&amp;lt;tt&amp;gt;textures/common/rendermodel_clip&amp;lt;/tt&amp;gt;&amp;quot; to make sure it collides with only bullets (more info at the bottom of this page).&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Collision Model Tips ====&lt;br /&gt;
* You do not have to create separate meshes for the vehicles, players and bullet collision if you don't want to. You can create a single optimised collision mesh and use the &amp;quot;&amp;lt;tt&amp;gt;textures/common/collision&amp;lt;/tt&amp;gt;&amp;quot; material.&lt;br /&gt;
* Unlike shadow hulls, collision meshes do not have to be &amp;quot;watertight&amp;quot;, open edges are allowed. However, bear in mind that things in the game will only collide with front-facing polys, so a single flat plane would only have collision on one side of it.&lt;br /&gt;
* Collision meshes are automatically optimised by the game to use polygons rather than triangles. Therefore, co-planar triangles will be optimised down into a single ''n''-sided polygon, for efficiency and performance.&lt;br /&gt;
** As an example, while a simple cube is rendered using 12 three-sided polygons (triangls), the collision optimisation will read it as 6 four-sided polygons (quads).&lt;br /&gt;
* As soon as you add any collision materials to your model file, any non-collision materials will be treated as nonsolid. Therefore, if you only add a player_clip mesh to your model, you will find that vehicles and bullets still pass through.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Valid Collision Materials ==&lt;br /&gt;
The surface type of each material is denoted by the suffix (eg. ''_metal'' for metal sound and particle effects).&lt;br /&gt;
Where no surface type suffix is specified, default effects will be used, which usually look and sound like concrete.&lt;br /&gt;
&lt;br /&gt;
=== Generic Collision ===&lt;br /&gt;
Vehicles, players, bullets and projectiles will all collide with this material. Nothing passes through.&lt;br /&gt;
* &amp;lt;tt&amp;gt;textures/common/collision&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;textures/common/collision_wood&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;textures/common/collision_metal&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;textures/common/collision_concrete&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Vehicle &amp;amp; Player Collision ===&lt;br /&gt;
Vehicles and players will collide with this material. Projectiles and bullets will pass through.&lt;br /&gt;
* &amp;lt;tt&amp;gt;textures/common/vehicleplayer_clip&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;textures/common/vehicleplayer_clip_metal&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;textures/common/vehicleplayer_clip_wood&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;textures/common/vehicleplayer_clip_concrete&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;textures/common/vehicleplayer_clip_glass&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;textures/common/vehicleplayer_clip_snow&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Player Collision ===&lt;br /&gt;
Only players will collide with this material. Vehicles, projectiles and bullets will pass through.&lt;br /&gt;
* &amp;lt;tt&amp;gt;textures/common/player_clip&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;textures/common/player_clip_metal&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;textures/common/player_clip_wood&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;textures/common/player_clip_concrete&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;textures/common/player_clip_glass&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Vehicle Collision ===&lt;br /&gt;
Only vehicles will collide with this material. Players, projectiles and bullets will pass through.&lt;br /&gt;
* &amp;lt;tt&amp;gt;textures/common/vehicle_clip&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;textures/common/vehicle_clip_metal&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;textures/common/vehicle_clip_wood&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;textures/common/vehicle_clip_concrete&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;textures/common/vehicle_clip_snow&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== &amp;quot;Rendermodel&amp;quot; Collision ===&lt;br /&gt;
Bullets and projectiles (and flyer drones!) will collide with this material. Players and vehicles will pass through.&lt;br /&gt;
* &amp;lt;tt&amp;gt;textures/common/rendermodel_clip&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;textures/common/rendermodel_clip_metal&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;textures/common/rendermodel_clip_wood&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;textures/common/rendermodel_clip_concrete&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;textures/common/rendermodel_clip_glass&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Special Collision Types ===&lt;br /&gt;
* &amp;lt;tt&amp;gt;textures/common/projectile_clip&amp;lt;/tt&amp;gt; - Allows bullets to pass through, but not projectiles (eg. rockets and tank shells).&lt;br /&gt;
&lt;br /&gt;
[[Category:Models]]&lt;br /&gt;
&amp;lt;/noinclude&amp;gt;&lt;/div&gt;</summary>
		<author><name>Ducks</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.splashdamage.com/index.php?title=Collision_Meshes&amp;diff=4089</id>
		<title>Collision Meshes</title>
		<link rel="alternate" type="text/html" href="https://wiki.splashdamage.com/index.php?title=Collision_Meshes&amp;diff=4089"/>
		<updated>2008-01-03T12:36:01Z</updated>

		<summary type="html">&lt;p&gt;Ducks: /* Valid Collision Materials */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
Collision meshes are used to improve in-game physics performance. They can also be used to stop players or vehicles catching on small protrusions from meshes, and generally smoothing out player movement over complex shapes.&lt;br /&gt;
&lt;br /&gt;
== Collision Meshes for Mapobject Models ==&lt;br /&gt;
When you make a model to be used as a mapobject, by default all the triangles are used as collision parts. This means that bullets, projectiles, players and vehicles collision all have to be calculated against every polygon in the model. Most of the time this is unnecessary (especially for player and vehicle collision) and reduces run-time performance in the game.&lt;br /&gt;
&lt;br /&gt;
Therefore, we can make optimised versions of the mesh, and store them in the same model file with a specific &amp;quot;collision&amp;quot; materials so that the game will only calculate collisions against the optimised versions.&amp;lt;includeonly&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{main|Collision Meshes}}&amp;lt;/includeonly&amp;gt;&amp;lt;noinclude&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== A Simple Example ===&lt;br /&gt;
[[Image:teapot_mesh.jpg|right|thumb|A small but detailed teapot model.]]&lt;br /&gt;
Here's a teapot model that we want to use in the game. It's not very big, but it has 1600 triangles!&lt;br /&gt;
At the moment, all the model's triangles will be used to calculate collision, which isn't very efficient or necessary.&lt;br /&gt;
&lt;br /&gt;
We could set ''&amp;quot;nonsolid&amp;quot;'' on the teapot's material, but that would mean that players could walk through the object and bullets wouldn't collide with it, which is usually not what you want!&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
== Vehicle and Player Collision ==&lt;br /&gt;
[[Image:teapot_vehicleplayerclip.jpg|right|thumb|The vehicle and player collision mesh for the teapot, made of 15 polygons.]]&lt;br /&gt;
We usually make really simple shapes that serve as collision models for vehicle and player physics. Most of the time, especially on small objects, the player will not be able to tell they are walking over or around a box or simple cylinder instead of the actual visible mesh.&lt;br /&gt;
&lt;br /&gt;
In fact, in a lot of cases, a simpler vehicle and player collision mesh also makes movement around the world feel smoother, since there aren't any small poking-out pieces to get stuck on.&lt;br /&gt;
&lt;br /&gt;
The vehicle and player collision mesh we've created here is only 18 triangles! It should be fine for the player to walk around without getting stuck, and is much cheaper for collision physics calculations.&lt;br /&gt;
&lt;br /&gt;
For this mesh we use &amp;quot;&amp;lt;tt&amp;gt;textures/common/vehicleplayer_clip&amp;lt;/tt&amp;gt;&amp;quot; to make sure it collides with only vehicles and players (more info at the bottom of this page).&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Bullet Collision ==&lt;br /&gt;
[[Image:teapot_bulletclip.jpg|right|thumb|The bullet collision mesh for the teapot, made of 160 polygons.]]&lt;br /&gt;
Most of the time, the very simple shape used for player and vehicle collision is not enough to support complex surface interactions like drawing bullet decals onto the mesh. Additionally, a mesh that is simplified for player and vehicle collision might create invisible collision in places where you should be able to shoot bullets through (in this case, the teapot's handle).&lt;br /&gt;
&lt;br /&gt;
Therefore, we need to make a bullet collision mesh. At only 160 polygons, this bullet collision mesh is 10 times less detailed than the visible teapot mesh. This is still keeping enough information about the shape and volume of the teapot to create an accurate representation of how bullets might collide with it.&lt;br /&gt;
&lt;br /&gt;
For this mesh we use &amp;quot;&amp;lt;tt&amp;gt;textures/common/rendermodel_clip&amp;lt;/tt&amp;gt;&amp;quot; to make sure it collides with only bullets (more info at the bottom of this page).&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Collision Model Tips ==&lt;br /&gt;
* You do not have to create separate meshes for the vehicles, players and bullet collision if you don't want to. You can create a single optimised collision mesh and use the &amp;quot;&amp;lt;tt&amp;gt;textures/common/collision&amp;lt;/tt&amp;gt;&amp;quot; material.&lt;br /&gt;
* Unlike shadow hulls, collision meshes do not have to be &amp;quot;watertight&amp;quot;, open edges are allowed. However, bear in mind that things in the game will only collide with front-facing polys, so a single flat plane would only have collision on one side of it.&lt;br /&gt;
* Collision meshes are automatically optimised by the game to use polygons rather than triangles. Therefore, co-planar triangles will be optimised down into a single ''n''-sided polygon, for efficiency and performance.&lt;br /&gt;
** As an example, while a simple cube is rendered using 12 three-sided polygons (triangls), the collision optimisation will read it as 6 four-sided polygons (quads).&lt;br /&gt;
* As soon as you add any collision materials to your model file, any non-collision materials will be treated as nonsolid. Therefore, if you only add a player_clip mesh to your model, you will find that vehicles and bullets still pass through.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Valid Collision Materials ==&lt;br /&gt;
The surface type of each material is denoted by the suffix (eg. ''_metal'' for metal sound and particle effects).&lt;br /&gt;
Where no surface type suffix is specified, default effects will be used, which usually look and sound like concrete.&lt;br /&gt;
&lt;br /&gt;
=== Generic Collision ===&lt;br /&gt;
Vehicles, players, bullets and projectiles will all collide with this material. Nothing passes through.&lt;br /&gt;
* &amp;lt;tt&amp;gt;textures/common/collision&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;textures/common/collision_wood&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;textures/common/collision_metal&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;textures/common/collision_concrete&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Vehicle &amp;amp; Player Collision ===&lt;br /&gt;
Vehicles and players will collide with this material. Projectiles and bullets will pass through.&lt;br /&gt;
* &amp;lt;tt&amp;gt;textures/common/vehicleplayer_clip&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;textures/common/vehicleplayer_clip_metal&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;textures/common/vehicleplayer_clip_wood&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;textures/common/vehicleplayer_clip_concrete&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;textures/common/vehicleplayer_clip_glass&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;textures/common/vehicleplayer_clip_snow&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Player Collision ===&lt;br /&gt;
Only players will collide with this material. Vehicles, projectiles and bullets will pass through.&lt;br /&gt;
* &amp;lt;tt&amp;gt;textures/common/player_clip&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;textures/common/player_clip_metal&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;textures/common/player_clip_wood&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;textures/common/player_clip_concrete&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;textures/common/player_clip_glass&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Vehicle Collision ===&lt;br /&gt;
Only vehicles will collide with this material. Players, projectiles and bullets will pass through.&lt;br /&gt;
* &amp;lt;tt&amp;gt;textures/common/vehicle_clip&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;textures/common/vehicle_clip_metal&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;textures/common/vehicle_clip_wood&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;textures/common/vehicle_clip_concrete&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;textures/common/vehicle_clip_snow&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== &amp;quot;Rendermodel&amp;quot; Collision ===&lt;br /&gt;
Bullets and projectiles (and flyer drones!) will collide with this material. Players and vehicles will pass through.&lt;br /&gt;
* &amp;lt;tt&amp;gt;textures/common/rendermodel_clip&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;textures/common/rendermodel_clip_metal&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;textures/common/rendermodel_clip_wood&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;textures/common/rendermodel_clip_concrete&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;textures/common/rendermodel_clip_glass&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Special Collision Types ===&lt;br /&gt;
* &amp;lt;tt&amp;gt;textures/common/projectile_clip&amp;lt;/tt&amp;gt; - Allows bullets to pass through, but not projectiles (eg. rockets and tank shells).&lt;br /&gt;
&lt;br /&gt;
[[Category:Models]]&lt;br /&gt;
&amp;lt;/noinclude&amp;gt;&lt;/div&gt;</summary>
		<author><name>Ducks</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.splashdamage.com/index.php?title=Collision_Meshes&amp;diff=4088</id>
		<title>Collision Meshes</title>
		<link rel="alternate" type="text/html" href="https://wiki.splashdamage.com/index.php?title=Collision_Meshes&amp;diff=4088"/>
		<updated>2008-01-03T12:33:50Z</updated>

		<summary type="html">&lt;p&gt;Ducks: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
Collision meshes are used to improve in-game physics performance. They can also be used to stop players or vehicles catching on small protrusions from meshes, and generally smoothing out player movement over complex shapes.&lt;br /&gt;
&lt;br /&gt;
== Collision Meshes for Mapobject Models ==&lt;br /&gt;
When you make a model to be used as a mapobject, by default all the triangles are used as collision parts. This means that bullets, projectiles, players and vehicles collision all have to be calculated against every polygon in the model. Most of the time this is unnecessary (especially for player and vehicle collision) and reduces run-time performance in the game.&lt;br /&gt;
&lt;br /&gt;
Therefore, we can make optimised versions of the mesh, and store them in the same model file with a specific &amp;quot;collision&amp;quot; materials so that the game will only calculate collisions against the optimised versions.&amp;lt;includeonly&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{main|Collision Meshes}}&amp;lt;/includeonly&amp;gt;&amp;lt;noinclude&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== A Simple Example ===&lt;br /&gt;
[[Image:teapot_mesh.jpg|right|thumb|A small but detailed teapot model.]]&lt;br /&gt;
Here's a teapot model that we want to use in the game. It's not very big, but it has 1600 triangles!&lt;br /&gt;
At the moment, all the model's triangles will be used to calculate collision, which isn't very efficient or necessary.&lt;br /&gt;
&lt;br /&gt;
We could set ''&amp;quot;nonsolid&amp;quot;'' on the teapot's material, but that would mean that players could walk through the object and bullets wouldn't collide with it, which is usually not what you want!&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
== Vehicle and Player Collision ==&lt;br /&gt;
[[Image:teapot_vehicleplayerclip.jpg|right|thumb|The vehicle and player collision mesh for the teapot, made of 15 polygons.]]&lt;br /&gt;
We usually make really simple shapes that serve as collision models for vehicle and player physics. Most of the time, especially on small objects, the player will not be able to tell they are walking over or around a box or simple cylinder instead of the actual visible mesh.&lt;br /&gt;
&lt;br /&gt;
In fact, in a lot of cases, a simpler vehicle and player collision mesh also makes movement around the world feel smoother, since there aren't any small poking-out pieces to get stuck on.&lt;br /&gt;
&lt;br /&gt;
The vehicle and player collision mesh we've created here is only 18 triangles! It should be fine for the player to walk around without getting stuck, and is much cheaper for collision physics calculations.&lt;br /&gt;
&lt;br /&gt;
For this mesh we use &amp;quot;&amp;lt;tt&amp;gt;textures/common/vehicleplayer_clip&amp;lt;/tt&amp;gt;&amp;quot; to make sure it collides with only vehicles and players (more info at the bottom of this page).&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Bullet Collision ==&lt;br /&gt;
[[Image:teapot_bulletclip.jpg|right|thumb|The bullet collision mesh for the teapot, made of 160 polygons.]]&lt;br /&gt;
Most of the time, the very simple shape used for player and vehicle collision is not enough to support complex surface interactions like drawing bullet decals onto the mesh. Additionally, a mesh that is simplified for player and vehicle collision might create invisible collision in places where you should be able to shoot bullets through (in this case, the teapot's handle).&lt;br /&gt;
&lt;br /&gt;
Therefore, we need to make a bullet collision mesh. At only 160 polygons, this bullet collision mesh is 10 times less detailed than the visible teapot mesh. This is still keeping enough information about the shape and volume of the teapot to create an accurate representation of how bullets might collide with it.&lt;br /&gt;
&lt;br /&gt;
For this mesh we use &amp;quot;&amp;lt;tt&amp;gt;textures/common/rendermodel_clip&amp;lt;/tt&amp;gt;&amp;quot; to make sure it collides with only bullets (more info at the bottom of this page).&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Collision Model Tips ==&lt;br /&gt;
* You do not have to create separate meshes for the vehicles, players and bullet collision if you don't want to. You can create a single optimised collision mesh and use the &amp;quot;&amp;lt;tt&amp;gt;textures/common/collision&amp;lt;/tt&amp;gt;&amp;quot; material.&lt;br /&gt;
* Unlike shadow hulls, collision meshes do not have to be &amp;quot;watertight&amp;quot;, open edges are allowed. However, bear in mind that things in the game will only collide with front-facing polys, so a single flat plane would only have collision on one side of it.&lt;br /&gt;
* Collision meshes are automatically optimised by the game to use polygons rather than triangles. Therefore, co-planar triangles will be optimised down into a single ''n''-sided polygon, for efficiency and performance.&lt;br /&gt;
** As an example, while a simple cube is rendered using 12 three-sided polygons (triangls), the collision optimisation will read it as 6 four-sided polygons (quads).&lt;br /&gt;
* As soon as you add any collision materials to your model file, any non-collision materials will be treated as nonsolid. Therefore, if you only add a player_clip mesh to your model, you will find that vehicles and bullets still pass through.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Valid Collision Materials ==&lt;br /&gt;
----&lt;br /&gt;
The surface type of each material is denoted by the suffix (eg. ''_metal'' for metal sound and particle effects).&lt;br /&gt;
Where no surface type suffix is specified, default effects will be used, which usually look and sound like concrete.&lt;br /&gt;
&lt;br /&gt;
=== Generic Collision ===&lt;br /&gt;
Vehicles, players, bullets and projectiles will all collide with this material. Nothing passes through.&lt;br /&gt;
* &amp;lt;tt&amp;gt;textures/common/collision&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;textures/common/collision_wood&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;textures/common/collision_metal&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;textures/common/collision_concrete&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Vehicle &amp;amp; Player Collision ===&lt;br /&gt;
Vehicles and players will collide with this material. Projectiles and bullets will pass through.&lt;br /&gt;
* &amp;lt;tt&amp;gt;textures/common/vehicleplayer_clip&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;textures/common/vehicleplayer_clip_metal&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;textures/common/vehicleplayer_clip_wood&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;textures/common/vehicleplayer_clip_concrete&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;textures/common/vehicleplayer_clip_glass&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;textures/common/vehicleplayer_clip_snow&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Player Collision ===&lt;br /&gt;
Only players will collide with this material. Vehicles, projectiles and bullets will pass through.&lt;br /&gt;
* &amp;lt;tt&amp;gt;textures/common/player_clip&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;textures/common/player_clip_metal&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;textures/common/player_clip_wood&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;textures/common/player_clip_concrete&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;textures/common/player_clip_glass&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Vehicle Collision ===&lt;br /&gt;
Only vehicles will collide with this material. Players, projectiles and bullets will pass through.&lt;br /&gt;
* &amp;lt;tt&amp;gt;textures/common/vehicle_clip&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;textures/common/vehicle_clip_metal&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;textures/common/vehicle_clip_wood&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;textures/common/vehicle_clip_concrete&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;textures/common/vehicle_clip_snow&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== &amp;quot;Rendermodel&amp;quot; Collision ===&lt;br /&gt;
Bullets and projectiles (and flyer drones!) will collide with this material. Players and vehicles will pass through.&lt;br /&gt;
* &amp;lt;tt&amp;gt;textures/common/rendermodel_clip&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;textures/common/rendermodel_clip_metal&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;textures/common/rendermodel_clip_wood&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;textures/common/rendermodel_clip_concrete&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;textures/common/rendermodel_clip_glass&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Special Collision Types ===&lt;br /&gt;
* &amp;lt;tt&amp;gt;textures/common/projectile_clip&amp;lt;/tt&amp;gt; - Allows bullets to pass through, but not projectiles (eg. rockets and tank shells).&lt;br /&gt;
&lt;br /&gt;
[[Category:Models]]&lt;br /&gt;
&amp;lt;/noinclude&amp;gt;&lt;/div&gt;</summary>
		<author><name>Ducks</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.splashdamage.com/index.php?title=Collision_Meshes&amp;diff=4087</id>
		<title>Collision Meshes</title>
		<link rel="alternate" type="text/html" href="https://wiki.splashdamage.com/index.php?title=Collision_Meshes&amp;diff=4087"/>
		<updated>2008-01-03T12:33:30Z</updated>

		<summary type="html">&lt;p&gt;Ducks: tidied up headings&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
Collision meshes are used to improve in-game physics performance. They can also be used to stop players or vehicles catching on small protrusions from meshes, and generally smoothing out player movement over complex shapes.&lt;br /&gt;
&lt;br /&gt;
== Collision Meshes for Mapobject Models ==&lt;br /&gt;
When you make a model to be used as a mapobject, by default all the triangles are used as collision parts. This means that bullets, projectiles, players and vehicles collision all have to be calculated against every polygon in the model. Most of the time this is unnecessary (especially for player and vehicle collision) and reduces run-time performance in the game.&lt;br /&gt;
&lt;br /&gt;
Therefore, we can make optimised versions of the mesh, and store them in the same model file with a specific &amp;quot;collision&amp;quot; materials so that the game will only calculate collisions against the optimised versions.&amp;lt;includeonly&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{main|Collision Meshes}}&amp;lt;/includeonly&amp;gt;&amp;lt;noinclude&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== A Simple Example ==&lt;br /&gt;
----&lt;br /&gt;
[[Image:teapot_mesh.jpg|right|thumb|A small but detailed teapot model.]]&lt;br /&gt;
Here's a teapot model that we want to use in the game. It's not very big, but it has 1600 triangles!&lt;br /&gt;
At the moment, all the model's triangles will be used to calculate collision, which isn't very efficient or necessary.&lt;br /&gt;
&lt;br /&gt;
We could set ''&amp;quot;nonsolid&amp;quot;'' on the teapot's material, but that would mean that players could walk through the object and bullets wouldn't collide with it, which is usually not what you want!&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
== Vehicle and Player Collision ==&lt;br /&gt;
[[Image:teapot_vehicleplayerclip.jpg|right|thumb|The vehicle and player collision mesh for the teapot, made of 15 polygons.]]&lt;br /&gt;
We usually make really simple shapes that serve as collision models for vehicle and player physics. Most of the time, especially on small objects, the player will not be able to tell they are walking over or around a box or simple cylinder instead of the actual visible mesh.&lt;br /&gt;
&lt;br /&gt;
In fact, in a lot of cases, a simpler vehicle and player collision mesh also makes movement around the world feel smoother, since there aren't any small poking-out pieces to get stuck on.&lt;br /&gt;
&lt;br /&gt;
The vehicle and player collision mesh we've created here is only 18 triangles! It should be fine for the player to walk around without getting stuck, and is much cheaper for collision physics calculations.&lt;br /&gt;
&lt;br /&gt;
For this mesh we use &amp;quot;&amp;lt;tt&amp;gt;textures/common/vehicleplayer_clip&amp;lt;/tt&amp;gt;&amp;quot; to make sure it collides with only vehicles and players (more info at the bottom of this page).&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Bullet Collision ==&lt;br /&gt;
[[Image:teapot_bulletclip.jpg|right|thumb|The bullet collision mesh for the teapot, made of 160 polygons.]]&lt;br /&gt;
Most of the time, the very simple shape used for player and vehicle collision is not enough to support complex surface interactions like drawing bullet decals onto the mesh. Additionally, a mesh that is simplified for player and vehicle collision might create invisible collision in places where you should be able to shoot bullets through (in this case, the teapot's handle).&lt;br /&gt;
&lt;br /&gt;
Therefore, we need to make a bullet collision mesh. At only 160 polygons, this bullet collision mesh is 10 times less detailed than the visible teapot mesh. This is still keeping enough information about the shape and volume of the teapot to create an accurate representation of how bullets might collide with it.&lt;br /&gt;
&lt;br /&gt;
For this mesh we use &amp;quot;&amp;lt;tt&amp;gt;textures/common/rendermodel_clip&amp;lt;/tt&amp;gt;&amp;quot; to make sure it collides with only bullets (more info at the bottom of this page).&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Collision Model Tips ==&lt;br /&gt;
* You do not have to create separate meshes for the vehicles, players and bullet collision if you don't want to. You can create a single optimised collision mesh and use the &amp;quot;&amp;lt;tt&amp;gt;textures/common/collision&amp;lt;/tt&amp;gt;&amp;quot; material.&lt;br /&gt;
* Unlike shadow hulls, collision meshes do not have to be &amp;quot;watertight&amp;quot;, open edges are allowed. However, bear in mind that things in the game will only collide with front-facing polys, so a single flat plane would only have collision on one side of it.&lt;br /&gt;
* Collision meshes are automatically optimised by the game to use polygons rather than triangles. Therefore, co-planar triangles will be optimised down into a single ''n''-sided polygon, for efficiency and performance.&lt;br /&gt;
** As an example, while a simple cube is rendered using 12 three-sided polygons (triangls), the collision optimisation will read it as 6 four-sided polygons (quads).&lt;br /&gt;
* As soon as you add any collision materials to your model file, any non-collision materials will be treated as nonsolid. Therefore, if you only add a player_clip mesh to your model, you will find that vehicles and bullets still pass through.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Valid Collision Materials ==&lt;br /&gt;
----&lt;br /&gt;
The surface type of each material is denoted by the suffix (eg. ''_metal'' for metal sound and particle effects).&lt;br /&gt;
Where no surface type suffix is specified, default effects will be used, which usually look and sound like concrete.&lt;br /&gt;
&lt;br /&gt;
=== Generic Collision ===&lt;br /&gt;
Vehicles, players, bullets and projectiles will all collide with this material. Nothing passes through.&lt;br /&gt;
* &amp;lt;tt&amp;gt;textures/common/collision&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;textures/common/collision_wood&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;textures/common/collision_metal&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;textures/common/collision_concrete&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Vehicle &amp;amp; Player Collision ===&lt;br /&gt;
Vehicles and players will collide with this material. Projectiles and bullets will pass through.&lt;br /&gt;
* &amp;lt;tt&amp;gt;textures/common/vehicleplayer_clip&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;textures/common/vehicleplayer_clip_metal&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;textures/common/vehicleplayer_clip_wood&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;textures/common/vehicleplayer_clip_concrete&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;textures/common/vehicleplayer_clip_glass&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;textures/common/vehicleplayer_clip_snow&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Player Collision ===&lt;br /&gt;
Only players will collide with this material. Vehicles, projectiles and bullets will pass through.&lt;br /&gt;
* &amp;lt;tt&amp;gt;textures/common/player_clip&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;textures/common/player_clip_metal&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;textures/common/player_clip_wood&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;textures/common/player_clip_concrete&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;textures/common/player_clip_glass&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Vehicle Collision ===&lt;br /&gt;
Only vehicles will collide with this material. Players, projectiles and bullets will pass through.&lt;br /&gt;
* &amp;lt;tt&amp;gt;textures/common/vehicle_clip&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;textures/common/vehicle_clip_metal&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;textures/common/vehicle_clip_wood&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;textures/common/vehicle_clip_concrete&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;textures/common/vehicle_clip_snow&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== &amp;quot;Rendermodel&amp;quot; Collision ===&lt;br /&gt;
Bullets and projectiles (and flyer drones!) will collide with this material. Players and vehicles will pass through.&lt;br /&gt;
* &amp;lt;tt&amp;gt;textures/common/rendermodel_clip&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;textures/common/rendermodel_clip_metal&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;textures/common/rendermodel_clip_wood&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;textures/common/rendermodel_clip_concrete&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;textures/common/rendermodel_clip_glass&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Special Collision Types ===&lt;br /&gt;
* &amp;lt;tt&amp;gt;textures/common/projectile_clip&amp;lt;/tt&amp;gt; - Allows bullets to pass through, but not projectiles (eg. rockets and tank shells).&lt;br /&gt;
&lt;br /&gt;
[[Category:Models]]&lt;br /&gt;
&amp;lt;/noinclude&amp;gt;&lt;/div&gt;</summary>
		<author><name>Ducks</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.splashdamage.com/index.php?title=Portal_Basics&amp;diff=4083</id>
		<title>Portal Basics</title>
		<link rel="alternate" type="text/html" href="https://wiki.splashdamage.com/index.php?title=Portal_Basics&amp;diff=4083"/>
		<updated>2008-01-02T15:16:29Z</updated>

		<summary type="html">&lt;p&gt;Ducks: /* playzoneportal */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Portals are not teleporters!'''&lt;br /&gt;
&lt;br /&gt;
Portals are used to reduce the amount of work the renderer has to do. In essence, a portal is a window into an area of a map; if the renderer can not see a portal into an area of the map, it knows the area behind the portal can not be seen by the player either, and therefore does not need to render it. Similarly, if the player is very far from the portal, such that it only uses a few pixels on the screen, the renderer knows it's not worth rendering the area behind it.&lt;br /&gt;
&lt;br /&gt;
The important thing to understand is that portals are only useful when used to distinguish separate areas, and when the area they hide is complex enough to make it worth not rendering. Hence portals are usually created in doorways or entryways that are crucial for the player to get from one part of the map to another.&lt;br /&gt;
&lt;br /&gt;
There are several types of portals. 'Visportals' are the most basic and simply won't render the area behind it when it itself isn't on-screen (or is too small to be considered worth rendering). Other portals are used to control the flow of light and to alter the ambient lighting within the different interior sections of maps. However, all portals are created in the same way and follow the same basic rules.&lt;br /&gt;
&lt;br /&gt;
== Creating a portal ==&lt;br /&gt;
A portal is created by assigning all but one face of a brush the [[Common Textures#common/nodraw|nodraw]] texture. The remaining face should be given the portal texture ([[Common Textures#common/visportal|visportal]], [[Common Textures#common/outsideportal|outsideportal]], or [[Common Textures|otherwise]].) The face with the chosen portal should cut completely through the area to be portalled - that is, the portal-textured face should touch ceiling, floor, and walls on both sides. Usually, this means portals are rectangular.&lt;br /&gt;
&lt;br /&gt;
'''Patches may not be used for portals. Portals must be completely flat.'''&lt;br /&gt;
&lt;br /&gt;
[[Image:Portals_goodbad.jpg|frame|none|How to set up a simple portal correctly.]]&lt;br /&gt;
&lt;br /&gt;
It is also important to note that '''portals must completely seal areas from each other'''. So if you have two rooms joined by three doorways, if you add a portal to one doorway, you need to add a portal to the other two doorways as well. In other words, it should be impossible to look at one side of a portal and then look at the other side without needing to pass through a portal to do so.&lt;br /&gt;
&lt;br /&gt;
== Portal types ==&lt;br /&gt;
&lt;br /&gt;
=== visportal ===&lt;br /&gt;
* Texture: &amp;lt;tt&amp;gt;[[Common Textures#editor/visportal|/editor/visportal]]&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The most common portal, used to hide areas of a map that should not be rendered when the portal is not in view. Note how the green visportal texture is placed in doorways - when those doorways are not in view, the areas behind them will not be rendered. Also note how the purple 'nodraw' texture in the first screenshot is actually the backside of the bigger portal in the second screenshot.&lt;br /&gt;
&lt;br /&gt;
[[Image:P_vis1.jpg|frame|left|visportal placement in Sewer]] [[Image:P_vis2.jpg|frame|left|visportal placement in Sewer]]&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
==== Uses ====&lt;br /&gt;
Visportals serve two main purposes:&lt;br /&gt;
# They can reduce the number of polygons that need to be drawn, hence&lt;br /&gt;
# They can reduce the number of textures that need to be in memory&lt;br /&gt;
&lt;br /&gt;
The combination of these means that portals can lead to significant performance gains, as the renderer has less work to do. Hence some areas can use more detail than normal, knowing the additional detail will be culled away by portals when not in sight. Conversely, portals can also make the game more accessible on lower-spec machines as the renderer knows which areas can be safely culled without affecting the experience for the user.&lt;br /&gt;
&lt;br /&gt;
The difficulty is placing portals and geometry appropriately. If placed badly, it can mean that two high-detail areas are in view at the same time, so the engine renders many more polygons and uses more texture memory, in some cases leading to a sudden decrease in performance.&lt;br /&gt;
&lt;br /&gt;
=== ambientportal ===&lt;br /&gt;
* Texture: &amp;lt;tt&amp;gt;[[Common Textures#editor/ambientportal|/editor/ambientportal]]&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Used to separate ambient lighting areas defined by [[Entity light_ambient|light_ambient]] entities.&lt;br /&gt;
&lt;br /&gt;
=== audioportal ===&lt;br /&gt;
* Texture: &amp;lt;tt&amp;gt;/textures/editor/audioportal&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Used to separate areas of sound, for example to make sure the sound of machinery in one room doesn't leak into an adjacent room.&lt;br /&gt;
&lt;br /&gt;
=== aasclusterportal ===&lt;br /&gt;
* Texture: &amp;lt;tt&amp;gt;/textures/common/aasclusterportal&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Distinguishes to areas for AAS generation purposes. &lt;br /&gt;
&lt;br /&gt;
=== outsideportal ===&lt;br /&gt;
* Texture: &amp;lt;tt&amp;gt;[[Common Textures#editor/outsideportal|/textures/editor/outsideportal]]&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Used to separate the inside (indoors) and outside (outdoors) of a level, in order to control light (and shadow) from sunlight.&lt;br /&gt;
&lt;br /&gt;
=== playzoneportal ===&lt;br /&gt;
* Texture: &amp;lt;tt&amp;gt;/textures/editor/playzoneportal&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Used to separate different parts of a map and their playzone markers. For example, these can be used to assign different playzones to separate parts of a building.&lt;br /&gt;
&amp;lt;!-- what a rubbish description - dj --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Developer Commands ==&lt;br /&gt;
[[Image:Portals_showportals.jpg|frame|left|r_showPortals in action]]&lt;br /&gt;
* {{consolecmd|r_showPortals 0/1/2/3}} - turns on rendering of portal outlines so it's possible to see which portals are active (rendered green) and which are not (rendered red). This is a good command to use to help understand how portals work and where they are placed in other maps. Setting {{consolecmd|r_showPortals 3}} displays what type each portal is.&lt;br /&gt;
* {{consolecmd|r_usePortals 0/1}} - turns on/off portals (when turned off, everything is drawn, whether it is visible or not)&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
== Additional Resources ==&lt;br /&gt;
* [http://www.iddevnet.com/doom3/visportals.php Vis Portals] - a good overview of visportals and explanation of how they work&lt;br /&gt;
* [http://www.modwiki.net/wiki/Visportal Visportal topic on modwiki] - a slightly simpler explanation&lt;br /&gt;
&lt;br /&gt;
[[Category:Basic Level Design]]&lt;/div&gt;</summary>
		<author><name>Ducks</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.splashdamage.com/index.php?title=Portal_Basics&amp;diff=4082</id>
		<title>Portal Basics</title>
		<link rel="alternate" type="text/html" href="https://wiki.splashdamage.com/index.php?title=Portal_Basics&amp;diff=4082"/>
		<updated>2008-01-02T15:16:19Z</updated>

		<summary type="html">&lt;p&gt;Ducks: /* playzoneportal */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Portals are not teleporters!'''&lt;br /&gt;
&lt;br /&gt;
Portals are used to reduce the amount of work the renderer has to do. In essence, a portal is a window into an area of a map; if the renderer can not see a portal into an area of the map, it knows the area behind the portal can not be seen by the player either, and therefore does not need to render it. Similarly, if the player is very far from the portal, such that it only uses a few pixels on the screen, the renderer knows it's not worth rendering the area behind it.&lt;br /&gt;
&lt;br /&gt;
The important thing to understand is that portals are only useful when used to distinguish separate areas, and when the area they hide is complex enough to make it worth not rendering. Hence portals are usually created in doorways or entryways that are crucial for the player to get from one part of the map to another.&lt;br /&gt;
&lt;br /&gt;
There are several types of portals. 'Visportals' are the most basic and simply won't render the area behind it when it itself isn't on-screen (or is too small to be considered worth rendering). Other portals are used to control the flow of light and to alter the ambient lighting within the different interior sections of maps. However, all portals are created in the same way and follow the same basic rules.&lt;br /&gt;
&lt;br /&gt;
== Creating a portal ==&lt;br /&gt;
A portal is created by assigning all but one face of a brush the [[Common Textures#common/nodraw|nodraw]] texture. The remaining face should be given the portal texture ([[Common Textures#common/visportal|visportal]], [[Common Textures#common/outsideportal|outsideportal]], or [[Common Textures|otherwise]].) The face with the chosen portal should cut completely through the area to be portalled - that is, the portal-textured face should touch ceiling, floor, and walls on both sides. Usually, this means portals are rectangular.&lt;br /&gt;
&lt;br /&gt;
'''Patches may not be used for portals. Portals must be completely flat.'''&lt;br /&gt;
&lt;br /&gt;
[[Image:Portals_goodbad.jpg|frame|none|How to set up a simple portal correctly.]]&lt;br /&gt;
&lt;br /&gt;
It is also important to note that '''portals must completely seal areas from each other'''. So if you have two rooms joined by three doorways, if you add a portal to one doorway, you need to add a portal to the other two doorways as well. In other words, it should be impossible to look at one side of a portal and then look at the other side without needing to pass through a portal to do so.&lt;br /&gt;
&lt;br /&gt;
== Portal types ==&lt;br /&gt;
&lt;br /&gt;
=== visportal ===&lt;br /&gt;
* Texture: &amp;lt;tt&amp;gt;[[Common Textures#editor/visportal|/editor/visportal]]&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The most common portal, used to hide areas of a map that should not be rendered when the portal is not in view. Note how the green visportal texture is placed in doorways - when those doorways are not in view, the areas behind them will not be rendered. Also note how the purple 'nodraw' texture in the first screenshot is actually the backside of the bigger portal in the second screenshot.&lt;br /&gt;
&lt;br /&gt;
[[Image:P_vis1.jpg|frame|left|visportal placement in Sewer]] [[Image:P_vis2.jpg|frame|left|visportal placement in Sewer]]&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
==== Uses ====&lt;br /&gt;
Visportals serve two main purposes:&lt;br /&gt;
# They can reduce the number of polygons that need to be drawn, hence&lt;br /&gt;
# They can reduce the number of textures that need to be in memory&lt;br /&gt;
&lt;br /&gt;
The combination of these means that portals can lead to significant performance gains, as the renderer has less work to do. Hence some areas can use more detail than normal, knowing the additional detail will be culled away by portals when not in sight. Conversely, portals can also make the game more accessible on lower-spec machines as the renderer knows which areas can be safely culled without affecting the experience for the user.&lt;br /&gt;
&lt;br /&gt;
The difficulty is placing portals and geometry appropriately. If placed badly, it can mean that two high-detail areas are in view at the same time, so the engine renders many more polygons and uses more texture memory, in some cases leading to a sudden decrease in performance.&lt;br /&gt;
&lt;br /&gt;
=== ambientportal ===&lt;br /&gt;
* Texture: &amp;lt;tt&amp;gt;[[Common Textures#editor/ambientportal|/editor/ambientportal]]&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Used to separate ambient lighting areas defined by [[Entity light_ambient|light_ambient]] entities.&lt;br /&gt;
&lt;br /&gt;
=== audioportal ===&lt;br /&gt;
* Texture: &amp;lt;tt&amp;gt;/textures/editor/audioportal&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Used to separate areas of sound, for example to make sure the sound of machinery in one room doesn't leak into an adjacent room.&lt;br /&gt;
&lt;br /&gt;
=== aasclusterportal ===&lt;br /&gt;
* Texture: &amp;lt;tt&amp;gt;/textures/common/aasclusterportal&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Distinguishes to areas for AAS generation purposes. &lt;br /&gt;
&lt;br /&gt;
=== outsideportal ===&lt;br /&gt;
* Texture: &amp;lt;tt&amp;gt;[[Common Textures#editor/outsideportal|/textures/editor/outsideportal]]&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Used to separate the inside (indoors) and outside (outdoors) of a level, in order to control light (and shadow) from sunlight.&lt;br /&gt;
&lt;br /&gt;
=== playzoneportal ===&lt;br /&gt;
* Texture: &amp;lt;tt&amp;gt;/textures/editor/playzoneportal&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Used to separate different parts of a map and their playzone markers. For example, these can be used to assign different playzones to separate parts of a building.&lt;br /&gt;
/* what a rubbish description - dj */&lt;br /&gt;
&lt;br /&gt;
== Developer Commands ==&lt;br /&gt;
[[Image:Portals_showportals.jpg|frame|left|r_showPortals in action]]&lt;br /&gt;
* {{consolecmd|r_showPortals 0/1/2/3}} - turns on rendering of portal outlines so it's possible to see which portals are active (rendered green) and which are not (rendered red). This is a good command to use to help understand how portals work and where they are placed in other maps. Setting {{consolecmd|r_showPortals 3}} displays what type each portal is.&lt;br /&gt;
* {{consolecmd|r_usePortals 0/1}} - turns on/off portals (when turned off, everything is drawn, whether it is visible or not)&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
== Additional Resources ==&lt;br /&gt;
* [http://www.iddevnet.com/doom3/visportals.php Vis Portals] - a good overview of visportals and explanation of how they work&lt;br /&gt;
* [http://www.modwiki.net/wiki/Visportal Visportal topic on modwiki] - a slightly simpler explanation&lt;br /&gt;
&lt;br /&gt;
[[Category:Basic Level Design]]&lt;/div&gt;</summary>
		<author><name>Ducks</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.splashdamage.com/index.php?title=User:Ducks/A_Simple_First_Mod&amp;diff=4079</id>
		<title>User:Ducks/A Simple First Mod</title>
		<link rel="alternate" type="text/html" href="https://wiki.splashdamage.com/index.php?title=User:Ducks/A_Simple_First_Mod&amp;diff=4079"/>
		<updated>2007-12-18T12:08:29Z</updated>

		<summary type="html">&lt;p&gt;Ducks: /* See Also */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is the barebones guide for creating a simple mod. It won't be a terrifically amazing mod, since it will just be ETQW with a few small changes, but it will demonstrate the basic principles.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
ETQW allows for a wide range of modifications, simply through the editing of its Definition Files (.def) and Script Files (.script). These files determine the basic properties and behaviours of almost everything that happens in-game, and can be easily edited for the creation of ETQW mods.&lt;br /&gt;
&lt;br /&gt;
'''For this tutorial you must:'''&lt;br /&gt;
* Have your SDK Launcher set up correctly&lt;br /&gt;
* Have a good text-editor, such as Notepad&lt;br /&gt;
* Have some scripting/programming knowledge&lt;br /&gt;
&lt;br /&gt;
'''This tutorial covers:'''&lt;br /&gt;
* How to create your own mod&lt;br /&gt;
* How to modify ETQW's .def files to change rockets&lt;br /&gt;
* How to modify ETQW's .script files to give infinite ammo&lt;br /&gt;
* How to package up your mod for release&lt;br /&gt;
&lt;br /&gt;
'''This tutorial does not:'''&lt;br /&gt;
* Teach you how to program scripts or edit/compile the game code&lt;br /&gt;
&lt;br /&gt;
== Basic setup ==&lt;br /&gt;
First, we need to create the mod folder for all the files our mod will use. When you want to send your mod to someone else, all you'll need to send them is the folder, which they can then place in their ETQW directory.&lt;br /&gt;
&lt;br /&gt;
The SDK Launcher includes a button to set this up for you - the 'Create...' button. Press this, and it will ask for a mod name  (preferably no spaces, like 'simplemod') and a description. Our mod is going to be called 'simplemod', described as 'a simple mod'. &lt;br /&gt;
&lt;br /&gt;
This will have created a directory in your ETQW directory called 'simplemod'. &lt;br /&gt;
&lt;br /&gt;
== Definition files (.def) ==&lt;br /&gt;
ETQW uses .def files to store information and settings for various items, weapons and objects. The SDK has a full collection of all these files in {{filename|\SDK 1.2 Beta\base\def\}}. For example, the definition file for the GDF Rocket Launcher is {{filename|\SDK 1.2 Beta\base\def\weapons\rocketlauncher.def}}. If you open this file in Notepad, you'll see a section about models, a section about animations, and then a section containing lots of different numbers. These settings can be used to change properties of the rocket launcher, rockets, and damage values.&lt;br /&gt;
&lt;br /&gt;
These files are typically split into many sections. In the case of the Rocket Launcher file, there are '&amp;lt;tt&amp;gt;invItemDef&amp;lt;/tt&amp;gt;'  sections near the top that define models and animations for the player's inventory. Later in the file there are '&amp;lt;tt&amp;gt;entityDef&amp;lt;/tt&amp;gt;' which contain entity definitions, and all the numbers and values that can be tweaked with.&lt;br /&gt;
&lt;br /&gt;
For example, under '&amp;lt;tt&amp;gt;entityDef projectile_law&amp;lt;/tt&amp;gt;' are all the values for seeking rockets, such as the velocity it flies at ({{keyvalue|4000 0 0}}, which means 'forward at 4000 units a second'), how long its fuse is ({{keyvalue|3}}, which means 'explode after 3 seconds if it hasn't hit anything'), and gravity ({{keyvalue|0}}, which means 'unaffected by gravity').&lt;br /&gt;
&lt;br /&gt;
There's also '&amp;lt;tt&amp;gt;entityDef projectile_law_arcing&amp;lt;/tt&amp;gt;', which are the values for the non-seeking rocket, which arcs through the air because it has a {{keyname|gravity}} setting of {{keyvalue|120}}.&lt;br /&gt;
&lt;br /&gt;
What we're going to do is change the entity definition for the arcing rocket so it travels really slowly, lasts really long, and isn't affected by gravity (so it won't arc.)&lt;br /&gt;
&lt;br /&gt;
=== Copying ===&lt;br /&gt;
First, we need to know which file contains the entity data we want to change - in this case, it's {{filename|\SDK 1.2 Beta\base\def\weapons\rocketlauncher.def}}. However, we shouldn't modify this file, as it's the one from the SDK and is in the wrong place for our mod. Instead, it should be copied to the 'simplemod' folder.&lt;br /&gt;
&lt;br /&gt;
So copy {{filename|\SDK 1.2 Beta\base\def\weapons\rocketlauncher.def}} to {{filename|\simplemod\def\weapons\rocketlauncher.def}} (you'll need to create the 'def' and 'weapons' folders yourself.)&lt;br /&gt;
&lt;br /&gt;
This means that when simplemod is run, although ETQW will still load all its normal files, it will see that simplemod has its own {{filename|rocketlauncher.def}} and will use that one instead of the one that comes with the game.&lt;br /&gt;
&lt;br /&gt;
=== Editing ===&lt;br /&gt;
Now open {{filename|\simplemod\def\weapons\rocketlauncher.def}} in Notepad, and find the section for the entity 'projectile_law_arcing'. It'll look like this:&lt;br /&gt;
&lt;br /&gt;
 entityDef projectile_law_arcing {&lt;br /&gt;
 	&amp;quot;inherit&amp;quot;			&amp;quot;projectile_rocket_base&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 	&amp;quot;dmg_damage&amp;quot;			&amp;quot;damage_law&amp;quot;&lt;br /&gt;
 	&amp;quot;dmg_splash_damage&amp;quot;		&amp;quot;damage_law_splash&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 	&amp;quot;launchFromBarrel&amp;quot;		&amp;quot;1&amp;quot;&lt;br /&gt;
 	&amp;quot;health&amp;quot;			&amp;quot;0&amp;quot;&lt;br /&gt;
 	&amp;quot;velocity&amp;quot;			&amp;quot;2000 0 0&amp;quot;&lt;br /&gt;
 	&amp;quot;face_velocity&amp;quot;			&amp;quot;1&amp;quot;&lt;br /&gt;
 	&amp;quot;gravity&amp;quot;			&amp;quot;120&amp;quot;&lt;br /&gt;
 	&amp;quot;fuse&amp;quot;				&amp;quot;4&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 	&amp;quot;snd_fly&amp;quot;			&amp;quot;sounds/weapons/law/fly&amp;quot;&lt;br /&gt;
   	&amp;quot;fx_trail&amp;quot;			&amp;quot;effects/base/missile_trail&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 	&amp;quot;fx_explode&amp;quot;			&amp;quot;effects/impacts/rocket/explosion_default&amp;quot;&lt;br /&gt;
 	&amp;quot;fx_explode_sand&amp;quot;		&amp;quot;effects/impacts/rocket/explosion_sand&amp;quot;&lt;br /&gt;
 	&amp;quot;fx_explode_metal&amp;quot;		&amp;quot;effects/impacts/rocket/explosion_metal&amp;quot;&lt;br /&gt;
 	&amp;quot;fx_explode_snow&amp;quot;		&amp;quot;effects/impacts/rocket/explosion_snow&amp;quot;&lt;br /&gt;
 	&lt;br /&gt;
 	&amp;quot;use_air_burst&amp;quot;			&amp;quot;1&amp;quot;&lt;br /&gt;
 	&amp;quot;fx_airburst&amp;quot;			&amp;quot;effects/impacts/rocket/explosion_air&amp;quot;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
We're going to change the rocket so it travels really slowly in a straight line.&lt;br /&gt;
&lt;br /&gt;
First to make it slower, change the {{keyname|velocity}} setting from {{keyvalue|2000 0 0}} to {{keyvalue|100 0 0}}, so it only travels 100 units a second.&lt;br /&gt;
&lt;br /&gt;
Next, change {{keyname|gravity}} from {{keyvalue|120}} to {{keyvalue|0}}, so isn't pulled down by gravity while in the air.&lt;br /&gt;
&lt;br /&gt;
Lastly, change {{keyname|fuse}} from {{keyvalue|4}} to {{keyvalue|30}}, so it'll last 30 seconds before it explodes (unless it hits something first)&lt;br /&gt;
&lt;br /&gt;
This is the result:&lt;br /&gt;
&lt;br /&gt;
 entityDef projectile_law_arcing {&lt;br /&gt;
 	&amp;quot;inherit&amp;quot;			&amp;quot;projectile_rocket_base&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 	&amp;quot;dmg_damage&amp;quot;			&amp;quot;damage_law&amp;quot;&lt;br /&gt;
 	&amp;quot;dmg_splash_damage&amp;quot;		&amp;quot;damage_law_splash&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 	&amp;quot;launchFromBarrel&amp;quot;		&amp;quot;1&amp;quot;&lt;br /&gt;
 	&amp;quot;health&amp;quot;			&amp;quot;0&amp;quot;&lt;br /&gt;
 	'''&amp;quot;velocity&amp;quot;			&amp;quot;100 0 0&amp;quot;'''&lt;br /&gt;
 	&amp;quot;face_velocity&amp;quot;			&amp;quot;1&amp;quot;&lt;br /&gt;
 	'''&amp;quot;gravity&amp;quot;			&amp;quot;0&amp;quot;'''&lt;br /&gt;
 	'''&amp;quot;fuse&amp;quot;				&amp;quot;30&amp;quot;'''&lt;br /&gt;
 &lt;br /&gt;
 	&amp;quot;snd_fly&amp;quot;			&amp;quot;sounds/weapons/law/fly&amp;quot;&lt;br /&gt;
   	&amp;quot;fx_trail&amp;quot;			&amp;quot;effects/base/missile_trail&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 	&amp;quot;fx_explode&amp;quot;			&amp;quot;effects/impacts/rocket/explosion_default&amp;quot;&lt;br /&gt;
 	&amp;quot;fx_explode_sand&amp;quot;		&amp;quot;effects/impacts/rocket/explosion_sand&amp;quot;&lt;br /&gt;
 	&amp;quot;fx_explode_metal&amp;quot;		&amp;quot;effects/impacts/rocket/explosion_metal&amp;quot;&lt;br /&gt;
 	&amp;quot;fx_explode_snow&amp;quot;		&amp;quot;effects/impacts/rocket/explosion_snow&amp;quot;&lt;br /&gt;
 	&lt;br /&gt;
 	&amp;quot;use_air_burst&amp;quot;			&amp;quot;1&amp;quot;&lt;br /&gt;
 	&amp;quot;fx_airburst&amp;quot;			&amp;quot;effects/impacts/rocket/explosion_air&amp;quot;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=== Testing ===&lt;br /&gt;
[[Image:simplemod_slowrocket.jpg|400px|thumb|right|A slow rocket, courtesy of editing the rocketlauncher.def file]]&lt;br /&gt;
We can test this change by loading the mod via the SDK Launcher (ensuring 'simplemod' is selected) and then loading any map via {{consolecmd|devmap}}, for example {{consolecmd|devmap island}}.&lt;br /&gt;
&lt;br /&gt;
Once the map is loaded, join the GDF team as a Soldier with the rocket launcher (as that's the only weapon changed by the above file.) If you now fire a non-seeking rocket, you should find it travels very slowly, in a straight line, and lasts 30 seconds before it explodes (unless it hits something first), allowing you to run around and inspect it while it's still in the air.&lt;br /&gt;
&lt;br /&gt;
''If you edit a .def file while the game is running, use {{consolecmd|reloadDecls}} to force the game to reload all definition files. This allows you to see what effect your changes had on the game, without needing to restart it.''&lt;br /&gt;
&lt;br /&gt;
''Be aware that for edited declarations to work, you should ensure the following cvar is set {{consolecmd|com_useBinaryDecls 2}}, which forces to engine to load your .def files rather then the binary ones shipped with the game.''&lt;br /&gt;
&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
== Script Files (.script) ==&lt;br /&gt;
Although definition files contain settings and values of entities, they can't change the ''behaviour'' of entities. For this, you need to edit script files; all weapons, vehicles, items and projectiles are defined with script files. Script files present a 'high-level' way to access the mechanics of the game, and can be modified while the game is running.&lt;br /&gt;
&lt;br /&gt;
''Script files are not be be confused with game code, which is programmed in C++ and contains all the low-level game behaviour. Many mods can be created entirely through script files. Note however that script files may be converted to C++ and compiled into a DLL for performance, but is not covered in this tutorial.''&lt;br /&gt;
&lt;br /&gt;
ETQW's scripts can be found in {{filename|\SDK 1.2 Beta\base\script\}}, and since they are normal text documents, can be opened in Notepad or any other text editor.&lt;br /&gt;
&lt;br /&gt;
The most important files here are {{filename|events.script}} (which defines game code methods that are callable from script files), and the {{filename|base.script}} files in each directory. &lt;br /&gt;
&lt;br /&gt;
For this bit of scripting, we're going to change the weapon script so weapons don't use up any ammo when they're fired.&lt;br /&gt;
&lt;br /&gt;
=== Copying ===&lt;br /&gt;
First, we need to know which file to modify - in this case, it's {{filename|\SDK 1.2 Beta\base\script\weapons\base.script}}, which contains the basic behaviours shared by all weapons used in the game. However, just like .def files, we shouldn't modify this file, as it's the one from the SDK. Instead, it should be copied to {{filename|simplemod\script\weapons\base.script}}, so it's specific to our mod.&lt;br /&gt;
&lt;br /&gt;
=== Examining ===&lt;br /&gt;
A cursory glance at this script shows that there are two methods related to ammo use - '&amp;lt;tt&amp;gt;UseAmmo&amp;lt;/tt&amp;gt;' and '&amp;lt;tt&amp;gt;UseAmmo_Stroyent&amp;lt;/tt&amp;gt;' - which are both called with a &amp;lt;tt&amp;gt;modIndex&amp;lt;/tt&amp;gt; parameter indicating what sort of ammo to be consumed.&lt;br /&gt;
&lt;br /&gt;
 void weapon_base::UseAmmo( float modIndex ) {&lt;br /&gt;
 	if ( sys.isClient() ) {&lt;br /&gt;
 		return;&lt;br /&gt;
 	}&lt;br /&gt;
 &lt;br /&gt;
 	float amount = ammoRequired( modIndex );&lt;br /&gt;
 	useAmmo( ammoType( modIndex ), amount );&lt;br /&gt;
 	addToClip( modIndex, -amount );&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void weapon_base::UseAmmo_Stroyent( float modIndex ) {&lt;br /&gt;
 	if ( sys.isClient() ) {&lt;br /&gt;
 		return;&lt;br /&gt;
 	}&lt;br /&gt;
 &lt;br /&gt;
 	float amount = ammoRequired( modIndex );&lt;br /&gt;
 	useAmmo( ammoType( modIndex ), amount );&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Both these methods call a few functions defined by the (C++) game code, specifically '&amp;lt;tt&amp;gt;sys.isClient&amp;lt;/tt&amp;gt;', '&amp;lt;tt&amp;gt;ammoRequired&amp;lt;/tt&amp;gt;', '&amp;lt;tt&amp;gt;useAmmo&amp;lt;/tt&amp;gt;' and '&amp;lt;tt&amp;gt;addToClip&amp;lt;/tt&amp;gt;'. We know this because these functions aren't defined in this .script file, but are present in the {{filename|events.script}} file, defined as '&amp;lt;tt&amp;gt;scriptEvent&amp;lt;/tt&amp;gt;' functions.&lt;br /&gt;
&lt;br /&gt;
=== Editing ===&lt;br /&gt;
For infinite ammo, the .script simply needs to be edited so the '&amp;lt;tt&amp;gt;useAmmo&amp;lt;/tt&amp;gt;' and '&amp;lt;tt&amp;gt;addToClip&amp;lt;/tt&amp;gt;' functions never get called. This can be done a number of ways, but the simplest is for these two '&amp;lt;tt&amp;gt;UseAmmo&amp;lt;/tt&amp;gt;' methods to simply do nothing:&lt;br /&gt;
&lt;br /&gt;
 void weapon_base::UseAmmo( float modIndex ) {&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void weapon_base::UseAmmo_Stroyent( float modIndex ) {&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
''This could be achieved in a large number of different ways, from simply commenting out the code using standard C/C++ comment syntax, or just adding a &amp;lt;tt&amp;gt;return&amp;lt;/tt&amp;gt; at the top of the method.''&lt;br /&gt;
&lt;br /&gt;
=== Testing ===&lt;br /&gt;
To test the script we first need to make ETQW reload the script files. This is done with {{consolecmd|reloadScript}}, which usually takes a few seconds, and means we can continue editing .script files in the background without having to quit and reload the game each time. If there are any errors or problems with the script, the ETQW console will list these problems for debugging/fixing.&lt;br /&gt;
&lt;br /&gt;
If the script is compiled successfully, a message such as '&amp;lt;tt&amp;gt;Compiled 'script/main.script': 13141.5 ms&amp;lt;/tt&amp;gt;' will be displayed.&lt;br /&gt;
&lt;br /&gt;
''Note that for scripts to work, the following cvar must be set: {{consolecmd|g_useCompiledScript 1}}''&lt;br /&gt;
&lt;br /&gt;
=== Compiling ===&lt;br /&gt;
Thanks to ETQW's built-in interpreter, scripts can be changed and tested very rapidly. However, for the final release of a mod, is is much preferable to compile the scripts into a {{filename|compiledscriptx86.dll}}, which will run much faster.&lt;br /&gt;
&lt;br /&gt;
Compiling scripts requires the additional setup of a compiler, and so is not covered in this tutorial.&lt;br /&gt;
&lt;br /&gt;
* See [[Generating Compiled Scripts]] for further information.&lt;br /&gt;
&lt;br /&gt;
== Packaging your mod ==&lt;br /&gt;
Mods can be packaged in a number of ways, but the simplest is to simply send your mod folder (in this case 'simplemod') to other people who want to run your mod, so they have the same folders and files as you.&lt;br /&gt;
&lt;br /&gt;
Alternatively, all the files inside 'simplemod' can be zipped up and renamed to a PK4 file (e.g. 'simplemod001.pk4'). This is neater and tidier.&lt;br /&gt;
&lt;br /&gt;
'''TODO'''&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
* [[Packaging up a Map or Mod]]&lt;/div&gt;</summary>
		<author><name>Ducks</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.splashdamage.com/index.php?title=User:Ducks/A_Simple_First_Mod&amp;diff=4078</id>
		<title>User:Ducks/A Simple First Mod</title>
		<link rel="alternate" type="text/html" href="https://wiki.splashdamage.com/index.php?title=User:Ducks/A_Simple_First_Mod&amp;diff=4078"/>
		<updated>2007-12-18T12:08:18Z</updated>

		<summary type="html">&lt;p&gt;Ducks: /* Packaging your mod */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is the barebones guide for creating a simple mod. It won't be a terrifically amazing mod, since it will just be ETQW with a few small changes, but it will demonstrate the basic principles.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
ETQW allows for a wide range of modifications, simply through the editing of its Definition Files (.def) and Script Files (.script). These files determine the basic properties and behaviours of almost everything that happens in-game, and can be easily edited for the creation of ETQW mods.&lt;br /&gt;
&lt;br /&gt;
'''For this tutorial you must:'''&lt;br /&gt;
* Have your SDK Launcher set up correctly&lt;br /&gt;
* Have a good text-editor, such as Notepad&lt;br /&gt;
* Have some scripting/programming knowledge&lt;br /&gt;
&lt;br /&gt;
'''This tutorial covers:'''&lt;br /&gt;
* How to create your own mod&lt;br /&gt;
* How to modify ETQW's .def files to change rockets&lt;br /&gt;
* How to modify ETQW's .script files to give infinite ammo&lt;br /&gt;
* How to package up your mod for release&lt;br /&gt;
&lt;br /&gt;
'''This tutorial does not:'''&lt;br /&gt;
* Teach you how to program scripts or edit/compile the game code&lt;br /&gt;
&lt;br /&gt;
== Basic setup ==&lt;br /&gt;
First, we need to create the mod folder for all the files our mod will use. When you want to send your mod to someone else, all you'll need to send them is the folder, which they can then place in their ETQW directory.&lt;br /&gt;
&lt;br /&gt;
The SDK Launcher includes a button to set this up for you - the 'Create...' button. Press this, and it will ask for a mod name  (preferably no spaces, like 'simplemod') and a description. Our mod is going to be called 'simplemod', described as 'a simple mod'. &lt;br /&gt;
&lt;br /&gt;
This will have created a directory in your ETQW directory called 'simplemod'. &lt;br /&gt;
&lt;br /&gt;
== Definition files (.def) ==&lt;br /&gt;
ETQW uses .def files to store information and settings for various items, weapons and objects. The SDK has a full collection of all these files in {{filename|\SDK 1.2 Beta\base\def\}}. For example, the definition file for the GDF Rocket Launcher is {{filename|\SDK 1.2 Beta\base\def\weapons\rocketlauncher.def}}. If you open this file in Notepad, you'll see a section about models, a section about animations, and then a section containing lots of different numbers. These settings can be used to change properties of the rocket launcher, rockets, and damage values.&lt;br /&gt;
&lt;br /&gt;
These files are typically split into many sections. In the case of the Rocket Launcher file, there are '&amp;lt;tt&amp;gt;invItemDef&amp;lt;/tt&amp;gt;'  sections near the top that define models and animations for the player's inventory. Later in the file there are '&amp;lt;tt&amp;gt;entityDef&amp;lt;/tt&amp;gt;' which contain entity definitions, and all the numbers and values that can be tweaked with.&lt;br /&gt;
&lt;br /&gt;
For example, under '&amp;lt;tt&amp;gt;entityDef projectile_law&amp;lt;/tt&amp;gt;' are all the values for seeking rockets, such as the velocity it flies at ({{keyvalue|4000 0 0}}, which means 'forward at 4000 units a second'), how long its fuse is ({{keyvalue|3}}, which means 'explode after 3 seconds if it hasn't hit anything'), and gravity ({{keyvalue|0}}, which means 'unaffected by gravity').&lt;br /&gt;
&lt;br /&gt;
There's also '&amp;lt;tt&amp;gt;entityDef projectile_law_arcing&amp;lt;/tt&amp;gt;', which are the values for the non-seeking rocket, which arcs through the air because it has a {{keyname|gravity}} setting of {{keyvalue|120}}.&lt;br /&gt;
&lt;br /&gt;
What we're going to do is change the entity definition for the arcing rocket so it travels really slowly, lasts really long, and isn't affected by gravity (so it won't arc.)&lt;br /&gt;
&lt;br /&gt;
=== Copying ===&lt;br /&gt;
First, we need to know which file contains the entity data we want to change - in this case, it's {{filename|\SDK 1.2 Beta\base\def\weapons\rocketlauncher.def}}. However, we shouldn't modify this file, as it's the one from the SDK and is in the wrong place for our mod. Instead, it should be copied to the 'simplemod' folder.&lt;br /&gt;
&lt;br /&gt;
So copy {{filename|\SDK 1.2 Beta\base\def\weapons\rocketlauncher.def}} to {{filename|\simplemod\def\weapons\rocketlauncher.def}} (you'll need to create the 'def' and 'weapons' folders yourself.)&lt;br /&gt;
&lt;br /&gt;
This means that when simplemod is run, although ETQW will still load all its normal files, it will see that simplemod has its own {{filename|rocketlauncher.def}} and will use that one instead of the one that comes with the game.&lt;br /&gt;
&lt;br /&gt;
=== Editing ===&lt;br /&gt;
Now open {{filename|\simplemod\def\weapons\rocketlauncher.def}} in Notepad, and find the section for the entity 'projectile_law_arcing'. It'll look like this:&lt;br /&gt;
&lt;br /&gt;
 entityDef projectile_law_arcing {&lt;br /&gt;
 	&amp;quot;inherit&amp;quot;			&amp;quot;projectile_rocket_base&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 	&amp;quot;dmg_damage&amp;quot;			&amp;quot;damage_law&amp;quot;&lt;br /&gt;
 	&amp;quot;dmg_splash_damage&amp;quot;		&amp;quot;damage_law_splash&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 	&amp;quot;launchFromBarrel&amp;quot;		&amp;quot;1&amp;quot;&lt;br /&gt;
 	&amp;quot;health&amp;quot;			&amp;quot;0&amp;quot;&lt;br /&gt;
 	&amp;quot;velocity&amp;quot;			&amp;quot;2000 0 0&amp;quot;&lt;br /&gt;
 	&amp;quot;face_velocity&amp;quot;			&amp;quot;1&amp;quot;&lt;br /&gt;
 	&amp;quot;gravity&amp;quot;			&amp;quot;120&amp;quot;&lt;br /&gt;
 	&amp;quot;fuse&amp;quot;				&amp;quot;4&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 	&amp;quot;snd_fly&amp;quot;			&amp;quot;sounds/weapons/law/fly&amp;quot;&lt;br /&gt;
   	&amp;quot;fx_trail&amp;quot;			&amp;quot;effects/base/missile_trail&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 	&amp;quot;fx_explode&amp;quot;			&amp;quot;effects/impacts/rocket/explosion_default&amp;quot;&lt;br /&gt;
 	&amp;quot;fx_explode_sand&amp;quot;		&amp;quot;effects/impacts/rocket/explosion_sand&amp;quot;&lt;br /&gt;
 	&amp;quot;fx_explode_metal&amp;quot;		&amp;quot;effects/impacts/rocket/explosion_metal&amp;quot;&lt;br /&gt;
 	&amp;quot;fx_explode_snow&amp;quot;		&amp;quot;effects/impacts/rocket/explosion_snow&amp;quot;&lt;br /&gt;
 	&lt;br /&gt;
 	&amp;quot;use_air_burst&amp;quot;			&amp;quot;1&amp;quot;&lt;br /&gt;
 	&amp;quot;fx_airburst&amp;quot;			&amp;quot;effects/impacts/rocket/explosion_air&amp;quot;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
We're going to change the rocket so it travels really slowly in a straight line.&lt;br /&gt;
&lt;br /&gt;
First to make it slower, change the {{keyname|velocity}} setting from {{keyvalue|2000 0 0}} to {{keyvalue|100 0 0}}, so it only travels 100 units a second.&lt;br /&gt;
&lt;br /&gt;
Next, change {{keyname|gravity}} from {{keyvalue|120}} to {{keyvalue|0}}, so isn't pulled down by gravity while in the air.&lt;br /&gt;
&lt;br /&gt;
Lastly, change {{keyname|fuse}} from {{keyvalue|4}} to {{keyvalue|30}}, so it'll last 30 seconds before it explodes (unless it hits something first)&lt;br /&gt;
&lt;br /&gt;
This is the result:&lt;br /&gt;
&lt;br /&gt;
 entityDef projectile_law_arcing {&lt;br /&gt;
 	&amp;quot;inherit&amp;quot;			&amp;quot;projectile_rocket_base&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 	&amp;quot;dmg_damage&amp;quot;			&amp;quot;damage_law&amp;quot;&lt;br /&gt;
 	&amp;quot;dmg_splash_damage&amp;quot;		&amp;quot;damage_law_splash&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 	&amp;quot;launchFromBarrel&amp;quot;		&amp;quot;1&amp;quot;&lt;br /&gt;
 	&amp;quot;health&amp;quot;			&amp;quot;0&amp;quot;&lt;br /&gt;
 	'''&amp;quot;velocity&amp;quot;			&amp;quot;100 0 0&amp;quot;'''&lt;br /&gt;
 	&amp;quot;face_velocity&amp;quot;			&amp;quot;1&amp;quot;&lt;br /&gt;
 	'''&amp;quot;gravity&amp;quot;			&amp;quot;0&amp;quot;'''&lt;br /&gt;
 	'''&amp;quot;fuse&amp;quot;				&amp;quot;30&amp;quot;'''&lt;br /&gt;
 &lt;br /&gt;
 	&amp;quot;snd_fly&amp;quot;			&amp;quot;sounds/weapons/law/fly&amp;quot;&lt;br /&gt;
   	&amp;quot;fx_trail&amp;quot;			&amp;quot;effects/base/missile_trail&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 	&amp;quot;fx_explode&amp;quot;			&amp;quot;effects/impacts/rocket/explosion_default&amp;quot;&lt;br /&gt;
 	&amp;quot;fx_explode_sand&amp;quot;		&amp;quot;effects/impacts/rocket/explosion_sand&amp;quot;&lt;br /&gt;
 	&amp;quot;fx_explode_metal&amp;quot;		&amp;quot;effects/impacts/rocket/explosion_metal&amp;quot;&lt;br /&gt;
 	&amp;quot;fx_explode_snow&amp;quot;		&amp;quot;effects/impacts/rocket/explosion_snow&amp;quot;&lt;br /&gt;
 	&lt;br /&gt;
 	&amp;quot;use_air_burst&amp;quot;			&amp;quot;1&amp;quot;&lt;br /&gt;
 	&amp;quot;fx_airburst&amp;quot;			&amp;quot;effects/impacts/rocket/explosion_air&amp;quot;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=== Testing ===&lt;br /&gt;
[[Image:simplemod_slowrocket.jpg|400px|thumb|right|A slow rocket, courtesy of editing the rocketlauncher.def file]]&lt;br /&gt;
We can test this change by loading the mod via the SDK Launcher (ensuring 'simplemod' is selected) and then loading any map via {{consolecmd|devmap}}, for example {{consolecmd|devmap island}}.&lt;br /&gt;
&lt;br /&gt;
Once the map is loaded, join the GDF team as a Soldier with the rocket launcher (as that's the only weapon changed by the above file.) If you now fire a non-seeking rocket, you should find it travels very slowly, in a straight line, and lasts 30 seconds before it explodes (unless it hits something first), allowing you to run around and inspect it while it's still in the air.&lt;br /&gt;
&lt;br /&gt;
''If you edit a .def file while the game is running, use {{consolecmd|reloadDecls}} to force the game to reload all definition files. This allows you to see what effect your changes had on the game, without needing to restart it.''&lt;br /&gt;
&lt;br /&gt;
''Be aware that for edited declarations to work, you should ensure the following cvar is set {{consolecmd|com_useBinaryDecls 2}}, which forces to engine to load your .def files rather then the binary ones shipped with the game.''&lt;br /&gt;
&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
== Script Files (.script) ==&lt;br /&gt;
Although definition files contain settings and values of entities, they can't change the ''behaviour'' of entities. For this, you need to edit script files; all weapons, vehicles, items and projectiles are defined with script files. Script files present a 'high-level' way to access the mechanics of the game, and can be modified while the game is running.&lt;br /&gt;
&lt;br /&gt;
''Script files are not be be confused with game code, which is programmed in C++ and contains all the low-level game behaviour. Many mods can be created entirely through script files. Note however that script files may be converted to C++ and compiled into a DLL for performance, but is not covered in this tutorial.''&lt;br /&gt;
&lt;br /&gt;
ETQW's scripts can be found in {{filename|\SDK 1.2 Beta\base\script\}}, and since they are normal text documents, can be opened in Notepad or any other text editor.&lt;br /&gt;
&lt;br /&gt;
The most important files here are {{filename|events.script}} (which defines game code methods that are callable from script files), and the {{filename|base.script}} files in each directory. &lt;br /&gt;
&lt;br /&gt;
For this bit of scripting, we're going to change the weapon script so weapons don't use up any ammo when they're fired.&lt;br /&gt;
&lt;br /&gt;
=== Copying ===&lt;br /&gt;
First, we need to know which file to modify - in this case, it's {{filename|\SDK 1.2 Beta\base\script\weapons\base.script}}, which contains the basic behaviours shared by all weapons used in the game. However, just like .def files, we shouldn't modify this file, as it's the one from the SDK. Instead, it should be copied to {{filename|simplemod\script\weapons\base.script}}, so it's specific to our mod.&lt;br /&gt;
&lt;br /&gt;
=== Examining ===&lt;br /&gt;
A cursory glance at this script shows that there are two methods related to ammo use - '&amp;lt;tt&amp;gt;UseAmmo&amp;lt;/tt&amp;gt;' and '&amp;lt;tt&amp;gt;UseAmmo_Stroyent&amp;lt;/tt&amp;gt;' - which are both called with a &amp;lt;tt&amp;gt;modIndex&amp;lt;/tt&amp;gt; parameter indicating what sort of ammo to be consumed.&lt;br /&gt;
&lt;br /&gt;
 void weapon_base::UseAmmo( float modIndex ) {&lt;br /&gt;
 	if ( sys.isClient() ) {&lt;br /&gt;
 		return;&lt;br /&gt;
 	}&lt;br /&gt;
 &lt;br /&gt;
 	float amount = ammoRequired( modIndex );&lt;br /&gt;
 	useAmmo( ammoType( modIndex ), amount );&lt;br /&gt;
 	addToClip( modIndex, -amount );&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void weapon_base::UseAmmo_Stroyent( float modIndex ) {&lt;br /&gt;
 	if ( sys.isClient() ) {&lt;br /&gt;
 		return;&lt;br /&gt;
 	}&lt;br /&gt;
 &lt;br /&gt;
 	float amount = ammoRequired( modIndex );&lt;br /&gt;
 	useAmmo( ammoType( modIndex ), amount );&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Both these methods call a few functions defined by the (C++) game code, specifically '&amp;lt;tt&amp;gt;sys.isClient&amp;lt;/tt&amp;gt;', '&amp;lt;tt&amp;gt;ammoRequired&amp;lt;/tt&amp;gt;', '&amp;lt;tt&amp;gt;useAmmo&amp;lt;/tt&amp;gt;' and '&amp;lt;tt&amp;gt;addToClip&amp;lt;/tt&amp;gt;'. We know this because these functions aren't defined in this .script file, but are present in the {{filename|events.script}} file, defined as '&amp;lt;tt&amp;gt;scriptEvent&amp;lt;/tt&amp;gt;' functions.&lt;br /&gt;
&lt;br /&gt;
=== Editing ===&lt;br /&gt;
For infinite ammo, the .script simply needs to be edited so the '&amp;lt;tt&amp;gt;useAmmo&amp;lt;/tt&amp;gt;' and '&amp;lt;tt&amp;gt;addToClip&amp;lt;/tt&amp;gt;' functions never get called. This can be done a number of ways, but the simplest is for these two '&amp;lt;tt&amp;gt;UseAmmo&amp;lt;/tt&amp;gt;' methods to simply do nothing:&lt;br /&gt;
&lt;br /&gt;
 void weapon_base::UseAmmo( float modIndex ) {&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void weapon_base::UseAmmo_Stroyent( float modIndex ) {&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
''This could be achieved in a large number of different ways, from simply commenting out the code using standard C/C++ comment syntax, or just adding a &amp;lt;tt&amp;gt;return&amp;lt;/tt&amp;gt; at the top of the method.''&lt;br /&gt;
&lt;br /&gt;
=== Testing ===&lt;br /&gt;
To test the script we first need to make ETQW reload the script files. This is done with {{consolecmd|reloadScript}}, which usually takes a few seconds, and means we can continue editing .script files in the background without having to quit and reload the game each time. If there are any errors or problems with the script, the ETQW console will list these problems for debugging/fixing.&lt;br /&gt;
&lt;br /&gt;
If the script is compiled successfully, a message such as '&amp;lt;tt&amp;gt;Compiled 'script/main.script': 13141.5 ms&amp;lt;/tt&amp;gt;' will be displayed.&lt;br /&gt;
&lt;br /&gt;
''Note that for scripts to work, the following cvar must be set: {{consolecmd|g_useCompiledScript 1}}''&lt;br /&gt;
&lt;br /&gt;
=== Compiling ===&lt;br /&gt;
Thanks to ETQW's built-in interpreter, scripts can be changed and tested very rapidly. However, for the final release of a mod, is is much preferable to compile the scripts into a {{filename|compiledscriptx86.dll}}, which will run much faster.&lt;br /&gt;
&lt;br /&gt;
Compiling scripts requires the additional setup of a compiler, and so is not covered in this tutorial.&lt;br /&gt;
&lt;br /&gt;
* See [[Generating Compiled Scripts]] for further information.&lt;br /&gt;
&lt;br /&gt;
== Packaging your mod ==&lt;br /&gt;
Mods can be packaged in a number of ways, but the simplest is to simply send your mod folder (in this case 'simplemod') to other people who want to run your mod, so they have the same folders and files as you.&lt;br /&gt;
&lt;br /&gt;
Alternatively, all the files inside 'simplemod' can be zipped up and renamed to a PK4 file (e.g. 'simplemod001.pk4'). This is neater and tidier.&lt;br /&gt;
&lt;br /&gt;
'''TODO'''&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
* [[Packaging_up_a_Map_or_Mod]]&lt;/div&gt;</summary>
		<author><name>Ducks</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.splashdamage.com/index.php?title=Portal_Basics&amp;diff=4077</id>
		<title>Portal Basics</title>
		<link rel="alternate" type="text/html" href="https://wiki.splashdamage.com/index.php?title=Portal_Basics&amp;diff=4077"/>
		<updated>2007-12-18T09:28:48Z</updated>

		<summary type="html">&lt;p&gt;Ducks: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Portals are not teleporters!'''&lt;br /&gt;
&lt;br /&gt;
Portals are used to reduce the amount of work the renderer has to do. In essence, a portal is a window into an area of a map; if the renderer can not see a portal into an area of the map, it knows the area behind the portal can not be seen by the player either, and therefore does not need to render it. Similarly, if the player is very far from the portal, such that it only uses a few pixels on the screen, the renderer knows it's not worth rendering the area behind it.&lt;br /&gt;
&lt;br /&gt;
The important thing to understand is that portals are only useful when used to distinguish separate areas, and when the area they hide is complex enough to make it worth not rendering. Hence portals are usually created in doorways or entryways that are crucial for the player to get from one part of the map to another.&lt;br /&gt;
&lt;br /&gt;
There are several types of portals. 'Visportals' are the most basic and simply won't render the area behind it when it itself isn't on-screen (or is too small to be considered worth rendering). Other portals are used to control the flow of light and to alter the ambient lighting within the different interior sections of maps. However, all portals are created in the same way and follow the same basic rules.&lt;br /&gt;
&lt;br /&gt;
== Creating a portal ==&lt;br /&gt;
A portal is created by assigning all but one face of a brush the [[Common Textures#common/nodraw|nodraw]] texture. The remaining face should be given the portal texture ([[Common Textures#common/visportal|visportal]], [[Common Textures#common/outsideportal|outsideportal]], or [[Common Textures|otherwise]].) The face with the chosen portal should cut completely through the area to be portalled - that is, the portal-textured face should touch ceiling, floor, and walls on both sides. Usually, this means portals are rectangular.&lt;br /&gt;
&lt;br /&gt;
'''Patches may not be used for portals. Portals must be completely flat.'''&lt;br /&gt;
&lt;br /&gt;
[[Image:Portals_goodbad.jpg|frame|none|How to set up a simple portal correctly.]]&lt;br /&gt;
&lt;br /&gt;
It is also important to note that '''portals must completely seal areas from each other'''. So if you have two rooms joined by three doorways, if you add a portal to one doorway, you need to add a portal to the other two doorways as well. In other words, it should be impossible to look at one side of a portal and then look at the other side without needing to pass through a portal to do so.&lt;br /&gt;
&lt;br /&gt;
== Portal types ==&lt;br /&gt;
&lt;br /&gt;
=== visportal ===&lt;br /&gt;
* Texture: &amp;lt;tt&amp;gt;[[Common Textures#editor/visportal|/editor/visportal]]&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The most common portal, used to hide areas of a map that should not be rendered when the portal is not in view. Note how the green visportal texture is placed in doorways - when those doorways are not in view, the areas behind them will not be rendered. Also note how the purple 'nodraw' texture in the first screenshot is actually the backside of the bigger portal in the second screenshot.&lt;br /&gt;
&lt;br /&gt;
[[Image:P_vis1.jpg|frame|left|visportal placement in Sewer]] [[Image:P_vis2.jpg|frame|left|visportal placement in Sewer]]&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
==== Uses ====&lt;br /&gt;
Visportals serve two main purposes:&lt;br /&gt;
# They can reduce the number of polygons that need to be drawn, hence&lt;br /&gt;
# They can reduce the number of textures that need to be in memory&lt;br /&gt;
&lt;br /&gt;
The combination of these means that portals can lead to significant performance gains, as the renderer has less work to do. Hence some areas can use more detail than normal, knowing the additional detail will be culled away by portals when not in sight. Conversely, portals can also make the game more accessible on lower-spec machines as the renderer knows which areas can be safely culled without affecting the experience for the user.&lt;br /&gt;
&lt;br /&gt;
The difficulty is placing portals and geometry appropriately. If placed badly, it can mean that two high-detail areas are in view at the same time, so the engine renders many more polygons and uses more texture memory, in some cases leading to a sudden decrease in performance.&lt;br /&gt;
&lt;br /&gt;
=== ambientportal ===&lt;br /&gt;
* Texture: &amp;lt;tt&amp;gt;[[Common Textures#editor/ambientportal|/editor/ambientportal]]&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Used to separate ambient lighting areas defined by [[Entity light_ambient|light_ambient]] entities.&lt;br /&gt;
&lt;br /&gt;
=== audioportal ===&lt;br /&gt;
* Texture: &amp;lt;tt&amp;gt;/textures/editor/audioportal&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Used to separate areas of sound, for example to make sure the sound of machinery in one room doesn't leak into an adjacent room.&lt;br /&gt;
&lt;br /&gt;
=== aasclusterportal ===&lt;br /&gt;
* Texture: &amp;lt;tt&amp;gt;/textures/common/aasclusterportal&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Distinguishes to areas for AAS generation purposes. &lt;br /&gt;
&lt;br /&gt;
=== outsideportal ===&lt;br /&gt;
* Texture: &amp;lt;tt&amp;gt;[[Common Textures#editor/outsideportal|/textures/editor/outsideportal]]&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Used to separate the inside (indoors) and outside (outdoors) of a level, in order to control light (and shadow) from sunlight.&lt;br /&gt;
&lt;br /&gt;
=== playzoneportal ===&lt;br /&gt;
* Texture: &amp;lt;tt&amp;gt;/textures/editor/playzoneportal&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Used to separate a map into two or more playzones - in the same manner that Slipgate is split across two environments. Each of Slipgate's environments are surrounded with a playzone portal hull.&lt;br /&gt;
&lt;br /&gt;
== Developer Commands ==&lt;br /&gt;
[[Image:Portals_showportals.jpg|frame|left|r_showPortals in action]]&lt;br /&gt;
* {{consolecmd|r_showPortals 0/1/2/3}} - turns on rendering of portal outlines so it's possible to see which portals are active (rendered green) and which are not (rendered red). This is a good command to use to help understand how portals work and where they are placed in other maps. Setting {{consolecmd|r_showPortals 3}} displays what type each portal is.&lt;br /&gt;
* {{consolecmd|r_usePortals 0/1}} - turns on/off portals (when turned off, everything is drawn, whether it is visible or not)&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
== Additional Resources ==&lt;br /&gt;
* [http://www.iddevnet.com/doom3/visportals.php Vis Portals] - a good overview of visportals and explanation of how they work&lt;br /&gt;
* [http://www.modwiki.net/wiki/Visportal Visportal topic on modwiki] - a slightly simpler explanation&lt;br /&gt;
&lt;br /&gt;
[[Category:Basic Level Design]]&lt;/div&gt;</summary>
		<author><name>Ducks</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.splashdamage.com/index.php?title=An_Advanced_Terrain_and_Megatexture&amp;diff=4076</id>
		<title>An Advanced Terrain and Megatexture</title>
		<link rel="alternate" type="text/html" href="https://wiki.splashdamage.com/index.php?title=An_Advanced_Terrain_and_Megatexture&amp;diff=4076"/>
		<updated>2007-12-18T09:26:17Z</updated>

		<summary type="html">&lt;p&gt;Ducks: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Image:AdvMega_Intro.jpg|thumb|500px|right]]&lt;br /&gt;
This guide will show you step by step, on how to create a detailed Megatextured Terrain. &lt;br /&gt;
&lt;br /&gt;
'''Please ensure you are familiar with [[A Simple First Megatexture]] before attempting this tutorial.'''&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
'''For this tutorial you must:'''&lt;br /&gt;
* Have a modelling package that can export as LWO, ASE or OBJ&lt;br /&gt;
* Have basic modelling skills&lt;br /&gt;
* Have basic mapping skills, as in [[A Simple First Terrain]]&lt;br /&gt;
&lt;br /&gt;
'''This tutorial covers:'''&lt;br /&gt;
* Steps to create a detailed terrain mesh.&lt;br /&gt;
* How to assign the Megatexture&lt;br /&gt;
* How to add the terrain mesh to a map&lt;br /&gt;
* How to make a Megatexture&lt;br /&gt;
* How to compile a Megatexture&lt;br /&gt;
* How to add Water to a map&lt;br /&gt;
&lt;br /&gt;
'''Programs used in this tutorial are:'''&lt;br /&gt;
* Mudbox&lt;br /&gt;
* World Machine&lt;br /&gt;
* Lightwave&lt;br /&gt;
* Maya (only used briefly)&lt;br /&gt;
Other similar programs can be used instead of these, but wont be covered in this tutorial.&lt;br /&gt;
&lt;br /&gt;
'''This tutorial does not cover in detail:'''&lt;br /&gt;
* How to use Mudbox / ZBrush / World Machine / Blender / Lightwave / Maya / 3DSMax&lt;br /&gt;
&lt;br /&gt;
'''If you already have a terrain mesh''', and do not want to use Mudbox and World Machine, skip to [[#Prepare Terrain for Megatexture|Prepare Terrain for Megatexture]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Mudbox: Shape the Terrain ==&lt;br /&gt;
[[Image:AdvMega_Mudbox.jpg|thumb|128px|right|Mudbox Layers]]&lt;br /&gt;
These are the basic steps for sculpting a terrain in Mudbox.&lt;br /&gt;
* Create a plane, and subdivide (but still keep a low tessellation).&lt;br /&gt;
* Change any tools you use to have the edit ''Direction'' set to ''Y'' axis.&lt;br /&gt;
* Create a new Layer, and sculpt the rough layout for the terrain.&lt;br /&gt;
* Subdivide again to the level of detail you want (or can).&lt;br /&gt;
* Create another layer, and sculpt more details into the terrain.&lt;br /&gt;
* Export to OBJ.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
== Convert Mesh to Heightmap ==&lt;br /&gt;
This step is needed if you want to import your current terrain mesh into World Machine.&lt;br /&gt;
* Firstly, rotate the terrain mesh. In Lightwave, rotate -90° around the X axis. For 3ds Max &amp;amp; Maya, rotate +90° around the X axis.&lt;br /&gt;
* Cap any holes in the mesh, and triangulate the mesh.&lt;br /&gt;
* Using a machine with an nVidia graphics card, run the following command in the ETQW console to get the heightmap (where &amp;lt;model&amp;gt; is the relative path of the ''.lwo'', ''.obj'' or ''.ase'' mesh):&lt;br /&gt;
** {{consolecmd|RenderBumpFlat –floatHeightmap -size 2048 2048 &amp;lt;model&amp;gt;}}&lt;br /&gt;
* An ''.r32'' (raw 32-bit) heightmap will be saved into the same folder as your model, this heightmap can be used in World Machine.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== World Machine: Adding Flow ==&lt;br /&gt;
[[Image:AdvMega_WorldMachine.jpg|thumb|320px|right|World Machine Device View]]&lt;br /&gt;
[http://www.world-machine.com World Machine] is used to add erosion flow lines to the terrain.  It's also useful as the flow maps can be exported to help create masks for texture distribution later in [[Terrain_Editor|Terrain Editor]].  These are the basic steps made to build the World Machine device nodes.&lt;br /&gt;
&lt;br /&gt;
* Blend the heightmap made from the Mudbox mesh with ''Perlin Noise'' to help the ''Erosion'' filters.&lt;br /&gt;
* Use a ''Snow'' filter around the rocks (mask used), so rocks look like they are sitting in soil.&lt;br /&gt;
* Pass the heightmap through two ''Erosion'' nodes, which are set up differently, and combined give a natural flowing look.  Both ''Erosion'' nodes are masked around the rocks, so they will keep their shape.  The first ''Erosion'' node is setup as ''Channeled Erosion'' with an ''Inverse Filter'', carving large flow lines into the terrain.  The Second is a ''Channeled Erosion'' set with ''No Filter'' , adding finer detailed flow lines.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
[[Image:AdvMega_WM_Output.jpg|thumb|150px|right|World Machine Heightmap]]&lt;br /&gt;
* The heightmap output of the erosion is split so the heightmap can be saved (and later used to create a mesh), and further filters created (sediment and normal map) to help make masks for texture distribution later.&lt;br /&gt;
&lt;br /&gt;
[[Image:AdvMega_WM_Flow.jpg|thumb|100px|right|Flow Map]]&lt;br /&gt;
* ''Flow'' and ''Deposition'' maps from the Erosion nodes are passed through ''Simple Transformation'' nodes that brighten the output saved.&lt;br /&gt;
* The heightmap saved above is imported and rendered at a lower (usable) resolution to the ''Mesh Output'' node creating an OBJ mesh.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This World Machine example was given using World Machine 2, which is currently in [http://www.world-machine.com/blog/ Beta].  A couple of features show aren't available in World Machine v1.25.  They are the ''Snow'' node (which isn't needed) and ''Mesh Output''. An alternative to creating a mesh from a heightmap [[Making_a_Terrain_Model#Optimising_to_Game_Mesh|can be found here]].&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== High to Low poly ==&lt;br /&gt;
=== Optimizing ===&lt;br /&gt;
[[Image:AdvMega Dags.jpg|thumb|320px|right|Dangling border polygons to delete]]&lt;br /&gt;
This stage will briefly explain how the high-poly mesh exported from World Machine can be optimized down to the low poly game mesh.&lt;br /&gt;
* Load the OBJ exported from [[#World Machine: Adding Flow|World Machine]] into your preferred 3d Application.&lt;br /&gt;
* Rotate so it's orientated correctly.&lt;br /&gt;
* The outer mesh border will look like it's been dragged down (an artifact from the mesh being built from a heightmap). So remove this by selecting the mesh border polygons, and delete them.&lt;br /&gt;
* Triangulate the mesh and save out as ''.OBJ'', so it can be loaded into Lightwave.&lt;br /&gt;
* In Lightwave, use a plug-in called [http://amber.rc.arizona.edu/lw/qemloss3.html qemLOSS3] (once installed, found in the Utilities tab) to reduce the polygons to a reasonable amount (ETQW used around 30,000 polygons for the 32,768 unit width terrain).  If you have trouble running qemLOSS3, apply a different material other than the default.&lt;br /&gt;
* Fix edges that are triangulated in the wrong direction.&lt;br /&gt;
* Smooth subdivide the mesh, and run your mesh through qemLOSS3 again (to the same polygon count as before).  This will give a smoother terrain, easier for player movement and with less harsh silhouette angles. Repeat until you're happy with the mesh smoothness.&lt;br /&gt;
* Again fix edges that are triangulated in the wrong direction (these show up most obviously by applying a shiny material, and making sure the mesh has a single smoothing group (all soft edges, 180 degree smoothing angle).&lt;br /&gt;
* If you plan on having water, cut the mesh along the waterline, so no polygons are both above or below the water.  This is so the [[#Water Fog|water fog]] has a clear line to stop at.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== UV the Terrain ===&lt;br /&gt;
[[Image:AdvMega_UV.png|thumb|200px|right|UV Layout]]&lt;br /&gt;
This process is written for Maya, other 3d packages will have to modify the process.&lt;br /&gt;
* To achieve relaxed UV borders use a mel script called worldSpaceUVLine - it can be found on [http://Highend3d.com/maya/downloads/mel_scripts/modeling/poly_tools/4508.html Highend3D]. Copy the .mel into your ''My Documents\maya\#.#\scripts'' folder and run by typing '''''worldSpaceUVLine;''''' in the Maya command line.&lt;br /&gt;
* Snap all 4 corners to the UV 0-1 square.  Select all the edge uv for one side, and in the worldSpaceUVLine tool select the corresponding UV layout direction (U for horizontal, V for vertical), and press the align UV’s on selected line button. Repeat for each side.&lt;br /&gt;
* Make sure all holes in the mesh are capped, and run the Relax UVs tool, with the option ''Edge Weights'' set to ''World Space'', and ''Pin UV Border'' selected.  Keep repeating Relax UVs until you see no more UV movement.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Perturbate Image (Normal Map) ===&lt;br /&gt;
[[Image:AdvMega_Perturbate.jpg|thumb|200px|right|Perturbate Image (Tangent Space Local Map)]]&lt;br /&gt;
The Perturbate Image is an image that is [[#Construct the Megatexture|applied to the megatexture]], and corrects the low poly mesh normal to match that of the high poly.&lt;br /&gt;
* Load the high and low poly mesh into your preferred 3d Application.&lt;br /&gt;
* Use a surface-sampler (also known as baking textures, or render-to-texture, most good 3D applications will have this capability) to render the high poly normals onto the low poly model, with normals set to &amp;quot;tangent space&amp;quot;.&lt;br /&gt;
* You probably will need to fix the normal map channels (red and green) as the 3D Application use normals maps differently to the Game.  Make sure the green channel has white facing down, and red has white facing right.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Convert World Machine masks to UV space ===&lt;br /&gt;
[[Image:AdvMega_LowPoly.jpg|thumb|400px|right|Low Poly Mesh with Local Map]]&lt;br /&gt;
All the masks created created in World Machine (flow, deposition etc.) won't match the new game mesh UV coordinates&lt;br /&gt;
* Load the high and low poly mesh into your preferred 3D application.&lt;br /&gt;
* Duplicate the game mesh and apply a planar UV projection.&lt;br /&gt;
* Apply the masks created in World Machine to the planar mapped mesh.&lt;br /&gt;
* Surface sample the diffuse from the planar mapped mesh, onto the game UV mesh.&lt;br /&gt;
Also render the mesh normals (world space) to an image.  The blue channel will become useful when creating distribution masks, as it represents how vertical a polygon is.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Prepare Terrain for Megatexture =&lt;br /&gt;
Now the mesh is nearly ready for the game, just a couple more steps.&lt;br /&gt;
&lt;br /&gt;
=== Prepare the Mesh ===&lt;br /&gt;
* Scale the game mesh to the correct size, as after converting from a heightmap it probably isn't the right size.  This tutorial mesh is a small 8,192 x 8,192 unit mesh (again the Enemy Territory : Quake Wars terrains are 32,768 x 32,768).&lt;br /&gt;
* Rename the material to ''megatextures/sdk/terrain_mesh_sdk'' (''megatextures/'''&amp;lt;map_name&amp;gt;'''''). Maya will have problems with this naming convention.&lt;br /&gt;
* Set the Mesh normals to be smooth.&lt;br /&gt;
* Save the mesh to {{filename|/models/terrain/sdk/terrain_mesh_sdk.lwo}} ('''''&amp;lt;map_name&amp;gt;'''.lwo'' or ''.obj'' to {{filename|/models/terrain}}).&lt;br /&gt;
&lt;br /&gt;
=== Setup the Material ===&lt;br /&gt;
* Create a text file called {{filename|/materials/megatextures_sdk.mtr}}&lt;br /&gt;
* Add the following text to create the material:&lt;br /&gt;
 ''material megatextures/sdk/terrain_mesh_sdk	{ useTemplate megatextures/default_ambient&amp;lt; &amp;quot;sdk/terrain_mesh_sdk&amp;quot; &amp;gt; }''&lt;br /&gt;
* Save the file. You will need to restart the whole game and editor before any new files are loaded. If you just added the declaration to an existing ''.mtr'' file, you can just use the {{consolecmd|reloaddecls}} console command.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Construct the Megatexture =&lt;br /&gt;
This section will cover the step by step creation of the Megatexture using Terrain Editor (an inspector tab in EditWorld).  For Detailed explanation on feilds and setting not discussed here, check out the [[Terrain_Editor|Terrain Editor]]&lt;br /&gt;
&lt;br /&gt;
=== Set up the Map ===&lt;br /&gt;
* Load EditWorld, and create a new map.&lt;br /&gt;
* Bring up the [[Terrain Editor]] inspector.&lt;br /&gt;
* {{accelbtn|RMB}} in the left blank (white) area.  In the pop-up menu select ''New'' | ''Tree...''&lt;br /&gt;
* On the Root node set the model field to {{filename|/models/terrain/sdk/terrain_mesh_sdk.lwo}}, and also set the ST Model to the same model.  If you have holes in your mesh (holes cut for buildings), you'd need to make a separate ST Model version with no mesh holes.&lt;br /&gt;
* Seal the map up by [[A_Simple_First_Terrain#Creating a Caulk Hull|Creating a Caulk Hull]].  Make sure the origin of the terrain mesh is inside this hull.&lt;br /&gt;
*For the area to be lit by the sun, create a brush inside the caulk hull, textured with 'editor/outsideportal'.&lt;br /&gt;
*To set the atmosphere create an Atmosphere entity and set '''atmospheredecl''' to '''Valley01''' (or what ever atmosphere you're using).&lt;br /&gt;
&lt;br /&gt;
=== Detail Textures ===&lt;br /&gt;
Also on the Root node is where the detail textures are assigned. In each of the layers created, you assign which of these 4 detail textures to use. Detail Textures need to be a greyscale 512x512 texture (preferably saved in ''base/textures/detail/'').&lt;br /&gt;
{| cellspacing=&amp;quot;8&amp;quot; border=&amp;quot;0&amp;quot;&lt;br /&gt;
|'''Detail Texture 0'''&lt;br /&gt;
|&lt;br /&gt;
|{{filename|textures/detail/temperate_dirt.tga}}&lt;br /&gt;
|-&lt;br /&gt;
|'''Detail Texture 1'''&lt;br /&gt;
|&lt;br /&gt;
|{{filename|textures/detail/temperate_grass.tga}}&lt;br /&gt;
|-&lt;br /&gt;
|'''Detail Texture 2'''&lt;br /&gt;
|&lt;br /&gt;
|{{filename|textures/detail/temperate_gravel.tga}}&lt;br /&gt;
|-&lt;br /&gt;
|'''Detail Texture 3'''&lt;br /&gt;
|&lt;br /&gt;
|{{filename|textures/detail/temperate_rock.tga}}&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Image Sources ===&lt;br /&gt;
Here we'll start to create the texture layers that build up the Megatexture. The steps will progressively skip repetitive information about the layer setup.&lt;br /&gt;
&lt;br /&gt;
;Ground_Base&lt;br /&gt;
* Create a '''Group node''', {{accelbtn|RMB}} and  with the pop-up menu select ''New'' | '''Group'''. In the right field you can enter a name for the Group, we'll name this one '''Ground_Base'''.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;Dirt&lt;br /&gt;
* Now we'll create a base '''Image Source''' node. {{accelbtn|RMB}} over the Group node, and create an '''Image Source''' node, this should create it as a child to the Group.  If you accidently created the Image node under the Root, don't worry as you can drag and release over the Group node to make it a child.  Name the Layer '''Dirt''', same way as the Group node.&lt;br /&gt;
* Apply a Diffuse texture by selecting '''Diffuse''' on the right hand panel of the inspector, then selecting the '''File Name''' field and press the '''...''' button to choose a texture.  For this layer we'll use {{filename|textures/megagen/temperate/dirt_06_d.tga}}&lt;br /&gt;
* Repeat the same process for the '''Local''' image by selecting '''Local''' on the right, and applying the texture {{filename|textures/megagen/temperate/dirt_06_local.tga}}&lt;br /&gt;
* As this is the base layer, the '''Distribution''' needs to cover the whole map.  So apply a full white image the same way as above but to the '''Distribution'''.&lt;br /&gt;
* This layer is a dirt layer so I'll set the the '''Detail Texture Type''' to '''0''', to match the number for the dirt detail texture.&lt;br /&gt;
* Also as this layer is dirt I'll set '''Sur Type Properties''' | '''Type''' to '''dirt'''. For a full list of usable surface types, check the [[Terrain_Editor#Surface_Type|Surface Type]] section.&lt;br /&gt;
* The diffuse texture has the dimensions 1024 x 1024, while the map covers 8192.  To keep the correct texture ratio, set '''Texture Properties''' | '''Scale''' to '''8 8'''.&lt;br /&gt;
* '''Texture Properties''' | '''Rotation''' is set to '''270''' to keep the to match the texture lighting to that of the atmosphere.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:AdvMega_2Layers.png|thumb|300px|right|Blend with Distribution Pattern]]&lt;br /&gt;
;Sand&lt;br /&gt;
* Sand will settle along the flow lines, as it's been washed down with the weather.&lt;br /&gt;
* Create this layer in the same way as the '''Dirt''' layer.  The '''Diffuse''' and '''Local''' can also be set up in the same way except choosing {{filename|textures/megagen/temperate/dirt_07.*}} as the textures.&lt;br /&gt;
* This layer will require a unique '''Distribution''' image.  The flow masks ([[# Convert World Machine masks to UV space|UV corrected]]) created from [[# World Machine: Adding Flow|World Machine]] were used to help create '''textures/megagen/terrain_mesh_sdk/masks/masks_sand.tga''' which is applied as the '''Distribution'''.&lt;br /&gt;
* To make the blend more fitting and unique set the '''Distribution Pattern''' to {{filename|textures/megagen/temperate/dirt_06_mask_inverse.tga}}.  This will blend the '''Sand''' into the cracks of the '''Dirt''' before the peaks (stones).&lt;br /&gt;
* '''Ramp Width''' is changed to '''0.5''' so the blend will become tighter.&lt;br /&gt;
* '''Distribution Pattern Texture Rotation''' and '''Scale''' Should match that of the '''Dirt''' layer, as it's using a Distribution Pattern that matches the dirt.&lt;br /&gt;
* Set the '''Detail Texture Type''' to '''0''' (dirt, as it's the best matching of the four), and the '''Surface Type Properties''' | '''Type''' to '''sand'''.&lt;br /&gt;
* To see how the Megatexture is progressing, render a [[Terrain_Editor#Megatexture_Preview|Megatexture Preview]] [[Image:TerEd_PreviewRender.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;Gravel&lt;br /&gt;
* To give the look off loose stones being scatter from the road.&lt;br /&gt;
* Create in the same way as above.  Was created after the [[#Road_Tool|Road Layer]] being placed.&lt;br /&gt;
* The '''Distribution Pattern''' image for this layer will match it's own gravel diffuse, so the '''Rotation''' and '''Scale''' for the '''Diffuse''' and '''Distribution Pattern''' images should be the same.&lt;br /&gt;
* Set the '''Detail Texture Type''' to '''2''' ({{filename|textures/detail/temperate_gravel.tga}}), and the '''Surface Type Properties''' | '''Type''' to '''gravel'''.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;Dry_Dirt&lt;br /&gt;
* Gives a dried up cracked earth appearance, were standing water would have once been.&lt;br /&gt;
* Slight transparency given so layer blends smoother over light sand and darker dirt, '''Alpha''' set to '''0.75'''&lt;br /&gt;
* '''Ramp Width''' set to '''0.25''' making the blend even tighter (sharper).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;Sticks&lt;br /&gt;
* Helps the grass blend in with the dirt.&lt;br /&gt;
* Created after the grass, then layer moved above by dragging and releasing between the layers '''Grass_Outer''' and '''Dry_Dirt'''.&lt;br /&gt;
* '''Ramp Width''' set to '''0.75''' so the blend can be softer.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;Grass_Outer&lt;br /&gt;
* Texture used is of a patchy grass, good for grass on the edges of a grass clump.&lt;br /&gt;
* '''Distribution Pattern''' texture carefully made so the dirt parts of the diffuse blend in last.&lt;br /&gt;
* Texture '''Rotation''' set to '''300''', this is to break up the look of textures tiling in the same direction.&lt;br /&gt;
* The '''Detail Texture Type''' is set to '''1''' ({{filename|textures/detail/temperate_grass.tga}}), and the '''Surface Type Properties''' | '''Type''' to '''grass'''.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;Grass_Inner&lt;br /&gt;
* Dense Grass, blended to cover the dirt of the patchy grass texture ('''Grass_Outer'''), where the mask become more solid (white).&lt;br /&gt;
* Uses the same '''Distribution''' mask as '''Grass_Outer''', as the '''Distribution Pattern''' texture is made so that it is never stronger than that of the patchy grass.&lt;br /&gt;
* Texture '''Rotation''' and '''Scale''' needs to match that of '''Grass_Outer''' as the '''Distribution Pattern''' textures of both grass layers work together, with the same '''Distribution'''.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;Stones&lt;br /&gt;
* Create the Stone '''Distribution''' after the solid rock layers, as the rock will look better when it blends to the stones.  To find out where rocks are distributed exactly, [[Terrain_Editor#Megatexture_Preview|Preview Render]] the megatexture with the rocks layer tinted black, and only a white base layer.  The Preview Megatexture will be saved to {{filename|base/imagedump/maps/&amp;lt;map_name&amp;gt;}} and flipped vertically.&lt;br /&gt;
* As well as being concentrated around the solid rock sections, stones should flow down the surrounding slopes.&lt;br /&gt;
* Make the Stones more dense around rocks.&lt;br /&gt;
* The '''Distribution Pattern''' texture has been created so the stones will blend in one by one.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:AdvMega_GroundLayers.png|thumb|300px|right|Ground Base Layers]]&lt;br /&gt;
;Pebbles&lt;br /&gt;
* Pebbles in Mud works well around the waterline.&lt;br /&gt;
* The '''Distribution''' mask is made slightly darker where the sand '''Distribution''' is.  This will give good variation, as the Pebbles will blend in first (due to '''Distribution Pattern'''), making them appear to be on sand instead of mud.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;Rock&lt;br /&gt;
* A new '''Group''' is created under the '''Root''' node to keep the rock elements neatly together.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;Rock_Base&lt;br /&gt;
* Rock should usually be created (distributed) near the start of making a Megatexture, as rock usually effects where all other elements will be distributed.&lt;br /&gt;
* Texture '''Rotation''' for both '''Diffuse''' and '''Distribution Pattern''' is set to '''0.45''', this is so the rock diffuse is rotated to match the direction of the rock in the map.  If you have rock in all directions you could make separate rock masks for the different rotations.&lt;br /&gt;
* A '''Heightmap''' image is assigned, {{filename|textures/megagen/temperate/rock_01_h.tga}}.  This will help the '''Rock_Stain_(HeightMap)''' blend into the cracks.&lt;br /&gt;
* Set the '''Propagate Distribution''' to '''true''', by ticking the box.  This will mask any child layers with this layers distribution.&lt;br /&gt;
* The '''Detail Texture Type''' is set to '''3''' ({{filename|textures/detail/temperate_rock.tga}}), and the '''Surface Type Properties''' | '''Type''' to '''stone'''.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;Rock_Smooth&lt;br /&gt;
* By distributing smooth rock on raised and large flat areas, while not in cracks and around rock edges, will help to give it shape.&lt;br /&gt;
* This layer can be set up in the same way as '''Rock_Base''' (including having a heightmap image), except you don't need to '''Propagate Distribution'''.&lt;br /&gt;
* Use the same '''Distribution Pattern''' used in '''Rock_Base''' so the smooth rock will form on the ridges first.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;Rock_Horizontal&lt;br /&gt;
* This layer will use a different technique to create horizontal crack lines in the rock.&lt;br /&gt;
* Most of the settings can be set up in the same way as the previous rock layers.&lt;br /&gt;
* Use the same '''Distribution Pattern''' used in '''Rock_Base''' (including the same scale and rotation).&lt;br /&gt;
* Set the '''Projector Pattern''' image to the horizontal rock distribution pattern ({{filename|textures/megagen/temperate/rock_04_mask.tga}}).&lt;br /&gt;
* Set the last value of the '''Blend Parameters''' giving 0 0 0 '''0.75''', this controls the sharpness off the '''Projector Pattern''' blend.&lt;br /&gt;
* The '''Distribution''' mask should only include steep polygons that face the angle of projection (this will prevent texture stretching).&lt;br /&gt;
* Set '''Image Renderer''' | '''UV Type''' to '''Parallel Side'''.  This will force the layer to render has a side projection.  For this to work correctly, the terrain mesh needs to be centered around the grid origin.&lt;br /&gt;
* Set '''Image Renderer''' | '''Projection Angle''' to '''135''', so the projection is in the direction of the vertical rock face (this will rotate the projection around the Z axis).&lt;br /&gt;
* '''Texture Properties''' | '''Scale''' to '''6 2''', as this is a side projection, the number of tiles should match the side profile of the mesh.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:AdvMega_RockLayers.png|thumb|300px|right|Rock with Horizontal Projection]]&lt;br /&gt;
;Rock_Stain(Heightmap)&lt;br /&gt;
* This layer will create darker staining on the rock, by the use of a heightmap blend.&lt;br /&gt;
* The way this blend method works is it renders all the heightmaps from each of the layers first, and then blends the diffuse &amp;amp; local images into the lower (darker) parts of the heightmap.&lt;br /&gt;
* Assign a black texture ({{filename|textures/megagen/black.tga}}) to the '''Heightmap''' image, this will help the staining occur stronger based on the '''Distribution''' mask.&lt;br /&gt;
* Set the first 2 values of the '''Blend Parameters''' giving '''0.33 0.25''' 0 0 . The first value (0.33) controls the height at which the blend takes place, while the second (0.25) controls the sharpness of the falloff in the blend.&lt;br /&gt;
* Set the '''Color''' of the layer to '''black''', either by texture or color tinting.&lt;br /&gt;
* No '''Local''' map required&lt;br /&gt;
* '''Alpha''' set to 0.5 so the rock texture underneath shows through.&lt;br /&gt;
* '''Detail Texture Type''' set to -1 , this will disable distributing detail textures for this layer.&lt;br /&gt;
* Leave the '''Surface Type Properties''' | '''Type''' field blank.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;Water_Line&lt;br /&gt;
* A new '''Group''' is created under the '''Root''' node to keep the water line elements neatly together.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;Water_Line_(Geometry_Based)&lt;br /&gt;
* This layer will give a look of wet ground.&lt;br /&gt;
* Set the '''Blend''' mode to '''Multiply (d*s)''', this will darken (multiply) over the textures underneath.&lt;br /&gt;
* Assign the '''Diffuse''' to {{filename|textures/megagen/white.tga}}, and '''Color''' tint to '''Hue 0, Saturation 0, Brightness 180'''&lt;br /&gt;
* For the '''Distribution''', change '''Source Type''' to '''geometryBased'''.  '''Enable''' the '''Altitude Upper''', set the '''Value''' to '''800''' (32 units just above the water line), and '''Fuzziness''' to '''0.075''' (the falloff).  '''Resolution''' can be set to '''1024''' (generated texture size of the mask).&lt;br /&gt;
* Again '''Detail Texture Type''' set to -1&lt;br /&gt;
* '''Surface Type Properties''' | '''Type''' set to '''water''', so allow splashes to form on the shoreline.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;Water_Fade_(Geometry_Based)&lt;br /&gt;
* This will help give the water depth (and reduce megatexture size ;)&lt;br /&gt;
* Setup in the same way as '''Water_Line_(Geometry_Based)''' above, except:&lt;br /&gt;
* Set the '''Blend''' mode to '''Blend''', this will cover over the textures underneath (looking similar to fog).&lt;br /&gt;
* '''Color''' tint set to '''Hue 60, Saturation 115, Brightness 22'''&lt;br /&gt;
* With '''Source Type''' set to '''geometryBased''', change the '''Altitude Upper''' | '''Value''' to '''768''' (water height) and '''Fuzziness''' to '''1''' (larger falloff).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;Perturbate&lt;br /&gt;
* Create under the '''Root''' node.  Will bring back the normals to that of the [[#Perturbate Image (Normal Map)|high-res mesh]], improving the baked lighting.&lt;br /&gt;
* Set the '''Blend''' mode to '''Perturbate Normals''', this will add the normals to those already generated by the other layers.&lt;br /&gt;
* Assign no '''Diffuse''' texture.&lt;br /&gt;
* Assign a white texture to the '''Distribution''' (as to cover the whole megatexture).&lt;br /&gt;
* Set the '''Local''' texture to {{filename|textures/megagen/terrain_mesh_sdk/local.tga}} (the mesh's normal map).&lt;br /&gt;
* '''Detail Texture Type''' set to -1&lt;br /&gt;
* Leave the '''Surface Type Properties''' | '''Type''' field blank.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:AdvMega_AmbOcc.jpg|thumb|200px|right|Ambient Occlusion map]]&lt;br /&gt;
;Ambient_Occlusion&lt;br /&gt;
* Also created under the '''Root''' node.  Rendered in ''Maya'' to emulate light being occluded in crevices.&lt;br /&gt;
* Set the '''Blend''' mode to '''Multiply (d*(s*1.6)'''. in this blend mode diffuse image colors darker than 160 will darken the previous layers, while colors brighter than 160 will lighten.&lt;br /&gt;
* Assign {{filename|textures/megagen/terrain_mesh_sdk/ambient_occlusion.tga}} as the Diffuse.  The image is balanced so that areas of no change are around 160 in color brightness.&lt;br /&gt;
* Assign a white texture to the '''Distribution''' (as to cover the whole megatexture).&lt;br /&gt;
* '''Detail Texture Type''' set to -1&lt;br /&gt;
* Leave the '''Surface Type Properties''' | '''Type''' field blank.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Road Tool ===&lt;br /&gt;
Here we'll create a paved road using the [[Terrain_Editor#Road_Node|Road Tool]].&lt;br /&gt;
* First we'll create a '''Road Template (.rtl)''', to assign what textures and surface type to assign to the road.&lt;br /&gt;
* Create a blank text file called {{filename|/megagen/roadtemplates/terrain_mesh_sdk.rtl}} and add the needed information:&lt;br /&gt;
 roadTemplate sdk_main_road {&lt;br /&gt;
     {&lt;br /&gt;
         diffuse image sdTextureTGA_Properties {&lt;br /&gt;
             name &amp;quot;textures/megagen/temperate/road_01_d.tga&amp;quot;&lt;br /&gt;
         }&lt;br /&gt;
         local image sdTextureTGA_Properties {&lt;br /&gt;
             name &amp;quot;textures/megagen/temperate/road_01_local.tga&amp;quot;&lt;br /&gt;
         }&lt;br /&gt;
         distribution image sdTextureTGA_Properties {&lt;br /&gt;
             name &amp;quot;textures/megagen/temperate/road_01_mask.tga&amp;quot;&lt;br /&gt;
         }&lt;br /&gt;
         offset ( -1 1 )&lt;br /&gt;
         surfaceType &amp;quot;pavement&amp;quot;&lt;br /&gt;
         detailtexture &amp;quot;textures/detail/temperate_gravel.tga&amp;quot;&lt;br /&gt;
         }&lt;br /&gt;
 }&lt;br /&gt;
Here we've given the road material a name '''sdk_main_road''', and set the '''Diffuse''', '''Local''', and  '''Mask''' textures.  Also setting the '''Surface Type''' to '''pavemant''', and '''Detail Texture''' to {{filename|textures/detail/temperate_gravel.tga}} (which also must be assigned in the '''Root''' node).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:AdvMega_RoadLayer.png|thumb|300px|right|Road Tool]]&lt;br /&gt;
;Main_Road&lt;br /&gt;
* Create the '''Road''' node, {{accelbtn|RMB}} over the Root node, a pop-up menu will appear and select ''New'' | '''Road'''.&lt;br /&gt;
* Set '''Road Template''' to '''sdk_main_road''', this points the road tool to the correct road template.&lt;br /&gt;
* Start placing the road along the map:&lt;br /&gt;
** Select the node&lt;br /&gt;
** Click on the ''XY Top'' window&lt;br /&gt;
** Enter vertex editing mode ({{accelkey|v}})&lt;br /&gt;
** Hold {{accelkey|Ctrl}}{{accelkey|Shift}} and {{accelbtn|lmb}} in the ''XY Top'' window to start placing the points that make up the road curve.&lt;br /&gt;
* Now to fix the width and direction of the road.&lt;br /&gt;
** You need to be in vertex editing mode if not already (toggled with {{accelkey|v}}).&lt;br /&gt;
** '''Moving Road Points''' {{accelbtn|LMB}}-drag the blue points.&lt;br /&gt;
** '''Change Points Direction''' {{accelbtn|LMB}}-drag the yellow points.&lt;br /&gt;
** '''Change Width of Road''' {{accelbtn|LMB}}-drag out the red points.  Alternatively you can widen the whole road when outside the vertex editing mode by selecting the Road node, then {{accelbtn|LMB}}-drag beside the road.&lt;br /&gt;
** '''Adding new Points''' hold {{accelkey|Ctrl}}{{accelkey|Shift}} and {{accelbtn|lmb}} the area where you want create the new point.&lt;br /&gt;
** '''Deleting Points''' {{accelbtn|LMB}} and hold the blue point you want to delete and press ''Backspace''.&lt;br /&gt;
** Press {{accelkey|Esc}} to exit vertex editing mode.&lt;br /&gt;
* The Road Tool must never cross a mesh border, so make sure you bump in your road by at least one unit.  If it does cross a border the Road Tool will render with an artifact stretching to the mesh corner.&lt;br /&gt;
*Finally move the layer into it's correct place for rendering.  Drag and release the node between the '''Ground_Base''' and '''Rock''' group node.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Projector ===&lt;br /&gt;
Using the projector node, localized texture detail can be projected onto the megatexture.&lt;br /&gt;
&lt;br /&gt;
;Projectors&lt;br /&gt;
Created a groups to keep things nice an neat.&lt;br /&gt;
&lt;br /&gt;
;Cracked_Road&lt;br /&gt;
* To give the look of cracked tar where the crater nears the road.&lt;br /&gt;
* Create the '''Road Node''', {{accelbtn|RMB}} over the '''Projectors''' Group node, a pop-up menu will appear and select ''New'' | '''Projector'''.&lt;br /&gt;
* Setup the '''Projector''' the same way you would a standard '''Image Source''' node, except you only need a '''Distribution''' mask (and not a '''Distributed Pattern), as the texture shouldn't be projected larger than the source textures.&lt;br /&gt;
* To place the projector move/scale/rotate as you would a normal brush (including vertex editing).  The projector should be positioned above the terrain mesh.&lt;br /&gt;
&lt;br /&gt;
;Crater&lt;br /&gt;
* Places the crater scorch marks.&lt;br /&gt;
* Setup the same way as '''Cracked_Road'''.&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
* [[A Simple First Megatexture]] - start here for a basic MegaTexture tutorial&lt;br /&gt;
* [[Generate a MegaTexture]] - steps for generating a MegaTexture from the SDK launcher.&lt;br /&gt;
&lt;br /&gt;
[[Category:Art]]&lt;br /&gt;
[[Category:Basic Level Design]]&lt;br /&gt;
[[Category:Tutorials]]&lt;/div&gt;</summary>
		<author><name>Ducks</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.splashdamage.com/index.php?title=An_Advanced_Terrain_and_Megatexture&amp;diff=4075</id>
		<title>An Advanced Terrain and Megatexture</title>
		<link rel="alternate" type="text/html" href="https://wiki.splashdamage.com/index.php?title=An_Advanced_Terrain_and_Megatexture&amp;diff=4075"/>
		<updated>2007-12-18T09:25:21Z</updated>

		<summary type="html">&lt;p&gt;Ducks: /* See Also */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Image:AdvMega_Intro.jpg|thumb|500px|right]]&lt;br /&gt;
This guide will show you step by step, on how to create a detailed Megatextured Terrain.&lt;br /&gt;
&lt;br /&gt;
= Introduction =&lt;br /&gt;
'''For this tutorial you must:'''&lt;br /&gt;
* Have a modelling package that can export as LWO, ASE or OBJ&lt;br /&gt;
* Have basic modelling skills&lt;br /&gt;
* Have basic mapping skills, as in [[A Simple First Terrain]]&lt;br /&gt;
&lt;br /&gt;
'''This tutorial covers:'''&lt;br /&gt;
* Steps to create a detailed terrain mesh.&lt;br /&gt;
* How to assign the Megatexture&lt;br /&gt;
* How to add the terrain mesh to a map&lt;br /&gt;
* How to make a Megatexture&lt;br /&gt;
* How to compile a Megatexture&lt;br /&gt;
* How to add Water to a map&lt;br /&gt;
&lt;br /&gt;
'''Programs used in this tutorial are:'''&lt;br /&gt;
* Mudbox&lt;br /&gt;
* World Machine&lt;br /&gt;
* Lightwave&lt;br /&gt;
* Maya (only used briefly)&lt;br /&gt;
Other similar programs can be used instead of these, but wont be covered in this tutorial.&lt;br /&gt;
&lt;br /&gt;
'''This tutorial does not cover in detail:'''&lt;br /&gt;
* How to use Mudbox / ZBrush / World Machine / Blender / Lightwave / Maya / 3DSMax&lt;br /&gt;
&lt;br /&gt;
'''If you already have a terrain mesh''', and do not want to use Mudbox and World Machine, skip to [[#Prepare Terrain for Megatexture|Prepare Terrain for Megatexture]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Mudbox: Shape the Terrain =&lt;br /&gt;
[[Image:AdvMega_Mudbox.jpg|thumb|128px|right|Mudbox Layers]]&lt;br /&gt;
These are the basic steps for sculpting a terrain in Mudbox.&lt;br /&gt;
* Create a plane, and subdivide (but still keep a low tessellation).&lt;br /&gt;
* Change any tools you use to have the edit ''Direction'' set to ''Y'' axis.&lt;br /&gt;
* Create a new Layer, and sculpt the rough layout for the terrain.&lt;br /&gt;
* Subdivide again to the level of detail you want (or can).&lt;br /&gt;
* Create another layer, and sculpt more details into the terrain.&lt;br /&gt;
* Export to OBJ.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
= Convert Mesh to Heightmap =&lt;br /&gt;
This step is needed if you want to import your current terrain mesh into World Machine.&lt;br /&gt;
* Firstly, rotate the terrain mesh. In Lightwave, rotate -90° around the X axis. For 3ds Max &amp;amp; Maya, rotate +90° around the X axis.&lt;br /&gt;
* Cap any holes in the mesh, and triangulate the mesh.&lt;br /&gt;
* Using a machine with an nVidia graphics card, run the following command in the ETQW console to get the heightmap (where &amp;lt;model&amp;gt; is the relative path of the ''.lwo'', ''.obj'' or ''.ase'' mesh):&lt;br /&gt;
** {{consolecmd|RenderBumpFlat –floatHeightmap -size 2048 2048 &amp;lt;model&amp;gt;}}&lt;br /&gt;
* An ''.r32'' (raw 32-bit) heightmap will be saved into the same folder as your model, this heightmap can be used in World Machine.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= World Machine: Adding Flow =&lt;br /&gt;
[[Image:AdvMega_WorldMachine.jpg|thumb|320px|right|World Machine Device View]]&lt;br /&gt;
[http://www.world-machine.com World Machine] is used to add erosion flow lines to the terrain.  It's also useful as the flow maps can be exported to help create masks for texture distribution later in [[Terrain_Editor|Terrain Editor]].  These are the basic steps made to build the World Machine device nodes.&lt;br /&gt;
&lt;br /&gt;
* Blend the heightmap made from the Mudbox mesh with ''Perlin Noise'' to help the ''Erosion'' filters.&lt;br /&gt;
* Use a ''Snow'' filter around the rocks (mask used), so rocks look like they are sitting in soil.&lt;br /&gt;
* Pass the heightmap through two ''Erosion'' nodes, which are set up differently, and combined give a natural flowing look.  Both ''Erosion'' nodes are masked around the rocks, so they will keep their shape.  The first ''Erosion'' node is setup as ''Channeled Erosion'' with an ''Inverse Filter'', carving large flow lines into the terrain.  The Second is a ''Channeled Erosion'' set with ''No Filter'' , adding finer detailed flow lines.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
[[Image:AdvMega_WM_Output.jpg|thumb|150px|right|World Machine Heightmap]]&lt;br /&gt;
* The heightmap output of the erosion is split so the heightmap can be saved (and later used to create a mesh), and further filters created (sediment and normal map) to help make masks for texture distribution later.&lt;br /&gt;
&lt;br /&gt;
[[Image:AdvMega_WM_Flow.jpg|thumb|100px|right|Flow Map]]&lt;br /&gt;
* ''Flow'' and ''Deposition'' maps from the Erosion nodes are passed through ''Simple Transformation'' nodes that brighten the output saved.&lt;br /&gt;
* The heightmap saved above is imported and rendered at a lower (usable) resolution to the ''Mesh Output'' node creating an OBJ mesh.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This World Machine example was given using World Machine 2, which is currently in [http://www.world-machine.com/blog/ Beta].  A couple of features show aren't available in World Machine v1.25.  They are the ''Snow'' node (which isn't needed) and ''Mesh Output''. An alternative to creating a mesh from a heightmap [[Making_a_Terrain_Model#Optimising_to_Game_Mesh|can be found here]].&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= High to Low poly =&lt;br /&gt;
=== Optimizing ===&lt;br /&gt;
[[Image:AdvMega Dags.jpg|thumb|320px|right|Dangling border polygons to delete]]&lt;br /&gt;
This stage will briefly explain how the high-poly mesh exported from World Machine can be optimized down to the low poly game mesh.&lt;br /&gt;
* Load the OBJ exported from [[#World Machine: Adding Flow|World Machine]] into your preferred 3d Application.&lt;br /&gt;
* Rotate so it's orientated correctly.&lt;br /&gt;
* The outer mesh border will look like it's been dragged down (an artifact from the mesh being built from a heightmap). So remove this by selecting the mesh border polygons, and delete them.&lt;br /&gt;
* Triangulate the mesh and save out as ''.OBJ'', so it can be loaded into Lightwave.&lt;br /&gt;
* In Lightwave, use a plug-in called [http://amber.rc.arizona.edu/lw/qemloss3.html qemLOSS3] (once installed, found in the Utilities tab) to reduce the polygons to a reasonable amount (ETQW used around 30,000 polygons for the 32,768 unit width terrain).  If you have trouble running qemLOSS3, apply a different material other than the default.&lt;br /&gt;
* Fix edges that are triangulated in the wrong direction.&lt;br /&gt;
* Smooth subdivide the mesh, and run your mesh through qemLOSS3 again (to the same polygon count as before).  This will give a smoother terrain, easier for player movement and with less harsh silhouette angles. Repeat until you're happy with the mesh smoothness.&lt;br /&gt;
* Again fix edges that are triangulated in the wrong direction (these show up most obviously by applying a shiny material, and making sure the mesh has a single smoothing group (all soft edges, 180 degree smoothing angle).&lt;br /&gt;
* If you plan on having water, cut the mesh along the waterline, so no polygons are both above or below the water.  This is so the [[#Water Fog|water fog]] has a clear line to stop at.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== UV the Terrain ===&lt;br /&gt;
[[Image:AdvMega_UV.png|thumb|200px|right|UV Layout]]&lt;br /&gt;
This process is written for Maya, other 3d packages will have to modify the process.&lt;br /&gt;
* To achieve relaxed UV borders use a mel script called worldSpaceUVLine - it can be found on [http://Highend3d.com/maya/downloads/mel_scripts/modeling/poly_tools/4508.html Highend3D]. Copy the .mel into your ''My Documents\maya\#.#\scripts'' folder and run by typing '''''worldSpaceUVLine;''''' in the Maya command line.&lt;br /&gt;
* Snap all 4 corners to the UV 0-1 square.  Select all the edge uv for one side, and in the worldSpaceUVLine tool select the corresponding UV layout direction (U for horizontal, V for vertical), and press the align UV’s on selected line button. Repeat for each side.&lt;br /&gt;
* Make sure all holes in the mesh are capped, and run the Relax UVs tool, with the option ''Edge Weights'' set to ''World Space'', and ''Pin UV Border'' selected.  Keep repeating Relax UVs until you see no more UV movement.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Perturbate Image (Normal Map) ===&lt;br /&gt;
[[Image:AdvMega_Perturbate.jpg|thumb|200px|right|Perturbate Image (Tangent Space Local Map)]]&lt;br /&gt;
The Perturbate Image is an image that is [[#Construct the Megatexture|applied to the megatexture]], and corrects the low poly mesh normal to match that of the high poly.&lt;br /&gt;
* Load the high and low poly mesh into your preferred 3d Application.&lt;br /&gt;
* Use a surface-sampler (also known as baking textures, or render-to-texture, most good 3D applications will have this capability) to render the high poly normals onto the low poly model, with normals set to &amp;quot;tangent space&amp;quot;.&lt;br /&gt;
* You probably will need to fix the normal map channels (red and green) as the 3D Application use normals maps differently to the Game.  Make sure the green channel has white facing down, and red has white facing right.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Convert World Machine masks to UV space ===&lt;br /&gt;
[[Image:AdvMega_LowPoly.jpg|thumb|400px|right|Low Poly Mesh with Local Map]]&lt;br /&gt;
All the masks created created in World Machine (flow, deposition etc.) won't match the new game mesh UV coordinates&lt;br /&gt;
* Load the high and low poly mesh into your preferred 3D application.&lt;br /&gt;
* Duplicate the game mesh and apply a planar UV projection.&lt;br /&gt;
* Apply the masks created in World Machine to the planar mapped mesh.&lt;br /&gt;
* Surface sample the diffuse from the planar mapped mesh, onto the game UV mesh.&lt;br /&gt;
Also render the mesh normals (world space) to an image.  The blue channel will become useful when creating distribution masks, as it represents how vertical a polygon is.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Prepare Terrain for Megatexture =&lt;br /&gt;
Now the mesh is nearly ready for the game, just a couple more steps.&lt;br /&gt;
&lt;br /&gt;
=== Prepare the Mesh ===&lt;br /&gt;
* Scale the game mesh to the correct size, as after converting from a heightmap it probably isn't the right size.  This tutorial mesh is a small 8,192 x 8,192 unit mesh (again the Enemy Territory : Quake Wars terrains are 32,768 x 32,768).&lt;br /&gt;
* Rename the material to ''megatextures/sdk/terrain_mesh_sdk'' (''megatextures/'''&amp;lt;map_name&amp;gt;'''''). Maya will have problems with this naming convention.&lt;br /&gt;
* Set the Mesh normals to be smooth.&lt;br /&gt;
* Save the mesh to {{filename|/models/terrain/sdk/terrain_mesh_sdk.lwo}} ('''''&amp;lt;map_name&amp;gt;'''.lwo'' or ''.obj'' to {{filename|/models/terrain}}).&lt;br /&gt;
&lt;br /&gt;
=== Setup the Material ===&lt;br /&gt;
* Create a text file called {{filename|/materials/megatextures_sdk.mtr}}&lt;br /&gt;
* Add the following text to create the material:&lt;br /&gt;
 ''material megatextures/sdk/terrain_mesh_sdk	{ useTemplate megatextures/default_ambient&amp;lt; &amp;quot;sdk/terrain_mesh_sdk&amp;quot; &amp;gt; }''&lt;br /&gt;
* Save the file. You will need to restart the whole game and editor before any new files are loaded. If you just added the declaration to an existing ''.mtr'' file, you can just use the {{consolecmd|reloaddecls}} console command.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Construct the Megatexture =&lt;br /&gt;
This section will cover the step by step creation of the Megatexture using Terrain Editor (an inspector tab in EditWorld).  For Detailed explanation on feilds and setting not discussed here, check out the [[Terrain_Editor|Terrain Editor]]&lt;br /&gt;
&lt;br /&gt;
=== Set up the Map ===&lt;br /&gt;
* Load EditWorld, and create a new map.&lt;br /&gt;
* Bring up the [[Terrain Editor]] inspector.&lt;br /&gt;
* {{accelbtn|RMB}} in the left blank (white) area.  In the pop-up menu select ''New'' | ''Tree...''&lt;br /&gt;
* On the Root node set the model field to {{filename|/models/terrain/sdk/terrain_mesh_sdk.lwo}}, and also set the ST Model to the same model.  If you have holes in your mesh (holes cut for buildings), you'd need to make a separate ST Model version with no mesh holes.&lt;br /&gt;
* Seal the map up by [[A_Simple_First_Terrain#Creating a Caulk Hull|Creating a Caulk Hull]].  Make sure the origin of the terrain mesh is inside this hull.&lt;br /&gt;
*For the area to be lit by the sun, create a brush inside the caulk hull, textured with 'editor/outsideportal'.&lt;br /&gt;
*To set the atmosphere create an Atmosphere entity and set '''atmospheredecl''' to '''Valley01''' (or what ever atmosphere you're using).&lt;br /&gt;
&lt;br /&gt;
=== Detail Textures ===&lt;br /&gt;
Also on the Root node is where the detail textures are assigned. In each of the layers created, you assign which of these 4 detail textures to use. Detail Textures need to be a greyscale 512x512 texture (preferably saved in ''base/textures/detail/'').&lt;br /&gt;
{| cellspacing=&amp;quot;8&amp;quot; border=&amp;quot;0&amp;quot;&lt;br /&gt;
|'''Detail Texture 0'''&lt;br /&gt;
|&lt;br /&gt;
|{{filename|textures/detail/temperate_dirt.tga}}&lt;br /&gt;
|-&lt;br /&gt;
|'''Detail Texture 1'''&lt;br /&gt;
|&lt;br /&gt;
|{{filename|textures/detail/temperate_grass.tga}}&lt;br /&gt;
|-&lt;br /&gt;
|'''Detail Texture 2'''&lt;br /&gt;
|&lt;br /&gt;
|{{filename|textures/detail/temperate_gravel.tga}}&lt;br /&gt;
|-&lt;br /&gt;
|'''Detail Texture 3'''&lt;br /&gt;
|&lt;br /&gt;
|{{filename|textures/detail/temperate_rock.tga}}&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Image Sources ===&lt;br /&gt;
Here we'll start to create the texture layers that build up the Megatexture. The steps will progressively skip repetitive information about the layer setup.&lt;br /&gt;
&lt;br /&gt;
;Ground_Base&lt;br /&gt;
* Create a '''Group node''', {{accelbtn|RMB}} and  with the pop-up menu select ''New'' | '''Group'''. In the right field you can enter a name for the Group, we'll name this one '''Ground_Base'''.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;Dirt&lt;br /&gt;
* Now we'll create a base '''Image Source''' node. {{accelbtn|RMB}} over the Group node, and create an '''Image Source''' node, this should create it as a child to the Group.  If you accidently created the Image node under the Root, don't worry as you can drag and release over the Group node to make it a child.  Name the Layer '''Dirt''', same way as the Group node.&lt;br /&gt;
* Apply a Diffuse texture by selecting '''Diffuse''' on the right hand panel of the inspector, then selecting the '''File Name''' field and press the '''...''' button to choose a texture.  For this layer we'll use {{filename|textures/megagen/temperate/dirt_06_d.tga}}&lt;br /&gt;
* Repeat the same process for the '''Local''' image by selecting '''Local''' on the right, and applying the texture {{filename|textures/megagen/temperate/dirt_06_local.tga}}&lt;br /&gt;
* As this is the base layer, the '''Distribution''' needs to cover the whole map.  So apply a full white image the same way as above but to the '''Distribution'''.&lt;br /&gt;
* This layer is a dirt layer so I'll set the the '''Detail Texture Type''' to '''0''', to match the number for the dirt detail texture.&lt;br /&gt;
* Also as this layer is dirt I'll set '''Sur Type Properties''' | '''Type''' to '''dirt'''. For a full list of usable surface types, check the [[Terrain_Editor#Surface_Type|Surface Type]] section.&lt;br /&gt;
* The diffuse texture has the dimensions 1024 x 1024, while the map covers 8192.  To keep the correct texture ratio, set '''Texture Properties''' | '''Scale''' to '''8 8'''.&lt;br /&gt;
* '''Texture Properties''' | '''Rotation''' is set to '''270''' to keep the to match the texture lighting to that of the atmosphere.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:AdvMega_2Layers.png|thumb|300px|right|Blend with Distribution Pattern]]&lt;br /&gt;
;Sand&lt;br /&gt;
* Sand will settle along the flow lines, as it's been washed down with the weather.&lt;br /&gt;
* Create this layer in the same way as the '''Dirt''' layer.  The '''Diffuse''' and '''Local''' can also be set up in the same way except choosing {{filename|textures/megagen/temperate/dirt_07.*}} as the textures.&lt;br /&gt;
* This layer will require a unique '''Distribution''' image.  The flow masks ([[# Convert World Machine masks to UV space|UV corrected]]) created from [[# World Machine: Adding Flow|World Machine]] were used to help create '''textures/megagen/terrain_mesh_sdk/masks/masks_sand.tga''' which is applied as the '''Distribution'''.&lt;br /&gt;
* To make the blend more fitting and unique set the '''Distribution Pattern''' to {{filename|textures/megagen/temperate/dirt_06_mask_inverse.tga}}.  This will blend the '''Sand''' into the cracks of the '''Dirt''' before the peaks (stones).&lt;br /&gt;
* '''Ramp Width''' is changed to '''0.5''' so the blend will become tighter.&lt;br /&gt;
* '''Distribution Pattern Texture Rotation''' and '''Scale''' Should match that of the '''Dirt''' layer, as it's using a Distribution Pattern that matches the dirt.&lt;br /&gt;
* Set the '''Detail Texture Type''' to '''0''' (dirt, as it's the best matching of the four), and the '''Surface Type Properties''' | '''Type''' to '''sand'''.&lt;br /&gt;
* To see how the Megatexture is progressing, render a [[Terrain_Editor#Megatexture_Preview|Megatexture Preview]] [[Image:TerEd_PreviewRender.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;Gravel&lt;br /&gt;
* To give the look off loose stones being scatter from the road.&lt;br /&gt;
* Create in the same way as above.  Was created after the [[#Road_Tool|Road Layer]] being placed.&lt;br /&gt;
* The '''Distribution Pattern''' image for this layer will match it's own gravel diffuse, so the '''Rotation''' and '''Scale''' for the '''Diffuse''' and '''Distribution Pattern''' images should be the same.&lt;br /&gt;
* Set the '''Detail Texture Type''' to '''2''' ({{filename|textures/detail/temperate_gravel.tga}}), and the '''Surface Type Properties''' | '''Type''' to '''gravel'''.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;Dry_Dirt&lt;br /&gt;
* Gives a dried up cracked earth appearance, were standing water would have once been.&lt;br /&gt;
* Slight transparency given so layer blends smoother over light sand and darker dirt, '''Alpha''' set to '''0.75'''&lt;br /&gt;
* '''Ramp Width''' set to '''0.25''' making the blend even tighter (sharper).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;Sticks&lt;br /&gt;
* Helps the grass blend in with the dirt.&lt;br /&gt;
* Created after the grass, then layer moved above by dragging and releasing between the layers '''Grass_Outer''' and '''Dry_Dirt'''.&lt;br /&gt;
* '''Ramp Width''' set to '''0.75''' so the blend can be softer.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;Grass_Outer&lt;br /&gt;
* Texture used is of a patchy grass, good for grass on the edges of a grass clump.&lt;br /&gt;
* '''Distribution Pattern''' texture carefully made so the dirt parts of the diffuse blend in last.&lt;br /&gt;
* Texture '''Rotation''' set to '''300''', this is to break up the look of textures tiling in the same direction.&lt;br /&gt;
* The '''Detail Texture Type''' is set to '''1''' ({{filename|textures/detail/temperate_grass.tga}}), and the '''Surface Type Properties''' | '''Type''' to '''grass'''.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;Grass_Inner&lt;br /&gt;
* Dense Grass, blended to cover the dirt of the patchy grass texture ('''Grass_Outer'''), where the mask become more solid (white).&lt;br /&gt;
* Uses the same '''Distribution''' mask as '''Grass_Outer''', as the '''Distribution Pattern''' texture is made so that it is never stronger than that of the patchy grass.&lt;br /&gt;
* Texture '''Rotation''' and '''Scale''' needs to match that of '''Grass_Outer''' as the '''Distribution Pattern''' textures of both grass layers work together, with the same '''Distribution'''.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;Stones&lt;br /&gt;
* Create the Stone '''Distribution''' after the solid rock layers, as the rock will look better when it blends to the stones.  To find out where rocks are distributed exactly, [[Terrain_Editor#Megatexture_Preview|Preview Render]] the megatexture with the rocks layer tinted black, and only a white base layer.  The Preview Megatexture will be saved to {{filename|base/imagedump/maps/&amp;lt;map_name&amp;gt;}} and flipped vertically.&lt;br /&gt;
* As well as being concentrated around the solid rock sections, stones should flow down the surrounding slopes.&lt;br /&gt;
* Make the Stones more dense around rocks.&lt;br /&gt;
* The '''Distribution Pattern''' texture has been created so the stones will blend in one by one.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:AdvMega_GroundLayers.png|thumb|300px|right|Ground Base Layers]]&lt;br /&gt;
;Pebbles&lt;br /&gt;
* Pebbles in Mud works well around the waterline.&lt;br /&gt;
* The '''Distribution''' mask is made slightly darker where the sand '''Distribution''' is.  This will give good variation, as the Pebbles will blend in first (due to '''Distribution Pattern'''), making them appear to be on sand instead of mud.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;Rock&lt;br /&gt;
* A new '''Group''' is created under the '''Root''' node to keep the rock elements neatly together.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;Rock_Base&lt;br /&gt;
* Rock should usually be created (distributed) near the start of making a Megatexture, as rock usually effects where all other elements will be distributed.&lt;br /&gt;
* Texture '''Rotation''' for both '''Diffuse''' and '''Distribution Pattern''' is set to '''0.45''', this is so the rock diffuse is rotated to match the direction of the rock in the map.  If you have rock in all directions you could make separate rock masks for the different rotations.&lt;br /&gt;
* A '''Heightmap''' image is assigned, {{filename|textures/megagen/temperate/rock_01_h.tga}}.  This will help the '''Rock_Stain_(HeightMap)''' blend into the cracks.&lt;br /&gt;
* Set the '''Propagate Distribution''' to '''true''', by ticking the box.  This will mask any child layers with this layers distribution.&lt;br /&gt;
* The '''Detail Texture Type''' is set to '''3''' ({{filename|textures/detail/temperate_rock.tga}}), and the '''Surface Type Properties''' | '''Type''' to '''stone'''.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;Rock_Smooth&lt;br /&gt;
* By distributing smooth rock on raised and large flat areas, while not in cracks and around rock edges, will help to give it shape.&lt;br /&gt;
* This layer can be set up in the same way as '''Rock_Base''' (including having a heightmap image), except you don't need to '''Propagate Distribution'''.&lt;br /&gt;
* Use the same '''Distribution Pattern''' used in '''Rock_Base''' so the smooth rock will form on the ridges first.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;Rock_Horizontal&lt;br /&gt;
* This layer will use a different technique to create horizontal crack lines in the rock.&lt;br /&gt;
* Most of the settings can be set up in the same way as the previous rock layers.&lt;br /&gt;
* Use the same '''Distribution Pattern''' used in '''Rock_Base''' (including the same scale and rotation).&lt;br /&gt;
* Set the '''Projector Pattern''' image to the horizontal rock distribution pattern ({{filename|textures/megagen/temperate/rock_04_mask.tga}}).&lt;br /&gt;
* Set the last value of the '''Blend Parameters''' giving 0 0 0 '''0.75''', this controls the sharpness off the '''Projector Pattern''' blend.&lt;br /&gt;
* The '''Distribution''' mask should only include steep polygons that face the angle of projection (this will prevent texture stretching).&lt;br /&gt;
* Set '''Image Renderer''' | '''UV Type''' to '''Parallel Side'''.  This will force the layer to render has a side projection.  For this to work correctly, the terrain mesh needs to be centered around the grid origin.&lt;br /&gt;
* Set '''Image Renderer''' | '''Projection Angle''' to '''135''', so the projection is in the direction of the vertical rock face (this will rotate the projection around the Z axis).&lt;br /&gt;
* '''Texture Properties''' | '''Scale''' to '''6 2''', as this is a side projection, the number of tiles should match the side profile of the mesh.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:AdvMega_RockLayers.png|thumb|300px|right|Rock with Horizontal Projection]]&lt;br /&gt;
;Rock_Stain(Heightmap)&lt;br /&gt;
* This layer will create darker staining on the rock, by the use of a heightmap blend.&lt;br /&gt;
* The way this blend method works is it renders all the heightmaps from each of the layers first, and then blends the diffuse &amp;amp; local images into the lower (darker) parts of the heightmap.&lt;br /&gt;
* Assign a black texture ({{filename|textures/megagen/black.tga}}) to the '''Heightmap''' image, this will help the staining occur stronger based on the '''Distribution''' mask.&lt;br /&gt;
* Set the first 2 values of the '''Blend Parameters''' giving '''0.33 0.25''' 0 0 . The first value (0.33) controls the height at which the blend takes place, while the second (0.25) controls the sharpness of the falloff in the blend.&lt;br /&gt;
* Set the '''Color''' of the layer to '''black''', either by texture or color tinting.&lt;br /&gt;
* No '''Local''' map required&lt;br /&gt;
* '''Alpha''' set to 0.5 so the rock texture underneath shows through.&lt;br /&gt;
* '''Detail Texture Type''' set to -1 , this will disable distributing detail textures for this layer.&lt;br /&gt;
* Leave the '''Surface Type Properties''' | '''Type''' field blank.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;Water_Line&lt;br /&gt;
* A new '''Group''' is created under the '''Root''' node to keep the water line elements neatly together.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;Water_Line_(Geometry_Based)&lt;br /&gt;
* This layer will give a look of wet ground.&lt;br /&gt;
* Set the '''Blend''' mode to '''Multiply (d*s)''', this will darken (multiply) over the textures underneath.&lt;br /&gt;
* Assign the '''Diffuse''' to {{filename|textures/megagen/white.tga}}, and '''Color''' tint to '''Hue 0, Saturation 0, Brightness 180'''&lt;br /&gt;
* For the '''Distribution''', change '''Source Type''' to '''geometryBased'''.  '''Enable''' the '''Altitude Upper''', set the '''Value''' to '''800''' (32 units just above the water line), and '''Fuzziness''' to '''0.075''' (the falloff).  '''Resolution''' can be set to '''1024''' (generated texture size of the mask).&lt;br /&gt;
* Again '''Detail Texture Type''' set to -1&lt;br /&gt;
* '''Surface Type Properties''' | '''Type''' set to '''water''', so allow splashes to form on the shoreline.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;Water_Fade_(Geometry_Based)&lt;br /&gt;
* This will help give the water depth (and reduce megatexture size ;)&lt;br /&gt;
* Setup in the same way as '''Water_Line_(Geometry_Based)''' above, except:&lt;br /&gt;
* Set the '''Blend''' mode to '''Blend''', this will cover over the textures underneath (looking similar to fog).&lt;br /&gt;
* '''Color''' tint set to '''Hue 60, Saturation 115, Brightness 22'''&lt;br /&gt;
* With '''Source Type''' set to '''geometryBased''', change the '''Altitude Upper''' | '''Value''' to '''768''' (water height) and '''Fuzziness''' to '''1''' (larger falloff).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;Perturbate&lt;br /&gt;
* Create under the '''Root''' node.  Will bring back the normals to that of the [[#Perturbate Image (Normal Map)|high-res mesh]], improving the baked lighting.&lt;br /&gt;
* Set the '''Blend''' mode to '''Perturbate Normals''', this will add the normals to those already generated by the other layers.&lt;br /&gt;
* Assign no '''Diffuse''' texture.&lt;br /&gt;
* Assign a white texture to the '''Distribution''' (as to cover the whole megatexture).&lt;br /&gt;
* Set the '''Local''' texture to {{filename|textures/megagen/terrain_mesh_sdk/local.tga}} (the mesh's normal map).&lt;br /&gt;
* '''Detail Texture Type''' set to -1&lt;br /&gt;
* Leave the '''Surface Type Properties''' | '''Type''' field blank.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:AdvMega_AmbOcc.jpg|thumb|200px|right|Ambient Occlusion map]]&lt;br /&gt;
;Ambient_Occlusion&lt;br /&gt;
* Also created under the '''Root''' node.  Rendered in ''Maya'' to emulate light being occluded in crevices.&lt;br /&gt;
* Set the '''Blend''' mode to '''Multiply (d*(s*1.6)'''. in this blend mode diffuse image colors darker than 160 will darken the previous layers, while colors brighter than 160 will lighten.&lt;br /&gt;
* Assign {{filename|textures/megagen/terrain_mesh_sdk/ambient_occlusion.tga}} as the Diffuse.  The image is balanced so that areas of no change are around 160 in color brightness.&lt;br /&gt;
* Assign a white texture to the '''Distribution''' (as to cover the whole megatexture).&lt;br /&gt;
* '''Detail Texture Type''' set to -1&lt;br /&gt;
* Leave the '''Surface Type Properties''' | '''Type''' field blank.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Road Tool ===&lt;br /&gt;
Here we'll create a paved road using the [[Terrain_Editor#Road_Node|Road Tool]].&lt;br /&gt;
* First we'll create a '''Road Template (.rtl)''', to assign what textures and surface type to assign to the road.&lt;br /&gt;
* Create a blank text file called {{filename|/megagen/roadtemplates/terrain_mesh_sdk.rtl}} and add the needed information:&lt;br /&gt;
 roadTemplate sdk_main_road {&lt;br /&gt;
     {&lt;br /&gt;
         diffuse image sdTextureTGA_Properties {&lt;br /&gt;
             name &amp;quot;textures/megagen/temperate/road_01_d.tga&amp;quot;&lt;br /&gt;
         }&lt;br /&gt;
         local image sdTextureTGA_Properties {&lt;br /&gt;
             name &amp;quot;textures/megagen/temperate/road_01_local.tga&amp;quot;&lt;br /&gt;
         }&lt;br /&gt;
         distribution image sdTextureTGA_Properties {&lt;br /&gt;
             name &amp;quot;textures/megagen/temperate/road_01_mask.tga&amp;quot;&lt;br /&gt;
         }&lt;br /&gt;
         offset ( -1 1 )&lt;br /&gt;
         surfaceType &amp;quot;pavement&amp;quot;&lt;br /&gt;
         detailtexture &amp;quot;textures/detail/temperate_gravel.tga&amp;quot;&lt;br /&gt;
         }&lt;br /&gt;
 }&lt;br /&gt;
Here we've given the road material a name '''sdk_main_road''', and set the '''Diffuse''', '''Local''', and  '''Mask''' textures.  Also setting the '''Surface Type''' to '''pavemant''', and '''Detail Texture''' to {{filename|textures/detail/temperate_gravel.tga}} (which also must be assigned in the '''Root''' node).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:AdvMega_RoadLayer.png|thumb|300px|right|Road Tool]]&lt;br /&gt;
;Main_Road&lt;br /&gt;
* Create the '''Road''' node, {{accelbtn|RMB}} over the Root node, a pop-up menu will appear and select ''New'' | '''Road'''.&lt;br /&gt;
* Set '''Road Template''' to '''sdk_main_road''', this points the road tool to the correct road template.&lt;br /&gt;
* Start placing the road along the map:&lt;br /&gt;
** Select the node&lt;br /&gt;
** Click on the ''XY Top'' window&lt;br /&gt;
** Enter vertex editing mode ({{accelkey|v}})&lt;br /&gt;
** Hold {{accelkey|Ctrl}}{{accelkey|Shift}} and {{accelbtn|lmb}} in the ''XY Top'' window to start placing the points that make up the road curve.&lt;br /&gt;
* Now to fix the width and direction of the road.&lt;br /&gt;
** You need to be in vertex editing mode if not already (toggled with {{accelkey|v}}).&lt;br /&gt;
** '''Moving Road Points''' {{accelbtn|LMB}}-drag the blue points.&lt;br /&gt;
** '''Change Points Direction''' {{accelbtn|LMB}}-drag the yellow points.&lt;br /&gt;
** '''Change Width of Road''' {{accelbtn|LMB}}-drag out the red points.  Alternatively you can widen the whole road when outside the vertex editing mode by selecting the Road node, then {{accelbtn|LMB}}-drag beside the road.&lt;br /&gt;
** '''Adding new Points''' hold {{accelkey|Ctrl}}{{accelkey|Shift}} and {{accelbtn|lmb}} the area where you want create the new point.&lt;br /&gt;
** '''Deleting Points''' {{accelbtn|LMB}} and hold the blue point you want to delete and press ''Backspace''.&lt;br /&gt;
** Press {{accelkey|Esc}} to exit vertex editing mode.&lt;br /&gt;
* The Road Tool must never cross a mesh border, so make sure you bump in your road by at least one unit.  If it does cross a border the Road Tool will render with an artifact stretching to the mesh corner.&lt;br /&gt;
*Finally move the layer into it's correct place for rendering.  Drag and release the node between the '''Ground_Base''' and '''Rock''' group node.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Projector ===&lt;br /&gt;
Using the projector node, localized texture detail can be projected onto the megatexture.&lt;br /&gt;
&lt;br /&gt;
;Projectors&lt;br /&gt;
Created a groups to keep things nice an neat.&lt;br /&gt;
&lt;br /&gt;
;Cracked_Road&lt;br /&gt;
* To give the look of cracked tar where the crater nears the road.&lt;br /&gt;
* Create the '''Road Node''', {{accelbtn|RMB}} over the '''Projectors''' Group node, a pop-up menu will appear and select ''New'' | '''Projector'''.&lt;br /&gt;
* Setup the '''Projector''' the same way you would a standard '''Image Source''' node, except you only need a '''Distribution''' mask (and not a '''Distributed Pattern), as the texture shouldn't be projected larger than the source textures.&lt;br /&gt;
* To place the projector move/scale/rotate as you would a normal brush (including vertex editing).  The projector should be positioned above the terrain mesh.&lt;br /&gt;
&lt;br /&gt;
;Crater&lt;br /&gt;
* Places the crater scorch marks.&lt;br /&gt;
* Setup the same way as '''Cracked_Road'''.&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
* [[A Simple First Megatexture]] - start here for a basic MegaTexture tutorial&lt;br /&gt;
* [[Generate a MegaTexture]] - steps for generating a MegaTexture from the SDK launcher.&lt;br /&gt;
&lt;br /&gt;
[[Category:Art]]&lt;br /&gt;
[[Category:Basic Level Design]]&lt;br /&gt;
[[Category:Tutorials]]&lt;/div&gt;</summary>
		<author><name>Ducks</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.splashdamage.com/index.php?title=An_Advanced_Terrain_and_Megatexture&amp;diff=4074</id>
		<title>An Advanced Terrain and Megatexture</title>
		<link rel="alternate" type="text/html" href="https://wiki.splashdamage.com/index.php?title=An_Advanced_Terrain_and_Megatexture&amp;diff=4074"/>
		<updated>2007-12-18T09:25:00Z</updated>

		<summary type="html">&lt;p&gt;Ducks: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Image:AdvMega_Intro.jpg|thumb|500px|right]]&lt;br /&gt;
This guide will show you step by step, on how to create a detailed Megatextured Terrain.&lt;br /&gt;
&lt;br /&gt;
= Introduction =&lt;br /&gt;
'''For this tutorial you must:'''&lt;br /&gt;
* Have a modelling package that can export as LWO, ASE or OBJ&lt;br /&gt;
* Have basic modelling skills&lt;br /&gt;
* Have basic mapping skills, as in [[A Simple First Terrain]]&lt;br /&gt;
&lt;br /&gt;
'''This tutorial covers:'''&lt;br /&gt;
* Steps to create a detailed terrain mesh.&lt;br /&gt;
* How to assign the Megatexture&lt;br /&gt;
* How to add the terrain mesh to a map&lt;br /&gt;
* How to make a Megatexture&lt;br /&gt;
* How to compile a Megatexture&lt;br /&gt;
* How to add Water to a map&lt;br /&gt;
&lt;br /&gt;
'''Programs used in this tutorial are:'''&lt;br /&gt;
* Mudbox&lt;br /&gt;
* World Machine&lt;br /&gt;
* Lightwave&lt;br /&gt;
* Maya (only used briefly)&lt;br /&gt;
Other similar programs can be used instead of these, but wont be covered in this tutorial.&lt;br /&gt;
&lt;br /&gt;
'''This tutorial does not cover in detail:'''&lt;br /&gt;
* How to use Mudbox / ZBrush / World Machine / Blender / Lightwave / Maya / 3DSMax&lt;br /&gt;
&lt;br /&gt;
'''If you already have a terrain mesh''', and do not want to use Mudbox and World Machine, skip to [[#Prepare Terrain for Megatexture|Prepare Terrain for Megatexture]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Mudbox: Shape the Terrain =&lt;br /&gt;
[[Image:AdvMega_Mudbox.jpg|thumb|128px|right|Mudbox Layers]]&lt;br /&gt;
These are the basic steps for sculpting a terrain in Mudbox.&lt;br /&gt;
* Create a plane, and subdivide (but still keep a low tessellation).&lt;br /&gt;
* Change any tools you use to have the edit ''Direction'' set to ''Y'' axis.&lt;br /&gt;
* Create a new Layer, and sculpt the rough layout for the terrain.&lt;br /&gt;
* Subdivide again to the level of detail you want (or can).&lt;br /&gt;
* Create another layer, and sculpt more details into the terrain.&lt;br /&gt;
* Export to OBJ.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
= Convert Mesh to Heightmap =&lt;br /&gt;
This step is needed if you want to import your current terrain mesh into World Machine.&lt;br /&gt;
* Firstly, rotate the terrain mesh. In Lightwave, rotate -90° around the X axis. For 3ds Max &amp;amp; Maya, rotate +90° around the X axis.&lt;br /&gt;
* Cap any holes in the mesh, and triangulate the mesh.&lt;br /&gt;
* Using a machine with an nVidia graphics card, run the following command in the ETQW console to get the heightmap (where &amp;lt;model&amp;gt; is the relative path of the ''.lwo'', ''.obj'' or ''.ase'' mesh):&lt;br /&gt;
** {{consolecmd|RenderBumpFlat –floatHeightmap -size 2048 2048 &amp;lt;model&amp;gt;}}&lt;br /&gt;
* An ''.r32'' (raw 32-bit) heightmap will be saved into the same folder as your model, this heightmap can be used in World Machine.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= World Machine: Adding Flow =&lt;br /&gt;
[[Image:AdvMega_WorldMachine.jpg|thumb|320px|right|World Machine Device View]]&lt;br /&gt;
[http://www.world-machine.com World Machine] is used to add erosion flow lines to the terrain.  It's also useful as the flow maps can be exported to help create masks for texture distribution later in [[Terrain_Editor|Terrain Editor]].  These are the basic steps made to build the World Machine device nodes.&lt;br /&gt;
&lt;br /&gt;
* Blend the heightmap made from the Mudbox mesh with ''Perlin Noise'' to help the ''Erosion'' filters.&lt;br /&gt;
* Use a ''Snow'' filter around the rocks (mask used), so rocks look like they are sitting in soil.&lt;br /&gt;
* Pass the heightmap through two ''Erosion'' nodes, which are set up differently, and combined give a natural flowing look.  Both ''Erosion'' nodes are masked around the rocks, so they will keep their shape.  The first ''Erosion'' node is setup as ''Channeled Erosion'' with an ''Inverse Filter'', carving large flow lines into the terrain.  The Second is a ''Channeled Erosion'' set with ''No Filter'' , adding finer detailed flow lines.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
[[Image:AdvMega_WM_Output.jpg|thumb|150px|right|World Machine Heightmap]]&lt;br /&gt;
* The heightmap output of the erosion is split so the heightmap can be saved (and later used to create a mesh), and further filters created (sediment and normal map) to help make masks for texture distribution later.&lt;br /&gt;
&lt;br /&gt;
[[Image:AdvMega_WM_Flow.jpg|thumb|100px|right|Flow Map]]&lt;br /&gt;
* ''Flow'' and ''Deposition'' maps from the Erosion nodes are passed through ''Simple Transformation'' nodes that brighten the output saved.&lt;br /&gt;
* The heightmap saved above is imported and rendered at a lower (usable) resolution to the ''Mesh Output'' node creating an OBJ mesh.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This World Machine example was given using World Machine 2, which is currently in [http://www.world-machine.com/blog/ Beta].  A couple of features show aren't available in World Machine v1.25.  They are the ''Snow'' node (which isn't needed) and ''Mesh Output''. An alternative to creating a mesh from a heightmap [[Making_a_Terrain_Model#Optimising_to_Game_Mesh|can be found here]].&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= High to Low poly =&lt;br /&gt;
=== Optimizing ===&lt;br /&gt;
[[Image:AdvMega Dags.jpg|thumb|320px|right|Dangling border polygons to delete]]&lt;br /&gt;
This stage will briefly explain how the high-poly mesh exported from World Machine can be optimized down to the low poly game mesh.&lt;br /&gt;
* Load the OBJ exported from [[#World Machine: Adding Flow|World Machine]] into your preferred 3d Application.&lt;br /&gt;
* Rotate so it's orientated correctly.&lt;br /&gt;
* The outer mesh border will look like it's been dragged down (an artifact from the mesh being built from a heightmap). So remove this by selecting the mesh border polygons, and delete them.&lt;br /&gt;
* Triangulate the mesh and save out as ''.OBJ'', so it can be loaded into Lightwave.&lt;br /&gt;
* In Lightwave, use a plug-in called [http://amber.rc.arizona.edu/lw/qemloss3.html qemLOSS3] (once installed, found in the Utilities tab) to reduce the polygons to a reasonable amount (ETQW used around 30,000 polygons for the 32,768 unit width terrain).  If you have trouble running qemLOSS3, apply a different material other than the default.&lt;br /&gt;
* Fix edges that are triangulated in the wrong direction.&lt;br /&gt;
* Smooth subdivide the mesh, and run your mesh through qemLOSS3 again (to the same polygon count as before).  This will give a smoother terrain, easier for player movement and with less harsh silhouette angles. Repeat until you're happy with the mesh smoothness.&lt;br /&gt;
* Again fix edges that are triangulated in the wrong direction (these show up most obviously by applying a shiny material, and making sure the mesh has a single smoothing group (all soft edges, 180 degree smoothing angle).&lt;br /&gt;
* If you plan on having water, cut the mesh along the waterline, so no polygons are both above or below the water.  This is so the [[#Water Fog|water fog]] has a clear line to stop at.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== UV the Terrain ===&lt;br /&gt;
[[Image:AdvMega_UV.png|thumb|200px|right|UV Layout]]&lt;br /&gt;
This process is written for Maya, other 3d packages will have to modify the process.&lt;br /&gt;
* To achieve relaxed UV borders use a mel script called worldSpaceUVLine - it can be found on [http://Highend3d.com/maya/downloads/mel_scripts/modeling/poly_tools/4508.html Highend3D]. Copy the .mel into your ''My Documents\maya\#.#\scripts'' folder and run by typing '''''worldSpaceUVLine;''''' in the Maya command line.&lt;br /&gt;
* Snap all 4 corners to the UV 0-1 square.  Select all the edge uv for one side, and in the worldSpaceUVLine tool select the corresponding UV layout direction (U for horizontal, V for vertical), and press the align UV’s on selected line button. Repeat for each side.&lt;br /&gt;
* Make sure all holes in the mesh are capped, and run the Relax UVs tool, with the option ''Edge Weights'' set to ''World Space'', and ''Pin UV Border'' selected.  Keep repeating Relax UVs until you see no more UV movement.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Perturbate Image (Normal Map) ===&lt;br /&gt;
[[Image:AdvMega_Perturbate.jpg|thumb|200px|right|Perturbate Image (Tangent Space Local Map)]]&lt;br /&gt;
The Perturbate Image is an image that is [[#Construct the Megatexture|applied to the megatexture]], and corrects the low poly mesh normal to match that of the high poly.&lt;br /&gt;
* Load the high and low poly mesh into your preferred 3d Application.&lt;br /&gt;
* Use a surface-sampler (also known as baking textures, or render-to-texture, most good 3D applications will have this capability) to render the high poly normals onto the low poly model, with normals set to &amp;quot;tangent space&amp;quot;.&lt;br /&gt;
* You probably will need to fix the normal map channels (red and green) as the 3D Application use normals maps differently to the Game.  Make sure the green channel has white facing down, and red has white facing right.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Convert World Machine masks to UV space ===&lt;br /&gt;
[[Image:AdvMega_LowPoly.jpg|thumb|400px|right|Low Poly Mesh with Local Map]]&lt;br /&gt;
All the masks created created in World Machine (flow, deposition etc.) won't match the new game mesh UV coordinates&lt;br /&gt;
* Load the high and low poly mesh into your preferred 3D application.&lt;br /&gt;
* Duplicate the game mesh and apply a planar UV projection.&lt;br /&gt;
* Apply the masks created in World Machine to the planar mapped mesh.&lt;br /&gt;
* Surface sample the diffuse from the planar mapped mesh, onto the game UV mesh.&lt;br /&gt;
Also render the mesh normals (world space) to an image.  The blue channel will become useful when creating distribution masks, as it represents how vertical a polygon is.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Prepare Terrain for Megatexture =&lt;br /&gt;
Now the mesh is nearly ready for the game, just a couple more steps.&lt;br /&gt;
&lt;br /&gt;
=== Prepare the Mesh ===&lt;br /&gt;
* Scale the game mesh to the correct size, as after converting from a heightmap it probably isn't the right size.  This tutorial mesh is a small 8,192 x 8,192 unit mesh (again the Enemy Territory : Quake Wars terrains are 32,768 x 32,768).&lt;br /&gt;
* Rename the material to ''megatextures/sdk/terrain_mesh_sdk'' (''megatextures/'''&amp;lt;map_name&amp;gt;'''''). Maya will have problems with this naming convention.&lt;br /&gt;
* Set the Mesh normals to be smooth.&lt;br /&gt;
* Save the mesh to {{filename|/models/terrain/sdk/terrain_mesh_sdk.lwo}} ('''''&amp;lt;map_name&amp;gt;'''.lwo'' or ''.obj'' to {{filename|/models/terrain}}).&lt;br /&gt;
&lt;br /&gt;
=== Setup the Material ===&lt;br /&gt;
* Create a text file called {{filename|/materials/megatextures_sdk.mtr}}&lt;br /&gt;
* Add the following text to create the material:&lt;br /&gt;
 ''material megatextures/sdk/terrain_mesh_sdk	{ useTemplate megatextures/default_ambient&amp;lt; &amp;quot;sdk/terrain_mesh_sdk&amp;quot; &amp;gt; }''&lt;br /&gt;
* Save the file. You will need to restart the whole game and editor before any new files are loaded. If you just added the declaration to an existing ''.mtr'' file, you can just use the {{consolecmd|reloaddecls}} console command.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Construct the Megatexture =&lt;br /&gt;
This section will cover the step by step creation of the Megatexture using Terrain Editor (an inspector tab in EditWorld).  For Detailed explanation on feilds and setting not discussed here, check out the [[Terrain_Editor|Terrain Editor]]&lt;br /&gt;
&lt;br /&gt;
=== Set up the Map ===&lt;br /&gt;
* Load EditWorld, and create a new map.&lt;br /&gt;
* Bring up the [[Terrain Editor]] inspector.&lt;br /&gt;
* {{accelbtn|RMB}} in the left blank (white) area.  In the pop-up menu select ''New'' | ''Tree...''&lt;br /&gt;
* On the Root node set the model field to {{filename|/models/terrain/sdk/terrain_mesh_sdk.lwo}}, and also set the ST Model to the same model.  If you have holes in your mesh (holes cut for buildings), you'd need to make a separate ST Model version with no mesh holes.&lt;br /&gt;
* Seal the map up by [[A_Simple_First_Terrain#Creating a Caulk Hull|Creating a Caulk Hull]].  Make sure the origin of the terrain mesh is inside this hull.&lt;br /&gt;
*For the area to be lit by the sun, create a brush inside the caulk hull, textured with 'editor/outsideportal'.&lt;br /&gt;
*To set the atmosphere create an Atmosphere entity and set '''atmospheredecl''' to '''Valley01''' (or what ever atmosphere you're using).&lt;br /&gt;
&lt;br /&gt;
=== Detail Textures ===&lt;br /&gt;
Also on the Root node is where the detail textures are assigned. In each of the layers created, you assign which of these 4 detail textures to use. Detail Textures need to be a greyscale 512x512 texture (preferably saved in ''base/textures/detail/'').&lt;br /&gt;
{| cellspacing=&amp;quot;8&amp;quot; border=&amp;quot;0&amp;quot;&lt;br /&gt;
|'''Detail Texture 0'''&lt;br /&gt;
|&lt;br /&gt;
|{{filename|textures/detail/temperate_dirt.tga}}&lt;br /&gt;
|-&lt;br /&gt;
|'''Detail Texture 1'''&lt;br /&gt;
|&lt;br /&gt;
|{{filename|textures/detail/temperate_grass.tga}}&lt;br /&gt;
|-&lt;br /&gt;
|'''Detail Texture 2'''&lt;br /&gt;
|&lt;br /&gt;
|{{filename|textures/detail/temperate_gravel.tga}}&lt;br /&gt;
|-&lt;br /&gt;
|'''Detail Texture 3'''&lt;br /&gt;
|&lt;br /&gt;
|{{filename|textures/detail/temperate_rock.tga}}&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Image Sources ===&lt;br /&gt;
Here we'll start to create the texture layers that build up the Megatexture. The steps will progressively skip repetitive information about the layer setup.&lt;br /&gt;
&lt;br /&gt;
;Ground_Base&lt;br /&gt;
* Create a '''Group node''', {{accelbtn|RMB}} and  with the pop-up menu select ''New'' | '''Group'''. In the right field you can enter a name for the Group, we'll name this one '''Ground_Base'''.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;Dirt&lt;br /&gt;
* Now we'll create a base '''Image Source''' node. {{accelbtn|RMB}} over the Group node, and create an '''Image Source''' node, this should create it as a child to the Group.  If you accidently created the Image node under the Root, don't worry as you can drag and release over the Group node to make it a child.  Name the Layer '''Dirt''', same way as the Group node.&lt;br /&gt;
* Apply a Diffuse texture by selecting '''Diffuse''' on the right hand panel of the inspector, then selecting the '''File Name''' field and press the '''...''' button to choose a texture.  For this layer we'll use {{filename|textures/megagen/temperate/dirt_06_d.tga}}&lt;br /&gt;
* Repeat the same process for the '''Local''' image by selecting '''Local''' on the right, and applying the texture {{filename|textures/megagen/temperate/dirt_06_local.tga}}&lt;br /&gt;
* As this is the base layer, the '''Distribution''' needs to cover the whole map.  So apply a full white image the same way as above but to the '''Distribution'''.&lt;br /&gt;
* This layer is a dirt layer so I'll set the the '''Detail Texture Type''' to '''0''', to match the number for the dirt detail texture.&lt;br /&gt;
* Also as this layer is dirt I'll set '''Sur Type Properties''' | '''Type''' to '''dirt'''. For a full list of usable surface types, check the [[Terrain_Editor#Surface_Type|Surface Type]] section.&lt;br /&gt;
* The diffuse texture has the dimensions 1024 x 1024, while the map covers 8192.  To keep the correct texture ratio, set '''Texture Properties''' | '''Scale''' to '''8 8'''.&lt;br /&gt;
* '''Texture Properties''' | '''Rotation''' is set to '''270''' to keep the to match the texture lighting to that of the atmosphere.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:AdvMega_2Layers.png|thumb|300px|right|Blend with Distribution Pattern]]&lt;br /&gt;
;Sand&lt;br /&gt;
* Sand will settle along the flow lines, as it's been washed down with the weather.&lt;br /&gt;
* Create this layer in the same way as the '''Dirt''' layer.  The '''Diffuse''' and '''Local''' can also be set up in the same way except choosing {{filename|textures/megagen/temperate/dirt_07.*}} as the textures.&lt;br /&gt;
* This layer will require a unique '''Distribution''' image.  The flow masks ([[# Convert World Machine masks to UV space|UV corrected]]) created from [[# World Machine: Adding Flow|World Machine]] were used to help create '''textures/megagen/terrain_mesh_sdk/masks/masks_sand.tga''' which is applied as the '''Distribution'''.&lt;br /&gt;
* To make the blend more fitting and unique set the '''Distribution Pattern''' to {{filename|textures/megagen/temperate/dirt_06_mask_inverse.tga}}.  This will blend the '''Sand''' into the cracks of the '''Dirt''' before the peaks (stones).&lt;br /&gt;
* '''Ramp Width''' is changed to '''0.5''' so the blend will become tighter.&lt;br /&gt;
* '''Distribution Pattern Texture Rotation''' and '''Scale''' Should match that of the '''Dirt''' layer, as it's using a Distribution Pattern that matches the dirt.&lt;br /&gt;
* Set the '''Detail Texture Type''' to '''0''' (dirt, as it's the best matching of the four), and the '''Surface Type Properties''' | '''Type''' to '''sand'''.&lt;br /&gt;
* To see how the Megatexture is progressing, render a [[Terrain_Editor#Megatexture_Preview|Megatexture Preview]] [[Image:TerEd_PreviewRender.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;Gravel&lt;br /&gt;
* To give the look off loose stones being scatter from the road.&lt;br /&gt;
* Create in the same way as above.  Was created after the [[#Road_Tool|Road Layer]] being placed.&lt;br /&gt;
* The '''Distribution Pattern''' image for this layer will match it's own gravel diffuse, so the '''Rotation''' and '''Scale''' for the '''Diffuse''' and '''Distribution Pattern''' images should be the same.&lt;br /&gt;
* Set the '''Detail Texture Type''' to '''2''' ({{filename|textures/detail/temperate_gravel.tga}}), and the '''Surface Type Properties''' | '''Type''' to '''gravel'''.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;Dry_Dirt&lt;br /&gt;
* Gives a dried up cracked earth appearance, were standing water would have once been.&lt;br /&gt;
* Slight transparency given so layer blends smoother over light sand and darker dirt, '''Alpha''' set to '''0.75'''&lt;br /&gt;
* '''Ramp Width''' set to '''0.25''' making the blend even tighter (sharper).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;Sticks&lt;br /&gt;
* Helps the grass blend in with the dirt.&lt;br /&gt;
* Created after the grass, then layer moved above by dragging and releasing between the layers '''Grass_Outer''' and '''Dry_Dirt'''.&lt;br /&gt;
* '''Ramp Width''' set to '''0.75''' so the blend can be softer.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;Grass_Outer&lt;br /&gt;
* Texture used is of a patchy grass, good for grass on the edges of a grass clump.&lt;br /&gt;
* '''Distribution Pattern''' texture carefully made so the dirt parts of the diffuse blend in last.&lt;br /&gt;
* Texture '''Rotation''' set to '''300''', this is to break up the look of textures tiling in the same direction.&lt;br /&gt;
* The '''Detail Texture Type''' is set to '''1''' ({{filename|textures/detail/temperate_grass.tga}}), and the '''Surface Type Properties''' | '''Type''' to '''grass'''.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;Grass_Inner&lt;br /&gt;
* Dense Grass, blended to cover the dirt of the patchy grass texture ('''Grass_Outer'''), where the mask become more solid (white).&lt;br /&gt;
* Uses the same '''Distribution''' mask as '''Grass_Outer''', as the '''Distribution Pattern''' texture is made so that it is never stronger than that of the patchy grass.&lt;br /&gt;
* Texture '''Rotation''' and '''Scale''' needs to match that of '''Grass_Outer''' as the '''Distribution Pattern''' textures of both grass layers work together, with the same '''Distribution'''.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;Stones&lt;br /&gt;
* Create the Stone '''Distribution''' after the solid rock layers, as the rock will look better when it blends to the stones.  To find out where rocks are distributed exactly, [[Terrain_Editor#Megatexture_Preview|Preview Render]] the megatexture with the rocks layer tinted black, and only a white base layer.  The Preview Megatexture will be saved to {{filename|base/imagedump/maps/&amp;lt;map_name&amp;gt;}} and flipped vertically.&lt;br /&gt;
* As well as being concentrated around the solid rock sections, stones should flow down the surrounding slopes.&lt;br /&gt;
* Make the Stones more dense around rocks.&lt;br /&gt;
* The '''Distribution Pattern''' texture has been created so the stones will blend in one by one.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:AdvMega_GroundLayers.png|thumb|300px|right|Ground Base Layers]]&lt;br /&gt;
;Pebbles&lt;br /&gt;
* Pebbles in Mud works well around the waterline.&lt;br /&gt;
* The '''Distribution''' mask is made slightly darker where the sand '''Distribution''' is.  This will give good variation, as the Pebbles will blend in first (due to '''Distribution Pattern'''), making them appear to be on sand instead of mud.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;Rock&lt;br /&gt;
* A new '''Group''' is created under the '''Root''' node to keep the rock elements neatly together.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;Rock_Base&lt;br /&gt;
* Rock should usually be created (distributed) near the start of making a Megatexture, as rock usually effects where all other elements will be distributed.&lt;br /&gt;
* Texture '''Rotation''' for both '''Diffuse''' and '''Distribution Pattern''' is set to '''0.45''', this is so the rock diffuse is rotated to match the direction of the rock in the map.  If you have rock in all directions you could make separate rock masks for the different rotations.&lt;br /&gt;
* A '''Heightmap''' image is assigned, {{filename|textures/megagen/temperate/rock_01_h.tga}}.  This will help the '''Rock_Stain_(HeightMap)''' blend into the cracks.&lt;br /&gt;
* Set the '''Propagate Distribution''' to '''true''', by ticking the box.  This will mask any child layers with this layers distribution.&lt;br /&gt;
* The '''Detail Texture Type''' is set to '''3''' ({{filename|textures/detail/temperate_rock.tga}}), and the '''Surface Type Properties''' | '''Type''' to '''stone'''.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;Rock_Smooth&lt;br /&gt;
* By distributing smooth rock on raised and large flat areas, while not in cracks and around rock edges, will help to give it shape.&lt;br /&gt;
* This layer can be set up in the same way as '''Rock_Base''' (including having a heightmap image), except you don't need to '''Propagate Distribution'''.&lt;br /&gt;
* Use the same '''Distribution Pattern''' used in '''Rock_Base''' so the smooth rock will form on the ridges first.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;Rock_Horizontal&lt;br /&gt;
* This layer will use a different technique to create horizontal crack lines in the rock.&lt;br /&gt;
* Most of the settings can be set up in the same way as the previous rock layers.&lt;br /&gt;
* Use the same '''Distribution Pattern''' used in '''Rock_Base''' (including the same scale and rotation).&lt;br /&gt;
* Set the '''Projector Pattern''' image to the horizontal rock distribution pattern ({{filename|textures/megagen/temperate/rock_04_mask.tga}}).&lt;br /&gt;
* Set the last value of the '''Blend Parameters''' giving 0 0 0 '''0.75''', this controls the sharpness off the '''Projector Pattern''' blend.&lt;br /&gt;
* The '''Distribution''' mask should only include steep polygons that face the angle of projection (this will prevent texture stretching).&lt;br /&gt;
* Set '''Image Renderer''' | '''UV Type''' to '''Parallel Side'''.  This will force the layer to render has a side projection.  For this to work correctly, the terrain mesh needs to be centered around the grid origin.&lt;br /&gt;
* Set '''Image Renderer''' | '''Projection Angle''' to '''135''', so the projection is in the direction of the vertical rock face (this will rotate the projection around the Z axis).&lt;br /&gt;
* '''Texture Properties''' | '''Scale''' to '''6 2''', as this is a side projection, the number of tiles should match the side profile of the mesh.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:AdvMega_RockLayers.png|thumb|300px|right|Rock with Horizontal Projection]]&lt;br /&gt;
;Rock_Stain(Heightmap)&lt;br /&gt;
* This layer will create darker staining on the rock, by the use of a heightmap blend.&lt;br /&gt;
* The way this blend method works is it renders all the heightmaps from each of the layers first, and then blends the diffuse &amp;amp; local images into the lower (darker) parts of the heightmap.&lt;br /&gt;
* Assign a black texture ({{filename|textures/megagen/black.tga}}) to the '''Heightmap''' image, this will help the staining occur stronger based on the '''Distribution''' mask.&lt;br /&gt;
* Set the first 2 values of the '''Blend Parameters''' giving '''0.33 0.25''' 0 0 . The first value (0.33) controls the height at which the blend takes place, while the second (0.25) controls the sharpness of the falloff in the blend.&lt;br /&gt;
* Set the '''Color''' of the layer to '''black''', either by texture or color tinting.&lt;br /&gt;
* No '''Local''' map required&lt;br /&gt;
* '''Alpha''' set to 0.5 so the rock texture underneath shows through.&lt;br /&gt;
* '''Detail Texture Type''' set to -1 , this will disable distributing detail textures for this layer.&lt;br /&gt;
* Leave the '''Surface Type Properties''' | '''Type''' field blank.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;Water_Line&lt;br /&gt;
* A new '''Group''' is created under the '''Root''' node to keep the water line elements neatly together.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;Water_Line_(Geometry_Based)&lt;br /&gt;
* This layer will give a look of wet ground.&lt;br /&gt;
* Set the '''Blend''' mode to '''Multiply (d*s)''', this will darken (multiply) over the textures underneath.&lt;br /&gt;
* Assign the '''Diffuse''' to {{filename|textures/megagen/white.tga}}, and '''Color''' tint to '''Hue 0, Saturation 0, Brightness 180'''&lt;br /&gt;
* For the '''Distribution''', change '''Source Type''' to '''geometryBased'''.  '''Enable''' the '''Altitude Upper''', set the '''Value''' to '''800''' (32 units just above the water line), and '''Fuzziness''' to '''0.075''' (the falloff).  '''Resolution''' can be set to '''1024''' (generated texture size of the mask).&lt;br /&gt;
* Again '''Detail Texture Type''' set to -1&lt;br /&gt;
* '''Surface Type Properties''' | '''Type''' set to '''water''', so allow splashes to form on the shoreline.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;Water_Fade_(Geometry_Based)&lt;br /&gt;
* This will help give the water depth (and reduce megatexture size ;)&lt;br /&gt;
* Setup in the same way as '''Water_Line_(Geometry_Based)''' above, except:&lt;br /&gt;
* Set the '''Blend''' mode to '''Blend''', this will cover over the textures underneath (looking similar to fog).&lt;br /&gt;
* '''Color''' tint set to '''Hue 60, Saturation 115, Brightness 22'''&lt;br /&gt;
* With '''Source Type''' set to '''geometryBased''', change the '''Altitude Upper''' | '''Value''' to '''768''' (water height) and '''Fuzziness''' to '''1''' (larger falloff).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;Perturbate&lt;br /&gt;
* Create under the '''Root''' node.  Will bring back the normals to that of the [[#Perturbate Image (Normal Map)|high-res mesh]], improving the baked lighting.&lt;br /&gt;
* Set the '''Blend''' mode to '''Perturbate Normals''', this will add the normals to those already generated by the other layers.&lt;br /&gt;
* Assign no '''Diffuse''' texture.&lt;br /&gt;
* Assign a white texture to the '''Distribution''' (as to cover the whole megatexture).&lt;br /&gt;
* Set the '''Local''' texture to {{filename|textures/megagen/terrain_mesh_sdk/local.tga}} (the mesh's normal map).&lt;br /&gt;
* '''Detail Texture Type''' set to -1&lt;br /&gt;
* Leave the '''Surface Type Properties''' | '''Type''' field blank.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:AdvMega_AmbOcc.jpg|thumb|200px|right|Ambient Occlusion map]]&lt;br /&gt;
;Ambient_Occlusion&lt;br /&gt;
* Also created under the '''Root''' node.  Rendered in ''Maya'' to emulate light being occluded in crevices.&lt;br /&gt;
* Set the '''Blend''' mode to '''Multiply (d*(s*1.6)'''. in this blend mode diffuse image colors darker than 160 will darken the previous layers, while colors brighter than 160 will lighten.&lt;br /&gt;
* Assign {{filename|textures/megagen/terrain_mesh_sdk/ambient_occlusion.tga}} as the Diffuse.  The image is balanced so that areas of no change are around 160 in color brightness.&lt;br /&gt;
* Assign a white texture to the '''Distribution''' (as to cover the whole megatexture).&lt;br /&gt;
* '''Detail Texture Type''' set to -1&lt;br /&gt;
* Leave the '''Surface Type Properties''' | '''Type''' field blank.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Road Tool ===&lt;br /&gt;
Here we'll create a paved road using the [[Terrain_Editor#Road_Node|Road Tool]].&lt;br /&gt;
* First we'll create a '''Road Template (.rtl)''', to assign what textures and surface type to assign to the road.&lt;br /&gt;
* Create a blank text file called {{filename|/megagen/roadtemplates/terrain_mesh_sdk.rtl}} and add the needed information:&lt;br /&gt;
 roadTemplate sdk_main_road {&lt;br /&gt;
     {&lt;br /&gt;
         diffuse image sdTextureTGA_Properties {&lt;br /&gt;
             name &amp;quot;textures/megagen/temperate/road_01_d.tga&amp;quot;&lt;br /&gt;
         }&lt;br /&gt;
         local image sdTextureTGA_Properties {&lt;br /&gt;
             name &amp;quot;textures/megagen/temperate/road_01_local.tga&amp;quot;&lt;br /&gt;
         }&lt;br /&gt;
         distribution image sdTextureTGA_Properties {&lt;br /&gt;
             name &amp;quot;textures/megagen/temperate/road_01_mask.tga&amp;quot;&lt;br /&gt;
         }&lt;br /&gt;
         offset ( -1 1 )&lt;br /&gt;
         surfaceType &amp;quot;pavement&amp;quot;&lt;br /&gt;
         detailtexture &amp;quot;textures/detail/temperate_gravel.tga&amp;quot;&lt;br /&gt;
         }&lt;br /&gt;
 }&lt;br /&gt;
Here we've given the road material a name '''sdk_main_road''', and set the '''Diffuse''', '''Local''', and  '''Mask''' textures.  Also setting the '''Surface Type''' to '''pavemant''', and '''Detail Texture''' to {{filename|textures/detail/temperate_gravel.tga}} (which also must be assigned in the '''Root''' node).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:AdvMega_RoadLayer.png|thumb|300px|right|Road Tool]]&lt;br /&gt;
;Main_Road&lt;br /&gt;
* Create the '''Road''' node, {{accelbtn|RMB}} over the Root node, a pop-up menu will appear and select ''New'' | '''Road'''.&lt;br /&gt;
* Set '''Road Template''' to '''sdk_main_road''', this points the road tool to the correct road template.&lt;br /&gt;
* Start placing the road along the map:&lt;br /&gt;
** Select the node&lt;br /&gt;
** Click on the ''XY Top'' window&lt;br /&gt;
** Enter vertex editing mode ({{accelkey|v}})&lt;br /&gt;
** Hold {{accelkey|Ctrl}}{{accelkey|Shift}} and {{accelbtn|lmb}} in the ''XY Top'' window to start placing the points that make up the road curve.&lt;br /&gt;
* Now to fix the width and direction of the road.&lt;br /&gt;
** You need to be in vertex editing mode if not already (toggled with {{accelkey|v}}).&lt;br /&gt;
** '''Moving Road Points''' {{accelbtn|LMB}}-drag the blue points.&lt;br /&gt;
** '''Change Points Direction''' {{accelbtn|LMB}}-drag the yellow points.&lt;br /&gt;
** '''Change Width of Road''' {{accelbtn|LMB}}-drag out the red points.  Alternatively you can widen the whole road when outside the vertex editing mode by selecting the Road node, then {{accelbtn|LMB}}-drag beside the road.&lt;br /&gt;
** '''Adding new Points''' hold {{accelkey|Ctrl}}{{accelkey|Shift}} and {{accelbtn|lmb}} the area where you want create the new point.&lt;br /&gt;
** '''Deleting Points''' {{accelbtn|LMB}} and hold the blue point you want to delete and press ''Backspace''.&lt;br /&gt;
** Press {{accelkey|Esc}} to exit vertex editing mode.&lt;br /&gt;
* The Road Tool must never cross a mesh border, so make sure you bump in your road by at least one unit.  If it does cross a border the Road Tool will render with an artifact stretching to the mesh corner.&lt;br /&gt;
*Finally move the layer into it's correct place for rendering.  Drag and release the node between the '''Ground_Base''' and '''Rock''' group node.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Projector ===&lt;br /&gt;
Using the projector node, localized texture detail can be projected onto the megatexture.&lt;br /&gt;
&lt;br /&gt;
;Projectors&lt;br /&gt;
Created a groups to keep things nice an neat.&lt;br /&gt;
&lt;br /&gt;
;Cracked_Road&lt;br /&gt;
* To give the look of cracked tar where the crater nears the road.&lt;br /&gt;
* Create the '''Road Node''', {{accelbtn|RMB}} over the '''Projectors''' Group node, a pop-up menu will appear and select ''New'' | '''Projector'''.&lt;br /&gt;
* Setup the '''Projector''' the same way you would a standard '''Image Source''' node, except you only need a '''Distribution''' mask (and not a '''Distributed Pattern), as the texture shouldn't be projected larger than the source textures.&lt;br /&gt;
* To place the projector move/scale/rotate as you would a normal brush (including vertex editing).  The projector should be positioned above the terrain mesh.&lt;br /&gt;
&lt;br /&gt;
;Crater&lt;br /&gt;
* Places the crater scorch marks.&lt;br /&gt;
* Setup the same way as '''Cracked_Road'''.&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
* [[An Simple First Megatexture]] - start here for a basic MegaTexture tutorial&lt;br /&gt;
* [[Generate a MegaTexture]] - steps for generating a MegaTexture from the SDK launcher.&lt;br /&gt;
&lt;br /&gt;
[[Category:Art]]&lt;br /&gt;
[[Category:Basic Level Design]]&lt;br /&gt;
[[Category:Tutorials]]&lt;/div&gt;</summary>
		<author><name>Ducks</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.splashdamage.com/index.php?title=A_Simple_First_Terrain&amp;diff=4073</id>
		<title>A Simple First Terrain</title>
		<link rel="alternate" type="text/html" href="https://wiki.splashdamage.com/index.php?title=A_Simple_First_Terrain&amp;diff=4073"/>
		<updated>2007-12-17T16:14:14Z</updated>

		<summary type="html">&lt;p&gt;Ducks: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is the barebones guide towards creating your first simple terrain and adding it to a map. This terrain won't be as detailed or as attractive as a full terrain, but will demonstrate the basics of creating a terrain mesh, assigning a texture, and adding it in-game.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
'''For this tutorial you must:'''&lt;br /&gt;
* Have a modelling package that can export as OBJ&lt;br /&gt;
* Have basic modelling skills&lt;br /&gt;
* Have basic mapping skills&lt;br /&gt;
&lt;br /&gt;
If you can't do any of the above things, this tutorial is not for you!&lt;br /&gt;
&lt;br /&gt;
'''This tutorial covers:'''&lt;br /&gt;
* How to create a terrain mesh and caulk hull&lt;br /&gt;
* How to add a terrain mesh to a map&lt;br /&gt;
* How to assign a texture&lt;br /&gt;
* How to work with terrain meshes and map geometry&lt;br /&gt;
&lt;br /&gt;
'''This tutorial does not cover:'''&lt;br /&gt;
* How to use Blender/Maya/Lightwave/ZBrush/Mudbox/3DSMax/EarthSculptor/WorldMachine&lt;br /&gt;
* How to create a megatexture&lt;br /&gt;
* How to create displacement maps&lt;br /&gt;
* Anything complicated&lt;br /&gt;
&lt;br /&gt;
== Building the Terrain Mesh ==&lt;br /&gt;
[[Image:simpleterrain_mesh.png|thumb|400px|A simple terrain mesh created in Blender]]&lt;br /&gt;
Use your preferred modelling package to create a basic terrain mesh that is exactly 32,768 units long and wide. &lt;br /&gt;
&lt;br /&gt;
It is preferable to keep the terrain as basic as possible, so it can be refined later on during the mapping process. For this reason, the terrain mesh here only contains a very very rough formation of bumps (or 'mountains' as they might be known)&lt;br /&gt;
&lt;br /&gt;
''While you can use any dimensions for your terrain mesh - it is strongly advised to stick to 8k*8k, 16*16k or 32k*32k''&lt;br /&gt;
&lt;br /&gt;
=== Important ===&lt;br /&gt;
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')&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
== Creating a Caulk Hull ==&lt;br /&gt;
[[Image:simpleterrain_caulkhull.png|thumb|400px|The caulk hull]]&lt;br /&gt;
Since maps must be leak-free/sealed, maps with terrain must have a caulk hull to ensure this is the case.&lt;br /&gt;
&lt;br /&gt;
In this case, since the terrain is 32768 units long and wide, the caulk hull should also be the same dimensions. The caulk hull is quickly created from a brush 32768 units long, 32768 wide and 16384 units tall, which is then hollowed. The brushes are also assigned the 'editor/noimpactcaulk' texture, which prevents gunshots and projectiles from hitting the surfaces of the hull (they simply disappear instead.)&lt;br /&gt;
&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
== Setting The Terrain ==&lt;br /&gt;
[[Image:simpleterrain_terraineditor.png|thumb|200px|The Terrain Editor]]&lt;br /&gt;
The mesh must be triangulated before it is exported as an .OBJ, and saved as {{filename|models/terrain/simpleterrain.obj}}. At this stage, a texture is not necessary, and can be set later.&lt;br /&gt;
&lt;br /&gt;
Terrains are set up in the Terrain Editor, accessible via {{accelkey|shift}}{{accelkey|N}}. 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 MegaBuild needs to generate a Megatexture.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
[[Image:simpleterrain_terraineditor2.png|thumb|200px|Root node set up to use the correct terrain mesh]]&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
At this point you may add a player spawn, an atmosphere, and compile the level to check the terrain. However, since there is no material set, there will be rendering issues.&lt;br /&gt;
&lt;br /&gt;
''You may find the 3D terrain is partly covered or obscured by the base of caulk hull. This can be fixed by moving or resizing the caulk hull so it contains the terrain properly.''&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
== Assigning a Material ==&lt;br /&gt;
[[Image:simpleterrain_textured.png|thumb|200px|Textured terrain mesh]]&lt;br /&gt;
It is not possible to assign materials to terrain meshes in EditWorld, you must do this process in your modelling application.&lt;br /&gt;
&lt;br /&gt;
For testing purposes, terrain meshes are often assigned a temporary material until they are in a state that they can be textured properly. Traditionally, this has been one of the existing materials in the game, such as concrete - {{filename|textures/concrete/concrete10}} (although any valid material will work.)&lt;br /&gt;
&lt;br /&gt;
Due to an oddity with the OBJ format, the material name {{filename|textures/concrete/concrete10}} is not valid inside an OBJ file. Instead, the material should be named {{filename|textures__concrete__concrete10}}, where the slashes are replaced by double underscores (single underscores will not work!).&lt;br /&gt;
&lt;br /&gt;
Setting the mesh material differs between modelling packages. However, since OBJ files are text, they can be manually edited with a text editor instead of using the modelling application. The OBJ will contain a line (often about halfway through) starting with &amp;lt;tt&amp;gt;usemtl&amp;lt;/tt&amp;gt; followed by an arbitrary texture name. This line should be replaced with &amp;lt;tt&amp;gt;usemtl textures__concrete__concrete10&amp;lt;/tt&amp;gt; and the file saved.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
editWorld can then be told to reload the OBJ (now with a proper material declaration) via ''Misc -&amp;gt; Reload -&amp;gt; Models'' or clicking the &amp;quot;Reload Models&amp;quot; button.&lt;br /&gt;
&lt;br /&gt;
''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}}.''&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
== Map Geometry ==&lt;br /&gt;
[[Image:simpleterrain_building.png|thumb|200px|Exported geometry used to help edit the terrain]]&lt;br /&gt;
The map and terrain are now in a state that they can be used for level design, however difficulty can arise ensuring the structures in the level fit to the terrain. &lt;br /&gt;
&lt;br /&gt;
This can be countered using editWorld's export tool, which exports map geometry for importing into the modelling package alongside the terrain. This can be done by selecting the geometry to export (such as a building or a reference, located anywhere in the map), and pressing {{accelkey|ctrl}}{{accelkey|e}}. This writes the geometry to {{filename|models/export.obj}}.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
[[Image:simpleterrain_refinedmesh.png|thumb|200px|Exported geometry used to help edit the terrain]]&lt;br /&gt;
The exported geometry can then be used as a template to modify the terrain accordingly - such as flattening areas of land to fit buildings, cutting holes for entrances of simply adding more detail. The modified terrain mesh is then saved for further work in editWorld.&lt;br /&gt;
&lt;br /&gt;
Most often, terrain vertices are snapped to the corners of buildings and structures, such that the terrain faces now covered by the building can be deleted. This allows for buildings to sink into the terrain, and lead into underground areas of the map.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
[[Image:simpleterrain_fixedterrain.png|thumb|200px|Terrain after being edited to fit the geometry.]]&lt;br /&gt;
This process of refinement is repeated many times throughout the life of the map, ensuring the terrain precisely fits the map geometry. &lt;br /&gt;
&lt;br /&gt;
''When working with terrained maps, most level geometry is stored in separate [[References]] to allow for easy editing.''&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
== That's it! ==&lt;br /&gt;
[[Image:simpleterrain_ingame.png|thumb|400px|Terrain in-game]]&lt;br /&gt;
You've now created a map with your very own terrain!&lt;br /&gt;
&lt;br /&gt;
'''Things to try:'''&lt;br /&gt;
* Assign a different texture to the terrain mesh&lt;br /&gt;
* Make the terrain an island with [[Water Surfaces]]&lt;br /&gt;
* Cut a hole in the terrain to create an underground area&lt;br /&gt;
&lt;br /&gt;
'''You can now proceed to [[A Simple First Megatexture]], which guides you through the process of texturing your terrain and creating a MegaTexture for it.'''&lt;br /&gt;
&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
== Advanced Bits and Pieces ==&lt;br /&gt;
&lt;br /&gt;
=== Atmosphere ===&lt;br /&gt;
You may find your atmosphere doesn't project sunlight and shadow correctly. This is because the engine needs to know the area you have created is outside. The simplest way to do this is to create a brush in the corner of the caulk hull, textured with 'editor/outsideportal'.&lt;br /&gt;
&lt;br /&gt;
=== Terrain Mesh UVs ===&lt;br /&gt;
If you find your terrain is a constant grey, rather than showing a texture (as in the screenshots) 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.&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
* [[Making a Terrain Model]] - an advanced guide for complete terrain creation&lt;br /&gt;
* [[Design: How do I|How do I...?]] - how to do common tasks&lt;br /&gt;
* [[Design: Troubleshooting]] - troubleshooting guide&lt;br /&gt;
* [[A Simple First Map]] - the first mapping tutorial&lt;br /&gt;
* [[A Simple Second Map]] - the second mapping tutorial&lt;br /&gt;
* [[A Simple First Megatexture]] - tutorial covering megatexture creation&lt;br /&gt;
* [[An Advanced Map]] - a more complex guide to creating a map, including terrain&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Basic Level Design]]&lt;br /&gt;
[[Category:Tutorials]]&lt;/div&gt;</summary>
		<author><name>Ducks</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.splashdamage.com/index.php?title=A_Simple_First_Megatexture&amp;diff=4072</id>
		<title>A Simple First Megatexture</title>
		<link rel="alternate" type="text/html" href="https://wiki.splashdamage.com/index.php?title=A_Simple_First_Megatexture&amp;diff=4072"/>
		<updated>2007-12-17T16:00:51Z</updated>

		<summary type="html">&lt;p&gt;Ducks: /* Introduction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Image:simplemega_ingame.jpg|right|thumb|500px|A simple MegaTexture, easily created with only 3 texture layers!]]&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
'''For this tutorial you must:'''&lt;br /&gt;
* Have a terrain model UV-mapped in the 0-1 range (covered in the simple first terrain tutorial)&lt;br /&gt;
* Have access to some tiling textures.&lt;br /&gt;
* Have a little understanding the ETQW material system&lt;br /&gt;
&lt;br /&gt;
If you don't have any of the above things, you are not ready to do this tutorial!&lt;br /&gt;
&lt;br /&gt;
'''This tutorial covers:'''&lt;br /&gt;
* How to set up a MegaTexture material&lt;br /&gt;
* How to create a Surface Tree&lt;br /&gt;
* How to add texture nodes in the Terrain Editor&lt;br /&gt;
* How to render and compile a full MegaTexture&lt;br /&gt;
&lt;br /&gt;
'''This tutorial does not cover:'''&lt;br /&gt;
* How to use Photoshop/EarthSculptor/Terragen/WorldMachine&lt;br /&gt;
* How to create tiling textures or height-maps&lt;br /&gt;
&lt;br /&gt;
== Creating a MegaTexture material ==&lt;br /&gt;
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:&lt;br /&gt;
 material megatextures/mapname		{ useTemplate megatextures/default_ambient&amp;lt; &amp;quot;mapname&amp;quot; &amp;gt; }&lt;br /&gt;
&lt;br /&gt;
This material would automatically search for a MegaTexture called {{filename|mapname.mega}} in the {{filename|/megatextures/}} folder. This example material uses the ''&amp;quot;default_ambient&amp;quot;'' 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]].&lt;br /&gt;
&lt;br /&gt;
Obviously you would want to use the actual name of your map instead of &amp;quot;mapname&amp;quot;, for consistency's sake and ease of reference.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Assigning the material ===&lt;br /&gt;
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).&lt;br /&gt;
Tips on this process can be found in the [[A Simple First Terrain|simple first terrain tutorial]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Creating the Surface Tree ==&lt;br /&gt;
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 &amp;quot;Save and Unload&amp;quot; button in the Terrain Editor.&lt;br /&gt;
[[Image:simplemega_terrainmodel.png|thumb|300px|Root node set up to use the correct terrain mesh]]&lt;br /&gt;
&lt;br /&gt;
=== Add the terrain mesh ===&lt;br /&gt;
Here's how you bring the terrain mesh into the surface tree:&lt;br /&gt;
* {{accelbtn|RMB}} on the left-hand pane, and choose ''New -&amp;gt; Tree'' via the menu.&lt;br /&gt;
** If you already have a Root node, click the &amp;quot;Begin Editing&amp;quot; button instead.&lt;br /&gt;
* Click on the Root node, and set {{keyname|Model}} to the name of the terrain mesh, in this case {{keyvalue|models/terrain/simpleterrain.obj}}.&lt;br /&gt;
* Press {{accelkey|enter}} to confirm the selection, and the terrain should appear in the 3D view.&lt;br /&gt;
&lt;br /&gt;
Be aware that your terrain model will probably appear bright orange or red.&lt;br /&gt;
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!&lt;br /&gt;
&lt;br /&gt;
=== Important note about nodes ===&lt;br /&gt;
When you are editing properties of nodes (names, numbers, texture sources etc.) always remember to hit {{accelkey|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 {{accelkey|enter}}, your changes may not be applied.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Create the first texture node ==&lt;br /&gt;
[[Image:simplemega_firstnode_diffuse.png|thumb|300px|The first texture node's diffuse texture properties]]&lt;br /&gt;
Now that the model is in place, you can start laying down the texture layers (or &amp;quot;nodes&amp;quot;) that will make up your MegaTexture.&lt;br /&gt;
&lt;br /&gt;
First you need to create a new Image Source node in the Terrain Editor.&lt;br /&gt;
* {{accelbtn|RMB}} on your &amp;quot;Root&amp;quot; node and choose ''New -&amp;gt; Image Source'' (or press {{accelkey|shift}}{{accelkey|i}})&lt;br /&gt;
* This will make a new node called &amp;quot;New Image Renderer&amp;quot;.&lt;br /&gt;
* You can rename this new node using the &amp;quot;Name&amp;quot; property field in the '''Object''' section.&lt;br /&gt;
* Rename the node &amp;quot;Dirt&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
You will notice in the top right of the Terrain Editor, a section listing things like &amp;quot;Diffuse&amp;quot;, &amp;quot;Distribution&amp;quot;, &amp;quot;Distribution Pattern&amp;quot; etc. Selecting one of these will list all of the properties for that section of the current node.&lt;br /&gt;
The ones we need to worry about are as follows:&lt;br /&gt;
&lt;br /&gt;
=== Diffuse ===&lt;br /&gt;
This is the colour map of the current node, and it should point to a tiling TGA texture.&lt;br /&gt;
* Make sure the Diffuse section is highlighted in the top right of the Terrain Editor.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to a generic tiling dirt texture. Remember to hit {{accelkey|enter}} afterwards!&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/dirt_02_d.tga}}&lt;br /&gt;
* The {{keyname|Scale}} field at the very bottom of the property list allows you to choose how much to tile the texture.&lt;br /&gt;
** 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!&lt;br /&gt;
** 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.&lt;br /&gt;
That's all you need to do for the Diffuse settings in this node.&lt;br /&gt;
&lt;br /&gt;
=== Distribution ===&lt;br /&gt;
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''.&lt;br /&gt;
* Make sure the Distribution section is highlighted in the top right.&lt;br /&gt;
* Since this is our first node, we want to show over the whole terrain. This means the distribution map should be 100% white.&lt;br /&gt;
* You can either assign a pure white TGA texture, or change the {{keyname|Source Type}} to {{keyvalue|geometryBased}}.&lt;br /&gt;
** {{keyvalue|geometryBased}} will by default create a fully white map, so if you don't have a white TGA handy, this is faster.&lt;br /&gt;
&lt;br /&gt;
=== Distribution Pattern ===&lt;br /&gt;
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.&lt;br /&gt;
* 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!&lt;br /&gt;
&lt;br /&gt;
=== Local ===&lt;br /&gt;
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.&lt;br /&gt;
* Make sure the Local section is highlighted in the top right.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching normal map for your tiling dirt texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/dirt_02_local.tga}}&lt;br /&gt;
* The Local texture's tiling amount is automatically the same as the Diffuse texture.&lt;br /&gt;
&lt;br /&gt;
=== Surface Type ===&lt;br /&gt;
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.&lt;br /&gt;
* Find the ''Surface Type Properties'' section of the property list.&lt;br /&gt;
* 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.&lt;br /&gt;
* Hit {{accelkey|enter}} to accept the surface type.&lt;br /&gt;
&lt;br /&gt;
Your dirt textures will now produce correct &amp;quot;dirt&amp;quot; effects when shot or collided with!&lt;br /&gt;
&lt;br /&gt;
=== Previewing the result ===&lt;br /&gt;
[[Image:simplemega_firstnode_preview.jpg|thumb|300px|The Render mode preview of the first node]]&lt;br /&gt;
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]]&lt;br /&gt;
&lt;br /&gt;
* Notice the drop-down arrow on the right of the button. Click it, and select ''&amp;quot;Full&amp;quot;'' instead of ''&amp;quot;None&amp;quot;''.&lt;br /&gt;
* Your terrain should change colour to black. This means it's ready for a preview to be rendered onto it.&lt;br /&gt;
* Click the button itself now, instead of the drop-down. An &amp;quot;Active Tasks&amp;quot; window should pop up, and when it's done, you should see your dirt texture appear on your terrain model.&lt;br /&gt;
* You can switch the camera to Render mode too, which will show your terrain model's shading better.&lt;br /&gt;
* If you want a full-resolution preview of a small area, choose ''&amp;quot;Window&amp;quot;'' instead of ''&amp;quot;Full&amp;quot;'' from the drop-down menu.&lt;br /&gt;
** 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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
'''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.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
== Adding a second node ==&lt;br /&gt;
Now that the first layer of dirt is in place, we can try putting some grass on top of it!&lt;br /&gt;
* Again, {{accelbtn|RMB}} on your &amp;quot;Root&amp;quot; node and choose ''New -&amp;gt; Image Source'' (or press {{accelkey|shift}}{{accelkey|i}})&lt;br /&gt;
* This will make another new node below your &amp;quot;Dirt&amp;quot; node. &lt;br /&gt;
* Name this new node &amp;quot;Grass&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Again, the main map types need to be specified before the node can be rendered:&lt;br /&gt;
&lt;br /&gt;
=== Diffuse ===&lt;br /&gt;
* Make sure the Diffuse section is highlighted in the top right of the Terrain Editor.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to a generic tiling grass texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/grass_04_d.tga}}&lt;br /&gt;
* 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.&lt;br /&gt;
&lt;br /&gt;
=== Distribution ===&lt;br /&gt;
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!&lt;br /&gt;
* Make sure the Distribution section is highlighted in the top right.&lt;br /&gt;
* Change the {{keyname|Source Type}} from {{keyvalue|texture}} to {{keyvalue|geometryBased}}.&lt;br /&gt;
&lt;br /&gt;
=== Geometric Texture Distribution ===&lt;br /&gt;
[[Image:simplemega_geometric_distribution.png|thumb|300px|The geometric texture distribution settings of the second node]]&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
* ''Altitude Lower'' - Enabling this will limit the lower parts of the terrain from receiving this node's textures.&lt;br /&gt;
** {{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.&lt;br /&gt;
** {{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.&lt;br /&gt;
* ''Altitude Upper'' - Enabling this will limit the higher parts of the terrain from receiving this node's textures.&lt;br /&gt;
** {{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.&lt;br /&gt;
** {{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.&lt;br /&gt;
&lt;br /&gt;
* {{keyname|Clamp Distribution To Edge}} - Leave this on Default.&lt;br /&gt;
&lt;br /&gt;
* {{keyname|Resolution}} - The size in pixels of the resulting mask. The default value of {{keyvalue|256}} is fine for nearly any terrain model.&lt;br /&gt;
&lt;br /&gt;
* ''Slope Lower'' - Enabling this will limit shallower angles of the terrain model from receiving this node's textures.&lt;br /&gt;
** {{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.&lt;br /&gt;
** {{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.&lt;br /&gt;
* ''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.&lt;br /&gt;
** {{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.&lt;br /&gt;
** {{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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
=== Distribution Pattern ===&lt;br /&gt;
[[Image:simplemega_dist_ramps.jpg|thumb|300px|The difference between using or not using a Distribution Pattern, and varying Ramp Widths]]&lt;br /&gt;
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!&lt;br /&gt;
So what we want here is a texture to identify the &amp;quot;height&amp;quot; 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.&lt;br /&gt;
&lt;br /&gt;
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!&lt;br /&gt;
&lt;br /&gt;
* Make sure {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching heightmap or mask for your tiling grass texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/grass_04_mask.tga}}&lt;br /&gt;
* 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 &amp;quot;Window&amp;quot; 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.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
=== Local ===&lt;br /&gt;
Again we want the normal-map which matches the diffuse texture for the grass.&lt;br /&gt;
* Make sure the Local section is highlighted in the top right.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching normal map for your tiling grass texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/grass_04_local.tga}}&lt;br /&gt;
&lt;br /&gt;
=== Surface Type ===&lt;br /&gt;
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.&lt;br /&gt;
* Find the ''Surface Type Properties'' section of the property list.&lt;br /&gt;
* 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.&lt;br /&gt;
* Hit {{accelkey|enter}} to accept the surface type.&lt;br /&gt;
&lt;br /&gt;
Your grass textures should now produce correct &amp;quot;grass&amp;quot; effects when shot or collided with!&lt;br /&gt;
&lt;br /&gt;
=== Preview ===&lt;br /&gt;
[[Image:simplemega_secondnode_preview.jpg|thumb|300px|The Render mode preview of the second node blended with the first node]]&lt;br /&gt;
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.&lt;br /&gt;
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.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
== Adding a third node ==&lt;br /&gt;
[[Image:simplemega_thirdnode_preview.jpg|thumb|300px|The Render mode preview of the third node blended with the other two nodes]]&lt;br /&gt;
Now that the grass and dirt are in place, we need some rocks to make the terrain look more natural.&lt;br /&gt;
* Add a new Image Renderer node below your &amp;quot;Grass&amp;quot; node and name it &amp;quot;Rock&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Again, the main map types need to be specified before the node can be rendered:&lt;br /&gt;
&lt;br /&gt;
=== Diffuse ===&lt;br /&gt;
* Set the '''Diffuse''' texture and scale.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/rock_01_d.tga}} at a scale of {{keyvalue|32 32}}&lt;br /&gt;
&lt;br /&gt;
=== Distribution ===&lt;br /&gt;
Again we can use Geometric Texture Distribution to easily apply the rock textures only to the cliff-like angles.&lt;br /&gt;
* Make sure the Distribution section is highlighted in the top right.&lt;br /&gt;
* Change the {{keyname|Source Type}} to {{keyvalue|geometryBased}}.&lt;br /&gt;
* 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}}&lt;br /&gt;
&lt;br /&gt;
=== Distribution Pattern ===&lt;br /&gt;
Again this will control how the the rocks blend into the other nodes. Again, we want a texture to identify the &amp;quot;height&amp;quot; of the tiling rock texture.&lt;br /&gt;
&lt;br /&gt;
* Make sure the Distribution Pattern section is highlighted in the top right.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching heightmap or mask for your tiling rock texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/rock_01_h.tga}}&lt;br /&gt;
* 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 &amp;quot;Window&amp;quot; preview to see how the blending looks.&lt;br /&gt;
* Remember to set the {{keyname|Distribution Pattern Texture Scale}} to the same value as the Diffuse Scale, {{keyvalue|32 32}}.&lt;br /&gt;
&lt;br /&gt;
=== Local ===&lt;br /&gt;
Again we want the normal-map which matches the diffuse texture for the rocks.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Local''' section, browse to the matching normal map for your tiling rock texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/rock_01_local.tga}}&lt;br /&gt;
&lt;br /&gt;
=== Surface Type ===&lt;br /&gt;
* Find the ''Surface Type Properties'' section of the property list.&lt;br /&gt;
* In the {{keyname|Type}} field, enter {{keyvalue|stone}}.&lt;br /&gt;
* Hit {{accelkey|enter}} to accept the surface type.&lt;br /&gt;
&lt;br /&gt;
Your rock textures should now produce correct &amp;quot;stone&amp;quot; effects when shot or collided with.&lt;br /&gt;
&lt;br /&gt;
=== Preview ===&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Further tweaks ==&lt;br /&gt;
There are other simple changes that can be done in the Terrain Editor to make your MegaTexture look even better.&lt;br /&gt;
&lt;br /&gt;
=== Node order ===&lt;br /&gt;
[[Image:simplemega_node_order.png|frame|Click and drag a node to change the order]]&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
* {{accelbtn|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.&lt;br /&gt;
* Release {{accelbtn|LMB}} when you have positioned the node in the correct place.&lt;br /&gt;
* 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!&lt;br /&gt;
&lt;br /&gt;
=== Color changes ===&lt;br /&gt;
Maybe your dirt texture is too bright? Or maybe your grass looks a little ''too'' green?&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Let's say you want to make the dirt texture darker and a bit more red. Here's how you'd do it:&lt;br /&gt;
* Select your Dirt node.&lt;br /&gt;
* 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).&lt;br /&gt;
* A color wheel and brightness slider will pop up in a new window. You can use this to darken and tint your texture.&lt;br /&gt;
* Choose a darker brightness, and a color slightly towards red. I used '''RGB Values''' of 225, 220, 220.&lt;br /&gt;
* Hit ''OK'' to accept the color.&lt;br /&gt;
* Re-render your MegaTexture preview. You should notice that the dirt layer looks darker now!&lt;br /&gt;
&lt;br /&gt;
=== Texture rotation ===&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Render the MegaTexture ==&lt;br /&gt;
=== Save the Surface Tree ===&lt;br /&gt;
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 &amp;quot;Save and Unload&amp;quot; button in the Terrain Editor, or save the whole map.&lt;br /&gt;
&lt;br /&gt;
=== Compile Only Entities ===&lt;br /&gt;
At this stage, your MegaTexture material is still technically &amp;quot;broken&amp;quot;, 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.&lt;br /&gt;
&lt;br /&gt;
However, we need to compile the map in order to tell the [[renderLight]] process which atmosphere to use when lighting the MegaTexture!&lt;br /&gt;
&lt;br /&gt;
So the solution is to do an '''Only Entities''' compile. You can find this in the menu ''Compile -&amp;gt; 2 - Only Entities'' in editWorld. This should be done in a few seconds, and compiles all the information that renderLight needs.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Run the SDK Launcher ===&lt;br /&gt;
Now that your ''.sft'' is saved, go through all the steps outlined in the [[Generate a MegaTexture]] tutorial.&lt;br /&gt;
&lt;br /&gt;
== That's it! ==&lt;br /&gt;
[[Image:simplemega_ingame.jpg|thumb|300px|The MegaTexture in-game!]]&lt;br /&gt;
You've now created your very own MegaTexture to use in your map!&lt;br /&gt;
&lt;br /&gt;
Before you even compile the map, you can get an accurate preview of how it will look in-game by pressing {{accelkey|F6}} to toggle &amp;quot;anim&amp;quot; mode while in editWorld's &amp;quot;RENDER&amp;quot; Camera view (toggled with {{accelkey|F3}}).&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
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:&lt;br /&gt;
* 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.&lt;br /&gt;
* 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 ''&amp;lt; &amp;quot;mapname&amp;quot; &amp;gt;'' part described in [[A Simple First Megatexture#Creating a MegaTexture material|this section]]), otherwise it will not be searching for the correct images.&lt;br /&gt;
* 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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
* [[An Advanced Terrain and Megatexture]] - an advanced guide for complete MegaTexture creation&lt;br /&gt;
* [[Generate a MegaTexture]] - steps for generating a MegaTexture from the SDK launcher.&lt;br /&gt;
* [http://community.enemyterritory.com/forums/showthread.php?t=19326 Forum Thread] - includes textures to download&lt;br /&gt;
&lt;br /&gt;
[[Category:Art]]&lt;br /&gt;
[[Category:Basic Level Design]]&lt;br /&gt;
[[Category:Tutorials]]&lt;/div&gt;</summary>
		<author><name>Ducks</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.splashdamage.com/index.php?title=A_Simple_First_Megatexture&amp;diff=4071</id>
		<title>A Simple First Megatexture</title>
		<link rel="alternate" type="text/html" href="https://wiki.splashdamage.com/index.php?title=A_Simple_First_Megatexture&amp;diff=4071"/>
		<updated>2007-12-17T16:00:02Z</updated>

		<summary type="html">&lt;p&gt;Ducks: /* Introduction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Image:simplemega_ingame.jpg|right|thumb|500px|A simple MegaTexture, easily created with only 3 texture layers!]]&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
'''For this tutorial you must:'''&lt;br /&gt;
* Have a terrain model UV-mapped in the 0-1 range (covered in the simple first terrain tutorial)&lt;br /&gt;
* Have access to some tiling textures.&lt;br /&gt;
* Have a little understanding the ETQW material system&lt;br /&gt;
&lt;br /&gt;
If you don't have any of the above things, you are not ready to do this tutorial!&lt;br /&gt;
&lt;br /&gt;
'''This tutorial covers:'''&lt;br /&gt;
* How to set up a MegaTexture material&lt;br /&gt;
* How to create a Surface Tree&lt;br /&gt;
* How to add texture nodes in the Terrain Editor&lt;br /&gt;
* How to render and compile a full MegaTexture&lt;br /&gt;
&lt;br /&gt;
'''This tutorial does not cover:'''&lt;br /&gt;
* How to use Photoshop/EarthSculptor/Terragen&lt;br /&gt;
* How to create tiling textures or height-maps&lt;br /&gt;
&lt;br /&gt;
== Creating a MegaTexture material ==&lt;br /&gt;
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:&lt;br /&gt;
 material megatextures/mapname		{ useTemplate megatextures/default_ambient&amp;lt; &amp;quot;mapname&amp;quot; &amp;gt; }&lt;br /&gt;
&lt;br /&gt;
This material would automatically search for a MegaTexture called {{filename|mapname.mega}} in the {{filename|/megatextures/}} folder. This example material uses the ''&amp;quot;default_ambient&amp;quot;'' 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]].&lt;br /&gt;
&lt;br /&gt;
Obviously you would want to use the actual name of your map instead of &amp;quot;mapname&amp;quot;, for consistency's sake and ease of reference.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Assigning the material ===&lt;br /&gt;
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).&lt;br /&gt;
Tips on this process can be found in the [[A Simple First Terrain|simple first terrain tutorial]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Creating the Surface Tree ==&lt;br /&gt;
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 &amp;quot;Save and Unload&amp;quot; button in the Terrain Editor.&lt;br /&gt;
[[Image:simplemega_terrainmodel.png|thumb|300px|Root node set up to use the correct terrain mesh]]&lt;br /&gt;
&lt;br /&gt;
=== Add the terrain mesh ===&lt;br /&gt;
Here's how you bring the terrain mesh into the surface tree:&lt;br /&gt;
* {{accelbtn|RMB}} on the left-hand pane, and choose ''New -&amp;gt; Tree'' via the menu.&lt;br /&gt;
** If you already have a Root node, click the &amp;quot;Begin Editing&amp;quot; button instead.&lt;br /&gt;
* Click on the Root node, and set {{keyname|Model}} to the name of the terrain mesh, in this case {{keyvalue|models/terrain/simpleterrain.obj}}.&lt;br /&gt;
* Press {{accelkey|enter}} to confirm the selection, and the terrain should appear in the 3D view.&lt;br /&gt;
&lt;br /&gt;
Be aware that your terrain model will probably appear bright orange or red.&lt;br /&gt;
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!&lt;br /&gt;
&lt;br /&gt;
=== Important note about nodes ===&lt;br /&gt;
When you are editing properties of nodes (names, numbers, texture sources etc.) always remember to hit {{accelkey|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 {{accelkey|enter}}, your changes may not be applied.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Create the first texture node ==&lt;br /&gt;
[[Image:simplemega_firstnode_diffuse.png|thumb|300px|The first texture node's diffuse texture properties]]&lt;br /&gt;
Now that the model is in place, you can start laying down the texture layers (or &amp;quot;nodes&amp;quot;) that will make up your MegaTexture.&lt;br /&gt;
&lt;br /&gt;
First you need to create a new Image Source node in the Terrain Editor.&lt;br /&gt;
* {{accelbtn|RMB}} on your &amp;quot;Root&amp;quot; node and choose ''New -&amp;gt; Image Source'' (or press {{accelkey|shift}}{{accelkey|i}})&lt;br /&gt;
* This will make a new node called &amp;quot;New Image Renderer&amp;quot;.&lt;br /&gt;
* You can rename this new node using the &amp;quot;Name&amp;quot; property field in the '''Object''' section.&lt;br /&gt;
* Rename the node &amp;quot;Dirt&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
You will notice in the top right of the Terrain Editor, a section listing things like &amp;quot;Diffuse&amp;quot;, &amp;quot;Distribution&amp;quot;, &amp;quot;Distribution Pattern&amp;quot; etc. Selecting one of these will list all of the properties for that section of the current node.&lt;br /&gt;
The ones we need to worry about are as follows:&lt;br /&gt;
&lt;br /&gt;
=== Diffuse ===&lt;br /&gt;
This is the colour map of the current node, and it should point to a tiling TGA texture.&lt;br /&gt;
* Make sure the Diffuse section is highlighted in the top right of the Terrain Editor.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to a generic tiling dirt texture. Remember to hit {{accelkey|enter}} afterwards!&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/dirt_02_d.tga}}&lt;br /&gt;
* The {{keyname|Scale}} field at the very bottom of the property list allows you to choose how much to tile the texture.&lt;br /&gt;
** 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!&lt;br /&gt;
** 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.&lt;br /&gt;
That's all you need to do for the Diffuse settings in this node.&lt;br /&gt;
&lt;br /&gt;
=== Distribution ===&lt;br /&gt;
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''.&lt;br /&gt;
* Make sure the Distribution section is highlighted in the top right.&lt;br /&gt;
* Since this is our first node, we want to show over the whole terrain. This means the distribution map should be 100% white.&lt;br /&gt;
* You can either assign a pure white TGA texture, or change the {{keyname|Source Type}} to {{keyvalue|geometryBased}}.&lt;br /&gt;
** {{keyvalue|geometryBased}} will by default create a fully white map, so if you don't have a white TGA handy, this is faster.&lt;br /&gt;
&lt;br /&gt;
=== Distribution Pattern ===&lt;br /&gt;
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.&lt;br /&gt;
* 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!&lt;br /&gt;
&lt;br /&gt;
=== Local ===&lt;br /&gt;
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.&lt;br /&gt;
* Make sure the Local section is highlighted in the top right.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching normal map for your tiling dirt texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/dirt_02_local.tga}}&lt;br /&gt;
* The Local texture's tiling amount is automatically the same as the Diffuse texture.&lt;br /&gt;
&lt;br /&gt;
=== Surface Type ===&lt;br /&gt;
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.&lt;br /&gt;
* Find the ''Surface Type Properties'' section of the property list.&lt;br /&gt;
* 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.&lt;br /&gt;
* Hit {{accelkey|enter}} to accept the surface type.&lt;br /&gt;
&lt;br /&gt;
Your dirt textures will now produce correct &amp;quot;dirt&amp;quot; effects when shot or collided with!&lt;br /&gt;
&lt;br /&gt;
=== Previewing the result ===&lt;br /&gt;
[[Image:simplemega_firstnode_preview.jpg|thumb|300px|The Render mode preview of the first node]]&lt;br /&gt;
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]]&lt;br /&gt;
&lt;br /&gt;
* Notice the drop-down arrow on the right of the button. Click it, and select ''&amp;quot;Full&amp;quot;'' instead of ''&amp;quot;None&amp;quot;''.&lt;br /&gt;
* Your terrain should change colour to black. This means it's ready for a preview to be rendered onto it.&lt;br /&gt;
* Click the button itself now, instead of the drop-down. An &amp;quot;Active Tasks&amp;quot; window should pop up, and when it's done, you should see your dirt texture appear on your terrain model.&lt;br /&gt;
* You can switch the camera to Render mode too, which will show your terrain model's shading better.&lt;br /&gt;
* If you want a full-resolution preview of a small area, choose ''&amp;quot;Window&amp;quot;'' instead of ''&amp;quot;Full&amp;quot;'' from the drop-down menu.&lt;br /&gt;
** 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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
'''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.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
== Adding a second node ==&lt;br /&gt;
Now that the first layer of dirt is in place, we can try putting some grass on top of it!&lt;br /&gt;
* Again, {{accelbtn|RMB}} on your &amp;quot;Root&amp;quot; node and choose ''New -&amp;gt; Image Source'' (or press {{accelkey|shift}}{{accelkey|i}})&lt;br /&gt;
* This will make another new node below your &amp;quot;Dirt&amp;quot; node. &lt;br /&gt;
* Name this new node &amp;quot;Grass&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Again, the main map types need to be specified before the node can be rendered:&lt;br /&gt;
&lt;br /&gt;
=== Diffuse ===&lt;br /&gt;
* Make sure the Diffuse section is highlighted in the top right of the Terrain Editor.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to a generic tiling grass texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/grass_04_d.tga}}&lt;br /&gt;
* 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.&lt;br /&gt;
&lt;br /&gt;
=== Distribution ===&lt;br /&gt;
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!&lt;br /&gt;
* Make sure the Distribution section is highlighted in the top right.&lt;br /&gt;
* Change the {{keyname|Source Type}} from {{keyvalue|texture}} to {{keyvalue|geometryBased}}.&lt;br /&gt;
&lt;br /&gt;
=== Geometric Texture Distribution ===&lt;br /&gt;
[[Image:simplemega_geometric_distribution.png|thumb|300px|The geometric texture distribution settings of the second node]]&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
* ''Altitude Lower'' - Enabling this will limit the lower parts of the terrain from receiving this node's textures.&lt;br /&gt;
** {{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.&lt;br /&gt;
** {{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.&lt;br /&gt;
* ''Altitude Upper'' - Enabling this will limit the higher parts of the terrain from receiving this node's textures.&lt;br /&gt;
** {{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.&lt;br /&gt;
** {{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.&lt;br /&gt;
&lt;br /&gt;
* {{keyname|Clamp Distribution To Edge}} - Leave this on Default.&lt;br /&gt;
&lt;br /&gt;
* {{keyname|Resolution}} - The size in pixels of the resulting mask. The default value of {{keyvalue|256}} is fine for nearly any terrain model.&lt;br /&gt;
&lt;br /&gt;
* ''Slope Lower'' - Enabling this will limit shallower angles of the terrain model from receiving this node's textures.&lt;br /&gt;
** {{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.&lt;br /&gt;
** {{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.&lt;br /&gt;
* ''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.&lt;br /&gt;
** {{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.&lt;br /&gt;
** {{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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
=== Distribution Pattern ===&lt;br /&gt;
[[Image:simplemega_dist_ramps.jpg|thumb|300px|The difference between using or not using a Distribution Pattern, and varying Ramp Widths]]&lt;br /&gt;
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!&lt;br /&gt;
So what we want here is a texture to identify the &amp;quot;height&amp;quot; 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.&lt;br /&gt;
&lt;br /&gt;
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!&lt;br /&gt;
&lt;br /&gt;
* Make sure {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching heightmap or mask for your tiling grass texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/grass_04_mask.tga}}&lt;br /&gt;
* 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 &amp;quot;Window&amp;quot; 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.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
=== Local ===&lt;br /&gt;
Again we want the normal-map which matches the diffuse texture for the grass.&lt;br /&gt;
* Make sure the Local section is highlighted in the top right.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching normal map for your tiling grass texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/grass_04_local.tga}}&lt;br /&gt;
&lt;br /&gt;
=== Surface Type ===&lt;br /&gt;
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.&lt;br /&gt;
* Find the ''Surface Type Properties'' section of the property list.&lt;br /&gt;
* 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.&lt;br /&gt;
* Hit {{accelkey|enter}} to accept the surface type.&lt;br /&gt;
&lt;br /&gt;
Your grass textures should now produce correct &amp;quot;grass&amp;quot; effects when shot or collided with!&lt;br /&gt;
&lt;br /&gt;
=== Preview ===&lt;br /&gt;
[[Image:simplemega_secondnode_preview.jpg|thumb|300px|The Render mode preview of the second node blended with the first node]]&lt;br /&gt;
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.&lt;br /&gt;
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.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
== Adding a third node ==&lt;br /&gt;
[[Image:simplemega_thirdnode_preview.jpg|thumb|300px|The Render mode preview of the third node blended with the other two nodes]]&lt;br /&gt;
Now that the grass and dirt are in place, we need some rocks to make the terrain look more natural.&lt;br /&gt;
* Add a new Image Renderer node below your &amp;quot;Grass&amp;quot; node and name it &amp;quot;Rock&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Again, the main map types need to be specified before the node can be rendered:&lt;br /&gt;
&lt;br /&gt;
=== Diffuse ===&lt;br /&gt;
* Set the '''Diffuse''' texture and scale.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/rock_01_d.tga}} at a scale of {{keyvalue|32 32}}&lt;br /&gt;
&lt;br /&gt;
=== Distribution ===&lt;br /&gt;
Again we can use Geometric Texture Distribution to easily apply the rock textures only to the cliff-like angles.&lt;br /&gt;
* Make sure the Distribution section is highlighted in the top right.&lt;br /&gt;
* Change the {{keyname|Source Type}} to {{keyvalue|geometryBased}}.&lt;br /&gt;
* 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}}&lt;br /&gt;
&lt;br /&gt;
=== Distribution Pattern ===&lt;br /&gt;
Again this will control how the the rocks blend into the other nodes. Again, we want a texture to identify the &amp;quot;height&amp;quot; of the tiling rock texture.&lt;br /&gt;
&lt;br /&gt;
* Make sure the Distribution Pattern section is highlighted in the top right.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching heightmap or mask for your tiling rock texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/rock_01_h.tga}}&lt;br /&gt;
* 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 &amp;quot;Window&amp;quot; preview to see how the blending looks.&lt;br /&gt;
* Remember to set the {{keyname|Distribution Pattern Texture Scale}} to the same value as the Diffuse Scale, {{keyvalue|32 32}}.&lt;br /&gt;
&lt;br /&gt;
=== Local ===&lt;br /&gt;
Again we want the normal-map which matches the diffuse texture for the rocks.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Local''' section, browse to the matching normal map for your tiling rock texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/rock_01_local.tga}}&lt;br /&gt;
&lt;br /&gt;
=== Surface Type ===&lt;br /&gt;
* Find the ''Surface Type Properties'' section of the property list.&lt;br /&gt;
* In the {{keyname|Type}} field, enter {{keyvalue|stone}}.&lt;br /&gt;
* Hit {{accelkey|enter}} to accept the surface type.&lt;br /&gt;
&lt;br /&gt;
Your rock textures should now produce correct &amp;quot;stone&amp;quot; effects when shot or collided with.&lt;br /&gt;
&lt;br /&gt;
=== Preview ===&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Further tweaks ==&lt;br /&gt;
There are other simple changes that can be done in the Terrain Editor to make your MegaTexture look even better.&lt;br /&gt;
&lt;br /&gt;
=== Node order ===&lt;br /&gt;
[[Image:simplemega_node_order.png|frame|Click and drag a node to change the order]]&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
* {{accelbtn|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.&lt;br /&gt;
* Release {{accelbtn|LMB}} when you have positioned the node in the correct place.&lt;br /&gt;
* 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!&lt;br /&gt;
&lt;br /&gt;
=== Color changes ===&lt;br /&gt;
Maybe your dirt texture is too bright? Or maybe your grass looks a little ''too'' green?&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Let's say you want to make the dirt texture darker and a bit more red. Here's how you'd do it:&lt;br /&gt;
* Select your Dirt node.&lt;br /&gt;
* 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).&lt;br /&gt;
* A color wheel and brightness slider will pop up in a new window. You can use this to darken and tint your texture.&lt;br /&gt;
* Choose a darker brightness, and a color slightly towards red. I used '''RGB Values''' of 225, 220, 220.&lt;br /&gt;
* Hit ''OK'' to accept the color.&lt;br /&gt;
* Re-render your MegaTexture preview. You should notice that the dirt layer looks darker now!&lt;br /&gt;
&lt;br /&gt;
=== Texture rotation ===&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Render the MegaTexture ==&lt;br /&gt;
=== Save the Surface Tree ===&lt;br /&gt;
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 &amp;quot;Save and Unload&amp;quot; button in the Terrain Editor, or save the whole map.&lt;br /&gt;
&lt;br /&gt;
=== Compile Only Entities ===&lt;br /&gt;
At this stage, your MegaTexture material is still technically &amp;quot;broken&amp;quot;, 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.&lt;br /&gt;
&lt;br /&gt;
However, we need to compile the map in order to tell the [[renderLight]] process which atmosphere to use when lighting the MegaTexture!&lt;br /&gt;
&lt;br /&gt;
So the solution is to do an '''Only Entities''' compile. You can find this in the menu ''Compile -&amp;gt; 2 - Only Entities'' in editWorld. This should be done in a few seconds, and compiles all the information that renderLight needs.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Run the SDK Launcher ===&lt;br /&gt;
Now that your ''.sft'' is saved, go through all the steps outlined in the [[Generate a MegaTexture]] tutorial.&lt;br /&gt;
&lt;br /&gt;
== That's it! ==&lt;br /&gt;
[[Image:simplemega_ingame.jpg|thumb|300px|The MegaTexture in-game!]]&lt;br /&gt;
You've now created your very own MegaTexture to use in your map!&lt;br /&gt;
&lt;br /&gt;
Before you even compile the map, you can get an accurate preview of how it will look in-game by pressing {{accelkey|F6}} to toggle &amp;quot;anim&amp;quot; mode while in editWorld's &amp;quot;RENDER&amp;quot; Camera view (toggled with {{accelkey|F3}}).&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
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:&lt;br /&gt;
* 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.&lt;br /&gt;
* 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 ''&amp;lt; &amp;quot;mapname&amp;quot; &amp;gt;'' part described in [[A Simple First Megatexture#Creating a MegaTexture material|this section]]), otherwise it will not be searching for the correct images.&lt;br /&gt;
* 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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
* [[An Advanced Terrain and Megatexture]] - an advanced guide for complete MegaTexture creation&lt;br /&gt;
* [[Generate a MegaTexture]] - steps for generating a MegaTexture from the SDK launcher.&lt;br /&gt;
* [http://community.enemyterritory.com/forums/showthread.php?t=19326 Forum Thread] - includes textures to download&lt;br /&gt;
&lt;br /&gt;
[[Category:Art]]&lt;br /&gt;
[[Category:Basic Level Design]]&lt;br /&gt;
[[Category:Tutorials]]&lt;/div&gt;</summary>
		<author><name>Ducks</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.splashdamage.com/index.php?title=A_Simple_First_Terrain&amp;diff=4070</id>
		<title>A Simple First Terrain</title>
		<link rel="alternate" type="text/html" href="https://wiki.splashdamage.com/index.php?title=A_Simple_First_Terrain&amp;diff=4070"/>
		<updated>2007-12-17T15:56:13Z</updated>

		<summary type="html">&lt;p&gt;Ducks: /* That's it! */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is the barebones guide towards creating your first simple terrain and adding it to a map. This terrain won't be as detailed or as attractive as a full terrain, but will demonstrate the basics of creating a terrain mesh, assigning a texture, and adding it in-game.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
'''For this tutorial you must:'''&lt;br /&gt;
* Have a modelling package that can export as OBJ&lt;br /&gt;
* Have basic modelling skills&lt;br /&gt;
* Have basic mapping skills&lt;br /&gt;
&lt;br /&gt;
If you can't do any of the above things, this tutorial is not for you!&lt;br /&gt;
&lt;br /&gt;
'''This tutorial covers:'''&lt;br /&gt;
* How to create a terrain mesh and caulk hull&lt;br /&gt;
* How to add a terrain mesh to a map&lt;br /&gt;
* How to assign a texture&lt;br /&gt;
* How to work with terrain meshes and map geometry&lt;br /&gt;
&lt;br /&gt;
'''This tutorial does not cover:'''&lt;br /&gt;
* How to use Blender/Maya/Lightwave/ZBrush/Mudbox/3DSMax&lt;br /&gt;
* How to create a megatexture&lt;br /&gt;
* How to create displacement maps&lt;br /&gt;
* Anything complicated&lt;br /&gt;
&lt;br /&gt;
== Building the Terrain Mesh ==&lt;br /&gt;
[[Image:simpleterrain_mesh.png|thumb|400px|A simple terrain mesh created in Blender]]&lt;br /&gt;
Use your preferred modelling package to create a basic terrain mesh that is exactly 32,768 units long and wide. &lt;br /&gt;
&lt;br /&gt;
It is preferable to keep the terrain as basic as possible, so it can be refined later on during the mapping process. For this reason, the terrain mesh here only contains a very very rough formation of bumps (or 'mountains' as they might be known)&lt;br /&gt;
&lt;br /&gt;
''While you can use any dimensions for your terrain mesh - it is strongly advised to stick to 8k*8k, 16*16k or 32k*32k''&lt;br /&gt;
&lt;br /&gt;
=== Important ===&lt;br /&gt;
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')&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
== Creating a Caulk Hull ==&lt;br /&gt;
[[Image:simpleterrain_caulkhull.png|thumb|400px|The caulk hull]]&lt;br /&gt;
Since maps must be leak-free/sealed, maps with terrain must have a caulk hull to ensure this is the case.&lt;br /&gt;
&lt;br /&gt;
In this case, since the terrain is 32768 units long and wide, the caulk hull should also be the same dimensions. The caulk hull is quickly created from a brush 32768 units long, 32768 wide and 16384 units tall, which is then hollowed. The brushes are also assigned the 'editor/noimpactcaulk' texture, which prevents gunshots and projectiles from hitting the surfaces of the hull (they simply disappear instead.)&lt;br /&gt;
&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
== Setting The Terrain ==&lt;br /&gt;
[[Image:simpleterrain_terraineditor.png|thumb|200px|The Terrain Editor]]&lt;br /&gt;
The mesh must be triangulated before it is exported as an .OBJ, and saved as {{filename|models/terrain/simpleterrain.obj}}. At this stage, a texture is not necessary, and can be set later.&lt;br /&gt;
&lt;br /&gt;
Terrains are set up in the Terrain Editor, accessible via {{accelkey|shift}}{{accelkey|N}}. 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 MegaBuild needs to generate a Megatexture.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
[[Image:simpleterrain_terraineditor2.png|thumb|200px|Root node set up to use the correct terrain mesh]]&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
At this point you may add a player spawn, an atmosphere, and compile the level to check the terrain. However, since there is no material set, there will be rendering issues.&lt;br /&gt;
&lt;br /&gt;
''You may find the 3D terrain is partly covered or obscured by the base of caulk hull. This can be fixed by moving or resizing the caulk hull so it contains the terrain properly.''&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
== Assigning a Material ==&lt;br /&gt;
[[Image:simpleterrain_textured.png|thumb|200px|Textured terrain mesh]]&lt;br /&gt;
It is not possible to assign materials to terrain meshes in EditWorld, you must do this process in your modelling application.&lt;br /&gt;
&lt;br /&gt;
For testing purposes, terrain meshes are often assigned a temporary material until they are in a state that they can be textured properly. Traditionally, this has been one of the existing materials in the game, such as concrete - {{filename|textures/concrete/concrete10}} (although any valid material will work.)&lt;br /&gt;
&lt;br /&gt;
Due to an oddity with the OBJ format, the material name {{filename|textures/concrete/concrete10}} is not valid inside an OBJ file. Instead, the material should be named {{filename|textures__concrete__concrete10}}, where the slashes are replaced by double underscores (single underscores will not work!).&lt;br /&gt;
&lt;br /&gt;
Setting the mesh material differs between modelling packages. However, since OBJ files are text, they can be manually edited with a text editor instead of using the modelling application. The OBJ will contain a line (often about halfway through) starting with &amp;lt;tt&amp;gt;usemtl&amp;lt;/tt&amp;gt; followed by an arbitrary texture name. This line should be replaced with &amp;lt;tt&amp;gt;usemtl textures__concrete__concrete10&amp;lt;/tt&amp;gt; and the file saved.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
editWorld can then be told to reload the OBJ (now with a proper material declaration) via ''Misc -&amp;gt; Reload -&amp;gt; Models'' or clicking the &amp;quot;Reload Models&amp;quot; button.&lt;br /&gt;
&lt;br /&gt;
''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}}.''&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
== Map Geometry ==&lt;br /&gt;
[[Image:simpleterrain_building.png|thumb|200px|Exported geometry used to help edit the terrain]]&lt;br /&gt;
The map and terrain are now in a state that they can be used for level design, however difficulty can arise ensuring the structures in the level fit to the terrain. &lt;br /&gt;
&lt;br /&gt;
This can be countered using editWorld's export tool, which exports map geometry for importing into the modelling package alongside the terrain. This can be done by selecting the geometry to export (such as a building or a reference, located anywhere in the map), and pressing {{accelkey|ctrl}}{{accelkey|e}}. This writes the geometry to {{filename|models/export.obj}}.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
[[Image:simpleterrain_refinedmesh.png|thumb|200px|Exported geometry used to help edit the terrain]]&lt;br /&gt;
The exported geometry can then be used as a template to modify the terrain accordingly - such as flattening areas of land to fit buildings, cutting holes for entrances of simply adding more detail. The modified terrain mesh is then saved for further work in editWorld.&lt;br /&gt;
&lt;br /&gt;
Most often, terrain vertices are snapped to the corners of buildings and structures, such that the terrain faces now covered by the building can be deleted. This allows for buildings to sink into the terrain, and lead into underground areas of the map.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
[[Image:simpleterrain_fixedterrain.png|thumb|200px|Terrain after being edited to fit the geometry.]]&lt;br /&gt;
This process of refinement is repeated many times throughout the life of the map, ensuring the terrain precisely fits the map geometry. &lt;br /&gt;
&lt;br /&gt;
''When working with terrained maps, most level geometry is stored in separate [[References]] to allow for easy editing.''&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
== That's it! ==&lt;br /&gt;
[[Image:simpleterrain_ingame.png|thumb|400px|Terrain in-game]]&lt;br /&gt;
You've now created a map with your very own terrain!&lt;br /&gt;
&lt;br /&gt;
'''Things to try:'''&lt;br /&gt;
* Assign a different texture to the terrain mesh&lt;br /&gt;
* Make the terrain an island with [[Water Surfaces]]&lt;br /&gt;
* Cut a hole in the terrain to create an underground area&lt;br /&gt;
&lt;br /&gt;
'''You can now proceed to [[A Simple First Megatexture]], which guides you through the process of texturing your terrain and creating a MegaTexture for it.'''&lt;br /&gt;
&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
== Advanced Bits and Pieces ==&lt;br /&gt;
&lt;br /&gt;
=== Atmosphere ===&lt;br /&gt;
You may find your atmosphere doesn't project sunlight and shadow correctly. This is because the engine needs to know the area you have created is outside. The simplest way to do this is to create a brush in the corner of the caulk hull, textured with 'editor/outsideportal'.&lt;br /&gt;
&lt;br /&gt;
=== Terrain Mesh UVs ===&lt;br /&gt;
If you find your terrain is a constant grey, rather than showing a texture (as in the screenshots) 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.&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
* [[Making a Terrain Model]] - an advanced guide for complete terrain creation&lt;br /&gt;
* [[Design: How do I|How do I...?]] - how to do common tasks&lt;br /&gt;
* [[Design: Troubleshooting]] - troubleshooting guide&lt;br /&gt;
* [[A Simple First Map]] - the first mapping tutorial&lt;br /&gt;
* [[A Simple Second Map]] - the second mapping tutorial&lt;br /&gt;
* [[A Simple First Megatexture]] - tutorial covering megatexture creation&lt;br /&gt;
* [[An Advanced Map]] - a more complex guide to creating a map, including terrain&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Basic Level Design]]&lt;br /&gt;
[[Category:Tutorials]]&lt;/div&gt;</summary>
		<author><name>Ducks</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.splashdamage.com/index.php?title=A_Simple_First_Terrain&amp;diff=4069</id>
		<title>A Simple First Terrain</title>
		<link rel="alternate" type="text/html" href="https://wiki.splashdamage.com/index.php?title=A_Simple_First_Terrain&amp;diff=4069"/>
		<updated>2007-12-17T15:56:05Z</updated>

		<summary type="html">&lt;p&gt;Ducks: /* That's it! */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is the barebones guide towards creating your first simple terrain and adding it to a map. This terrain won't be as detailed or as attractive as a full terrain, but will demonstrate the basics of creating a terrain mesh, assigning a texture, and adding it in-game.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
'''For this tutorial you must:'''&lt;br /&gt;
* Have a modelling package that can export as OBJ&lt;br /&gt;
* Have basic modelling skills&lt;br /&gt;
* Have basic mapping skills&lt;br /&gt;
&lt;br /&gt;
If you can't do any of the above things, this tutorial is not for you!&lt;br /&gt;
&lt;br /&gt;
'''This tutorial covers:'''&lt;br /&gt;
* How to create a terrain mesh and caulk hull&lt;br /&gt;
* How to add a terrain mesh to a map&lt;br /&gt;
* How to assign a texture&lt;br /&gt;
* How to work with terrain meshes and map geometry&lt;br /&gt;
&lt;br /&gt;
'''This tutorial does not cover:'''&lt;br /&gt;
* How to use Blender/Maya/Lightwave/ZBrush/Mudbox/3DSMax&lt;br /&gt;
* How to create a megatexture&lt;br /&gt;
* How to create displacement maps&lt;br /&gt;
* Anything complicated&lt;br /&gt;
&lt;br /&gt;
== Building the Terrain Mesh ==&lt;br /&gt;
[[Image:simpleterrain_mesh.png|thumb|400px|A simple terrain mesh created in Blender]]&lt;br /&gt;
Use your preferred modelling package to create a basic terrain mesh that is exactly 32,768 units long and wide. &lt;br /&gt;
&lt;br /&gt;
It is preferable to keep the terrain as basic as possible, so it can be refined later on during the mapping process. For this reason, the terrain mesh here only contains a very very rough formation of bumps (or 'mountains' as they might be known)&lt;br /&gt;
&lt;br /&gt;
''While you can use any dimensions for your terrain mesh - it is strongly advised to stick to 8k*8k, 16*16k or 32k*32k''&lt;br /&gt;
&lt;br /&gt;
=== Important ===&lt;br /&gt;
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')&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
== Creating a Caulk Hull ==&lt;br /&gt;
[[Image:simpleterrain_caulkhull.png|thumb|400px|The caulk hull]]&lt;br /&gt;
Since maps must be leak-free/sealed, maps with terrain must have a caulk hull to ensure this is the case.&lt;br /&gt;
&lt;br /&gt;
In this case, since the terrain is 32768 units long and wide, the caulk hull should also be the same dimensions. The caulk hull is quickly created from a brush 32768 units long, 32768 wide and 16384 units tall, which is then hollowed. The brushes are also assigned the 'editor/noimpactcaulk' texture, which prevents gunshots and projectiles from hitting the surfaces of the hull (they simply disappear instead.)&lt;br /&gt;
&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
== Setting The Terrain ==&lt;br /&gt;
[[Image:simpleterrain_terraineditor.png|thumb|200px|The Terrain Editor]]&lt;br /&gt;
The mesh must be triangulated before it is exported as an .OBJ, and saved as {{filename|models/terrain/simpleterrain.obj}}. At this stage, a texture is not necessary, and can be set later.&lt;br /&gt;
&lt;br /&gt;
Terrains are set up in the Terrain Editor, accessible via {{accelkey|shift}}{{accelkey|N}}. 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 MegaBuild needs to generate a Megatexture.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
[[Image:simpleterrain_terraineditor2.png|thumb|200px|Root node set up to use the correct terrain mesh]]&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
At this point you may add a player spawn, an atmosphere, and compile the level to check the terrain. However, since there is no material set, there will be rendering issues.&lt;br /&gt;
&lt;br /&gt;
''You may find the 3D terrain is partly covered or obscured by the base of caulk hull. This can be fixed by moving or resizing the caulk hull so it contains the terrain properly.''&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
== Assigning a Material ==&lt;br /&gt;
[[Image:simpleterrain_textured.png|thumb|200px|Textured terrain mesh]]&lt;br /&gt;
It is not possible to assign materials to terrain meshes in EditWorld, you must do this process in your modelling application.&lt;br /&gt;
&lt;br /&gt;
For testing purposes, terrain meshes are often assigned a temporary material until they are in a state that they can be textured properly. Traditionally, this has been one of the existing materials in the game, such as concrete - {{filename|textures/concrete/concrete10}} (although any valid material will work.)&lt;br /&gt;
&lt;br /&gt;
Due to an oddity with the OBJ format, the material name {{filename|textures/concrete/concrete10}} is not valid inside an OBJ file. Instead, the material should be named {{filename|textures__concrete__concrete10}}, where the slashes are replaced by double underscores (single underscores will not work!).&lt;br /&gt;
&lt;br /&gt;
Setting the mesh material differs between modelling packages. However, since OBJ files are text, they can be manually edited with a text editor instead of using the modelling application. The OBJ will contain a line (often about halfway through) starting with &amp;lt;tt&amp;gt;usemtl&amp;lt;/tt&amp;gt; followed by an arbitrary texture name. This line should be replaced with &amp;lt;tt&amp;gt;usemtl textures__concrete__concrete10&amp;lt;/tt&amp;gt; and the file saved.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
editWorld can then be told to reload the OBJ (now with a proper material declaration) via ''Misc -&amp;gt; Reload -&amp;gt; Models'' or clicking the &amp;quot;Reload Models&amp;quot; button.&lt;br /&gt;
&lt;br /&gt;
''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}}.''&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
== Map Geometry ==&lt;br /&gt;
[[Image:simpleterrain_building.png|thumb|200px|Exported geometry used to help edit the terrain]]&lt;br /&gt;
The map and terrain are now in a state that they can be used for level design, however difficulty can arise ensuring the structures in the level fit to the terrain. &lt;br /&gt;
&lt;br /&gt;
This can be countered using editWorld's export tool, which exports map geometry for importing into the modelling package alongside the terrain. This can be done by selecting the geometry to export (such as a building or a reference, located anywhere in the map), and pressing {{accelkey|ctrl}}{{accelkey|e}}. This writes the geometry to {{filename|models/export.obj}}.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
[[Image:simpleterrain_refinedmesh.png|thumb|200px|Exported geometry used to help edit the terrain]]&lt;br /&gt;
The exported geometry can then be used as a template to modify the terrain accordingly - such as flattening areas of land to fit buildings, cutting holes for entrances of simply adding more detail. The modified terrain mesh is then saved for further work in editWorld.&lt;br /&gt;
&lt;br /&gt;
Most often, terrain vertices are snapped to the corners of buildings and structures, such that the terrain faces now covered by the building can be deleted. This allows for buildings to sink into the terrain, and lead into underground areas of the map.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
[[Image:simpleterrain_fixedterrain.png|thumb|200px|Terrain after being edited to fit the geometry.]]&lt;br /&gt;
This process of refinement is repeated many times throughout the life of the map, ensuring the terrain precisely fits the map geometry. &lt;br /&gt;
&lt;br /&gt;
''When working with terrained maps, most level geometry is stored in separate [[References]] to allow for easy editing.''&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
== That's it! ==&lt;br /&gt;
[[Image:simpleterrain_ingame.png|thumb|400px|Terrain in-game]]&lt;br /&gt;
You've now created a map with your very own terrain!&lt;br /&gt;
&lt;br /&gt;
'''Things to try:'''&lt;br /&gt;
* Assign a different texture to the terrain mesh&lt;br /&gt;
* Make the terrain an island with [[Water Surfaces]]&lt;br /&gt;
* Cut a hole in the terrain to create an underground area&lt;br /&gt;
&lt;br /&gt;
''You can now proceed to [[A Simple First Megatexture]], which guides you through the process of texturing your terrain and creating a MegaTexture for it.''&lt;br /&gt;
&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
== Advanced Bits and Pieces ==&lt;br /&gt;
&lt;br /&gt;
=== Atmosphere ===&lt;br /&gt;
You may find your atmosphere doesn't project sunlight and shadow correctly. This is because the engine needs to know the area you have created is outside. The simplest way to do this is to create a brush in the corner of the caulk hull, textured with 'editor/outsideportal'.&lt;br /&gt;
&lt;br /&gt;
=== Terrain Mesh UVs ===&lt;br /&gt;
If you find your terrain is a constant grey, rather than showing a texture (as in the screenshots) 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.&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
* [[Making a Terrain Model]] - an advanced guide for complete terrain creation&lt;br /&gt;
* [[Design: How do I|How do I...?]] - how to do common tasks&lt;br /&gt;
* [[Design: Troubleshooting]] - troubleshooting guide&lt;br /&gt;
* [[A Simple First Map]] - the first mapping tutorial&lt;br /&gt;
* [[A Simple Second Map]] - the second mapping tutorial&lt;br /&gt;
* [[A Simple First Megatexture]] - tutorial covering megatexture creation&lt;br /&gt;
* [[An Advanced Map]] - a more complex guide to creating a map, including terrain&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Basic Level Design]]&lt;br /&gt;
[[Category:Tutorials]]&lt;/div&gt;</summary>
		<author><name>Ducks</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.splashdamage.com/index.php?title=A_Simple_First_Terrain&amp;diff=4068</id>
		<title>A Simple First Terrain</title>
		<link rel="alternate" type="text/html" href="https://wiki.splashdamage.com/index.php?title=A_Simple_First_Terrain&amp;diff=4068"/>
		<updated>2007-12-17T15:55:55Z</updated>

		<summary type="html">&lt;p&gt;Ducks: /* That's it! */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is the barebones guide towards creating your first simple terrain and adding it to a map. This terrain won't be as detailed or as attractive as a full terrain, but will demonstrate the basics of creating a terrain mesh, assigning a texture, and adding it in-game.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
'''For this tutorial you must:'''&lt;br /&gt;
* Have a modelling package that can export as OBJ&lt;br /&gt;
* Have basic modelling skills&lt;br /&gt;
* Have basic mapping skills&lt;br /&gt;
&lt;br /&gt;
If you can't do any of the above things, this tutorial is not for you!&lt;br /&gt;
&lt;br /&gt;
'''This tutorial covers:'''&lt;br /&gt;
* How to create a terrain mesh and caulk hull&lt;br /&gt;
* How to add a terrain mesh to a map&lt;br /&gt;
* How to assign a texture&lt;br /&gt;
* How to work with terrain meshes and map geometry&lt;br /&gt;
&lt;br /&gt;
'''This tutorial does not cover:'''&lt;br /&gt;
* How to use Blender/Maya/Lightwave/ZBrush/Mudbox/3DSMax&lt;br /&gt;
* How to create a megatexture&lt;br /&gt;
* How to create displacement maps&lt;br /&gt;
* Anything complicated&lt;br /&gt;
&lt;br /&gt;
== Building the Terrain Mesh ==&lt;br /&gt;
[[Image:simpleterrain_mesh.png|thumb|400px|A simple terrain mesh created in Blender]]&lt;br /&gt;
Use your preferred modelling package to create a basic terrain mesh that is exactly 32,768 units long and wide. &lt;br /&gt;
&lt;br /&gt;
It is preferable to keep the terrain as basic as possible, so it can be refined later on during the mapping process. For this reason, the terrain mesh here only contains a very very rough formation of bumps (or 'mountains' as they might be known)&lt;br /&gt;
&lt;br /&gt;
''While you can use any dimensions for your terrain mesh - it is strongly advised to stick to 8k*8k, 16*16k or 32k*32k''&lt;br /&gt;
&lt;br /&gt;
=== Important ===&lt;br /&gt;
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')&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
== Creating a Caulk Hull ==&lt;br /&gt;
[[Image:simpleterrain_caulkhull.png|thumb|400px|The caulk hull]]&lt;br /&gt;
Since maps must be leak-free/sealed, maps with terrain must have a caulk hull to ensure this is the case.&lt;br /&gt;
&lt;br /&gt;
In this case, since the terrain is 32768 units long and wide, the caulk hull should also be the same dimensions. The caulk hull is quickly created from a brush 32768 units long, 32768 wide and 16384 units tall, which is then hollowed. The brushes are also assigned the 'editor/noimpactcaulk' texture, which prevents gunshots and projectiles from hitting the surfaces of the hull (they simply disappear instead.)&lt;br /&gt;
&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
== Setting The Terrain ==&lt;br /&gt;
[[Image:simpleterrain_terraineditor.png|thumb|200px|The Terrain Editor]]&lt;br /&gt;
The mesh must be triangulated before it is exported as an .OBJ, and saved as {{filename|models/terrain/simpleterrain.obj}}. At this stage, a texture is not necessary, and can be set later.&lt;br /&gt;
&lt;br /&gt;
Terrains are set up in the Terrain Editor, accessible via {{accelkey|shift}}{{accelkey|N}}. 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 MegaBuild needs to generate a Megatexture.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
[[Image:simpleterrain_terraineditor2.png|thumb|200px|Root node set up to use the correct terrain mesh]]&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
At this point you may add a player spawn, an atmosphere, and compile the level to check the terrain. However, since there is no material set, there will be rendering issues.&lt;br /&gt;
&lt;br /&gt;
''You may find the 3D terrain is partly covered or obscured by the base of caulk hull. This can be fixed by moving or resizing the caulk hull so it contains the terrain properly.''&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
== Assigning a Material ==&lt;br /&gt;
[[Image:simpleterrain_textured.png|thumb|200px|Textured terrain mesh]]&lt;br /&gt;
It is not possible to assign materials to terrain meshes in EditWorld, you must do this process in your modelling application.&lt;br /&gt;
&lt;br /&gt;
For testing purposes, terrain meshes are often assigned a temporary material until they are in a state that they can be textured properly. Traditionally, this has been one of the existing materials in the game, such as concrete - {{filename|textures/concrete/concrete10}} (although any valid material will work.)&lt;br /&gt;
&lt;br /&gt;
Due to an oddity with the OBJ format, the material name {{filename|textures/concrete/concrete10}} is not valid inside an OBJ file. Instead, the material should be named {{filename|textures__concrete__concrete10}}, where the slashes are replaced by double underscores (single underscores will not work!).&lt;br /&gt;
&lt;br /&gt;
Setting the mesh material differs between modelling packages. However, since OBJ files are text, they can be manually edited with a text editor instead of using the modelling application. The OBJ will contain a line (often about halfway through) starting with &amp;lt;tt&amp;gt;usemtl&amp;lt;/tt&amp;gt; followed by an arbitrary texture name. This line should be replaced with &amp;lt;tt&amp;gt;usemtl textures__concrete__concrete10&amp;lt;/tt&amp;gt; and the file saved.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
editWorld can then be told to reload the OBJ (now with a proper material declaration) via ''Misc -&amp;gt; Reload -&amp;gt; Models'' or clicking the &amp;quot;Reload Models&amp;quot; button.&lt;br /&gt;
&lt;br /&gt;
''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}}.''&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
== Map Geometry ==&lt;br /&gt;
[[Image:simpleterrain_building.png|thumb|200px|Exported geometry used to help edit the terrain]]&lt;br /&gt;
The map and terrain are now in a state that they can be used for level design, however difficulty can arise ensuring the structures in the level fit to the terrain. &lt;br /&gt;
&lt;br /&gt;
This can be countered using editWorld's export tool, which exports map geometry for importing into the modelling package alongside the terrain. This can be done by selecting the geometry to export (such as a building or a reference, located anywhere in the map), and pressing {{accelkey|ctrl}}{{accelkey|e}}. This writes the geometry to {{filename|models/export.obj}}.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
[[Image:simpleterrain_refinedmesh.png|thumb|200px|Exported geometry used to help edit the terrain]]&lt;br /&gt;
The exported geometry can then be used as a template to modify the terrain accordingly - such as flattening areas of land to fit buildings, cutting holes for entrances of simply adding more detail. The modified terrain mesh is then saved for further work in editWorld.&lt;br /&gt;
&lt;br /&gt;
Most often, terrain vertices are snapped to the corners of buildings and structures, such that the terrain faces now covered by the building can be deleted. This allows for buildings to sink into the terrain, and lead into underground areas of the map.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
[[Image:simpleterrain_fixedterrain.png|thumb|200px|Terrain after being edited to fit the geometry.]]&lt;br /&gt;
This process of refinement is repeated many times throughout the life of the map, ensuring the terrain precisely fits the map geometry. &lt;br /&gt;
&lt;br /&gt;
''When working with terrained maps, most level geometry is stored in separate [[References]] to allow for easy editing.''&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
== That's it! ==&lt;br /&gt;
[[Image:simpleterrain_ingame.png|thumb|400px|Terrain in-game]]&lt;br /&gt;
You've now created a map with your very own terrain!&lt;br /&gt;
&lt;br /&gt;
'''Things to try:'''&lt;br /&gt;
* Assign a different texture to the terrain mesh&lt;br /&gt;
* Make the terrain an island with [[Water Surfaces]]&lt;br /&gt;
* Cut a hole in the terrain to create an underground area&lt;br /&gt;
&lt;br /&gt;
You can also now proceed to [[A Simple First Megatexture]], which guides you through the process of texturing your terrain and creating a MegaTexture for it.&lt;br /&gt;
&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
== Advanced Bits and Pieces ==&lt;br /&gt;
&lt;br /&gt;
=== Atmosphere ===&lt;br /&gt;
You may find your atmosphere doesn't project sunlight and shadow correctly. This is because the engine needs to know the area you have created is outside. The simplest way to do this is to create a brush in the corner of the caulk hull, textured with 'editor/outsideportal'.&lt;br /&gt;
&lt;br /&gt;
=== Terrain Mesh UVs ===&lt;br /&gt;
If you find your terrain is a constant grey, rather than showing a texture (as in the screenshots) 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.&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
* [[Making a Terrain Model]] - an advanced guide for complete terrain creation&lt;br /&gt;
* [[Design: How do I|How do I...?]] - how to do common tasks&lt;br /&gt;
* [[Design: Troubleshooting]] - troubleshooting guide&lt;br /&gt;
* [[A Simple First Map]] - the first mapping tutorial&lt;br /&gt;
* [[A Simple Second Map]] - the second mapping tutorial&lt;br /&gt;
* [[A Simple First Megatexture]] - tutorial covering megatexture creation&lt;br /&gt;
* [[An Advanced Map]] - a more complex guide to creating a map, including terrain&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Basic Level Design]]&lt;br /&gt;
[[Category:Tutorials]]&lt;/div&gt;</summary>
		<author><name>Ducks</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.splashdamage.com/index.php?title=A_Simple_First_Terrain&amp;diff=4067</id>
		<title>A Simple First Terrain</title>
		<link rel="alternate" type="text/html" href="https://wiki.splashdamage.com/index.php?title=A_Simple_First_Terrain&amp;diff=4067"/>
		<updated>2007-12-17T15:55:18Z</updated>

		<summary type="html">&lt;p&gt;Ducks: /* See Also */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is the barebones guide towards creating your first simple terrain and adding it to a map. This terrain won't be as detailed or as attractive as a full terrain, but will demonstrate the basics of creating a terrain mesh, assigning a texture, and adding it in-game.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
'''For this tutorial you must:'''&lt;br /&gt;
* Have a modelling package that can export as OBJ&lt;br /&gt;
* Have basic modelling skills&lt;br /&gt;
* Have basic mapping skills&lt;br /&gt;
&lt;br /&gt;
If you can't do any of the above things, this tutorial is not for you!&lt;br /&gt;
&lt;br /&gt;
'''This tutorial covers:'''&lt;br /&gt;
* How to create a terrain mesh and caulk hull&lt;br /&gt;
* How to add a terrain mesh to a map&lt;br /&gt;
* How to assign a texture&lt;br /&gt;
* How to work with terrain meshes and map geometry&lt;br /&gt;
&lt;br /&gt;
'''This tutorial does not cover:'''&lt;br /&gt;
* How to use Blender/Maya/Lightwave/ZBrush/Mudbox/3DSMax&lt;br /&gt;
* How to create a megatexture&lt;br /&gt;
* How to create displacement maps&lt;br /&gt;
* Anything complicated&lt;br /&gt;
&lt;br /&gt;
== Building the Terrain Mesh ==&lt;br /&gt;
[[Image:simpleterrain_mesh.png|thumb|400px|A simple terrain mesh created in Blender]]&lt;br /&gt;
Use your preferred modelling package to create a basic terrain mesh that is exactly 32,768 units long and wide. &lt;br /&gt;
&lt;br /&gt;
It is preferable to keep the terrain as basic as possible, so it can be refined later on during the mapping process. For this reason, the terrain mesh here only contains a very very rough formation of bumps (or 'mountains' as they might be known)&lt;br /&gt;
&lt;br /&gt;
''While you can use any dimensions for your terrain mesh - it is strongly advised to stick to 8k*8k, 16*16k or 32k*32k''&lt;br /&gt;
&lt;br /&gt;
=== Important ===&lt;br /&gt;
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')&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
== Creating a Caulk Hull ==&lt;br /&gt;
[[Image:simpleterrain_caulkhull.png|thumb|400px|The caulk hull]]&lt;br /&gt;
Since maps must be leak-free/sealed, maps with terrain must have a caulk hull to ensure this is the case.&lt;br /&gt;
&lt;br /&gt;
In this case, since the terrain is 32768 units long and wide, the caulk hull should also be the same dimensions. The caulk hull is quickly created from a brush 32768 units long, 32768 wide and 16384 units tall, which is then hollowed. The brushes are also assigned the 'editor/noimpactcaulk' texture, which prevents gunshots and projectiles from hitting the surfaces of the hull (they simply disappear instead.)&lt;br /&gt;
&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
== Setting The Terrain ==&lt;br /&gt;
[[Image:simpleterrain_terraineditor.png|thumb|200px|The Terrain Editor]]&lt;br /&gt;
The mesh must be triangulated before it is exported as an .OBJ, and saved as {{filename|models/terrain/simpleterrain.obj}}. At this stage, a texture is not necessary, and can be set later.&lt;br /&gt;
&lt;br /&gt;
Terrains are set up in the Terrain Editor, accessible via {{accelkey|shift}}{{accelkey|N}}. 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 MegaBuild needs to generate a Megatexture.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
[[Image:simpleterrain_terraineditor2.png|thumb|200px|Root node set up to use the correct terrain mesh]]&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
At this point you may add a player spawn, an atmosphere, and compile the level to check the terrain. However, since there is no material set, there will be rendering issues.&lt;br /&gt;
&lt;br /&gt;
''You may find the 3D terrain is partly covered or obscured by the base of caulk hull. This can be fixed by moving or resizing the caulk hull so it contains the terrain properly.''&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
== Assigning a Material ==&lt;br /&gt;
[[Image:simpleterrain_textured.png|thumb|200px|Textured terrain mesh]]&lt;br /&gt;
It is not possible to assign materials to terrain meshes in EditWorld, you must do this process in your modelling application.&lt;br /&gt;
&lt;br /&gt;
For testing purposes, terrain meshes are often assigned a temporary material until they are in a state that they can be textured properly. Traditionally, this has been one of the existing materials in the game, such as concrete - {{filename|textures/concrete/concrete10}} (although any valid material will work.)&lt;br /&gt;
&lt;br /&gt;
Due to an oddity with the OBJ format, the material name {{filename|textures/concrete/concrete10}} is not valid inside an OBJ file. Instead, the material should be named {{filename|textures__concrete__concrete10}}, where the slashes are replaced by double underscores (single underscores will not work!).&lt;br /&gt;
&lt;br /&gt;
Setting the mesh material differs between modelling packages. However, since OBJ files are text, they can be manually edited with a text editor instead of using the modelling application. The OBJ will contain a line (often about halfway through) starting with &amp;lt;tt&amp;gt;usemtl&amp;lt;/tt&amp;gt; followed by an arbitrary texture name. This line should be replaced with &amp;lt;tt&amp;gt;usemtl textures__concrete__concrete10&amp;lt;/tt&amp;gt; and the file saved.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
editWorld can then be told to reload the OBJ (now with a proper material declaration) via ''Misc -&amp;gt; Reload -&amp;gt; Models'' or clicking the &amp;quot;Reload Models&amp;quot; button.&lt;br /&gt;
&lt;br /&gt;
''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}}.''&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
== Map Geometry ==&lt;br /&gt;
[[Image:simpleterrain_building.png|thumb|200px|Exported geometry used to help edit the terrain]]&lt;br /&gt;
The map and terrain are now in a state that they can be used for level design, however difficulty can arise ensuring the structures in the level fit to the terrain. &lt;br /&gt;
&lt;br /&gt;
This can be countered using editWorld's export tool, which exports map geometry for importing into the modelling package alongside the terrain. This can be done by selecting the geometry to export (such as a building or a reference, located anywhere in the map), and pressing {{accelkey|ctrl}}{{accelkey|e}}. This writes the geometry to {{filename|models/export.obj}}.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
[[Image:simpleterrain_refinedmesh.png|thumb|200px|Exported geometry used to help edit the terrain]]&lt;br /&gt;
The exported geometry can then be used as a template to modify the terrain accordingly - such as flattening areas of land to fit buildings, cutting holes for entrances of simply adding more detail. The modified terrain mesh is then saved for further work in editWorld.&lt;br /&gt;
&lt;br /&gt;
Most often, terrain vertices are snapped to the corners of buildings and structures, such that the terrain faces now covered by the building can be deleted. This allows for buildings to sink into the terrain, and lead into underground areas of the map.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
[[Image:simpleterrain_fixedterrain.png|thumb|200px|Terrain after being edited to fit the geometry.]]&lt;br /&gt;
This process of refinement is repeated many times throughout the life of the map, ensuring the terrain precisely fits the map geometry. &lt;br /&gt;
&lt;br /&gt;
''When working with terrained maps, most level geometry is stored in separate [[References]] to allow for easy editing.''&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
== That's it! ==&lt;br /&gt;
[[Image:simpleterrain_ingame.png|thumb|400px|Terrain in-game]]&lt;br /&gt;
You've now created a map with your very own terrain!&lt;br /&gt;
&lt;br /&gt;
'''Things to try:'''&lt;br /&gt;
* Assign a different texture to the terrain mesh&lt;br /&gt;
* Make the terrain an island with [[Water Surfaces]]&lt;br /&gt;
* Cut a hole in the terrain to create an underground area&lt;br /&gt;
&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
== Advanced Bits and Pieces ==&lt;br /&gt;
&lt;br /&gt;
=== Atmosphere ===&lt;br /&gt;
You may find your atmosphere doesn't project sunlight and shadow correctly. This is because the engine needs to know the area you have created is outside. The simplest way to do this is to create a brush in the corner of the caulk hull, textured with 'editor/outsideportal'.&lt;br /&gt;
&lt;br /&gt;
=== Terrain Mesh UVs ===&lt;br /&gt;
If you find your terrain is a constant grey, rather than showing a texture (as in the screenshots) 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.&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
* [[Making a Terrain Model]] - an advanced guide for complete terrain creation&lt;br /&gt;
* [[Design: How do I|How do I...?]] - how to do common tasks&lt;br /&gt;
* [[Design: Troubleshooting]] - troubleshooting guide&lt;br /&gt;
* [[A Simple First Map]] - the first mapping tutorial&lt;br /&gt;
* [[A Simple Second Map]] - the second mapping tutorial&lt;br /&gt;
* [[A Simple First Megatexture]] - tutorial covering megatexture creation&lt;br /&gt;
* [[An Advanced Map]] - a more complex guide to creating a map, including terrain&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Basic Level Design]]&lt;br /&gt;
[[Category:Tutorials]]&lt;/div&gt;</summary>
		<author><name>Ducks</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.splashdamage.com/index.php?title=A_Simple_First_Megatexture&amp;diff=4066</id>
		<title>A Simple First Megatexture</title>
		<link rel="alternate" type="text/html" href="https://wiki.splashdamage.com/index.php?title=A_Simple_First_Megatexture&amp;diff=4066"/>
		<updated>2007-12-17T15:29:40Z</updated>

		<summary type="html">&lt;p&gt;Ducks: /* Further tweaks */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Image:simplemega_ingame.jpg|right|thumb|500px|A simple MegaTexture, easily created with only 3 texture layers!]]&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
'''For this tutorial you must:'''&lt;br /&gt;
* Have a terrain model UV-mapped in the 0-1 range (covered in the simple first terrain tutorial)&lt;br /&gt;
* Have access to some tiling textures.&lt;br /&gt;
* Have a little understanding the ETQW material system&lt;br /&gt;
&lt;br /&gt;
If you don't have any of the above things, you are not ready to do this tutorial!&lt;br /&gt;
&lt;br /&gt;
'''This tutorial covers:'''&lt;br /&gt;
* How to set up a MegaTexture material&lt;br /&gt;
* How to create a Surface Tree&lt;br /&gt;
* How to add texture nodes in the Terrain Editor&lt;br /&gt;
* How to render and compile a full MegaTexture&lt;br /&gt;
&lt;br /&gt;
'''This tutorial does not cover:'''&lt;br /&gt;
* How to use Blender/Maya/Lightwave/ZBrush/Mudbox/3DSMax/Photoshop&lt;br /&gt;
* How to create tiling textures or heightmaps&lt;br /&gt;
* Anything overly complicated&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Creating a MegaTexture material ==&lt;br /&gt;
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:&lt;br /&gt;
 material megatextures/mapname		{ useTemplate megatextures/default_ambient&amp;lt; &amp;quot;mapname&amp;quot; &amp;gt; }&lt;br /&gt;
&lt;br /&gt;
This material would automatically search for a MegaTexture called {{filename|mapname.mega}} in the {{filename|/megatextures/}} folder. This example material uses the ''&amp;quot;default_ambient&amp;quot;'' 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]].&lt;br /&gt;
&lt;br /&gt;
Obviously you would want to use the actual name of your map instead of &amp;quot;mapname&amp;quot;, for consistency's sake and ease of reference.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Assigning the material ===&lt;br /&gt;
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).&lt;br /&gt;
Tips on this process can be found in the [[A Simple First Terrain|simple first terrain tutorial]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Creating the Surface Tree ==&lt;br /&gt;
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 &amp;quot;Save and Unload&amp;quot; button in the Terrain Editor.&lt;br /&gt;
[[Image:simplemega_terrainmodel.png|thumb|300px|Root node set up to use the correct terrain mesh]]&lt;br /&gt;
&lt;br /&gt;
=== Add the terrain mesh ===&lt;br /&gt;
Here's how you bring the terrain mesh into the surface tree:&lt;br /&gt;
* {{accelbtn|RMB}} on the left-hand pane, and choose ''New -&amp;gt; Tree'' via the menu.&lt;br /&gt;
** If you already have a Root node, click the &amp;quot;Begin Editing&amp;quot; button instead.&lt;br /&gt;
* Click on the Root node, and set {{keyname|Model}} to the name of the terrain mesh, in this case {{keyvalue|models/terrain/simpleterrain.obj}}.&lt;br /&gt;
* Press {{accelkey|enter}} to confirm the selection, and the terrain should appear in the 3D view.&lt;br /&gt;
&lt;br /&gt;
Be aware that your terrain model will probably appear bright orange or red.&lt;br /&gt;
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!&lt;br /&gt;
&lt;br /&gt;
=== Important note about nodes ===&lt;br /&gt;
When you are editing properties of nodes (names, numbers, texture sources etc.) always remember to hit {{accelkey|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 {{accelkey|enter}}, your changes may not be applied.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Create the first texture node ==&lt;br /&gt;
[[Image:simplemega_firstnode_diffuse.png|thumb|300px|The first texture node's diffuse texture properties]]&lt;br /&gt;
Now that the model is in place, you can start laying down the texture layers (or &amp;quot;nodes&amp;quot;) that will make up your MegaTexture.&lt;br /&gt;
&lt;br /&gt;
First you need to create a new Image Source node in the Terrain Editor.&lt;br /&gt;
* {{accelbtn|RMB}} on your &amp;quot;Root&amp;quot; node and choose ''New -&amp;gt; Image Source'' (or press {{accelkey|shift}}{{accelkey|i}})&lt;br /&gt;
* This will make a new node called &amp;quot;New Image Renderer&amp;quot;.&lt;br /&gt;
* You can rename this new node using the &amp;quot;Name&amp;quot; property field in the '''Object''' section.&lt;br /&gt;
* Rename the node &amp;quot;Dirt&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
You will notice in the top right of the Terrain Editor, a section listing things like &amp;quot;Diffuse&amp;quot;, &amp;quot;Distribution&amp;quot;, &amp;quot;Distribution Pattern&amp;quot; etc. Selecting one of these will list all of the properties for that section of the current node.&lt;br /&gt;
The ones we need to worry about are as follows:&lt;br /&gt;
&lt;br /&gt;
=== Diffuse ===&lt;br /&gt;
This is the colour map of the current node, and it should point to a tiling TGA texture.&lt;br /&gt;
* Make sure the Diffuse section is highlighted in the top right of the Terrain Editor.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to a generic tiling dirt texture. Remember to hit {{accelkey|enter}} afterwards!&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/dirt_02_d.tga}}&lt;br /&gt;
* The {{keyname|Scale}} field at the very bottom of the property list allows you to choose how much to tile the texture.&lt;br /&gt;
** 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!&lt;br /&gt;
** 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.&lt;br /&gt;
That's all you need to do for the Diffuse settings in this node.&lt;br /&gt;
&lt;br /&gt;
=== Distribution ===&lt;br /&gt;
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''.&lt;br /&gt;
* Make sure the Distribution section is highlighted in the top right.&lt;br /&gt;
* Since this is our first node, we want to show over the whole terrain. This means the distribution map should be 100% white.&lt;br /&gt;
* You can either assign a pure white TGA texture, or change the {{keyname|Source Type}} to {{keyvalue|geometryBased}}.&lt;br /&gt;
** {{keyvalue|geometryBased}} will by default create a fully white map, so if you don't have a white TGA handy, this is faster.&lt;br /&gt;
&lt;br /&gt;
=== Distribution Pattern ===&lt;br /&gt;
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.&lt;br /&gt;
* 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!&lt;br /&gt;
&lt;br /&gt;
=== Local ===&lt;br /&gt;
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.&lt;br /&gt;
* Make sure the Local section is highlighted in the top right.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching normal map for your tiling dirt texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/dirt_02_local.tga}}&lt;br /&gt;
* The Local texture's tiling amount is automatically the same as the Diffuse texture.&lt;br /&gt;
&lt;br /&gt;
=== Surface Type ===&lt;br /&gt;
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.&lt;br /&gt;
* Find the ''Surface Type Properties'' section of the property list.&lt;br /&gt;
* 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.&lt;br /&gt;
* Hit {{accelkey|enter}} to accept the surface type.&lt;br /&gt;
&lt;br /&gt;
Your dirt textures will now produce correct &amp;quot;dirt&amp;quot; effects when shot or collided with!&lt;br /&gt;
&lt;br /&gt;
=== Previewing the result ===&lt;br /&gt;
[[Image:simplemega_firstnode_preview.jpg|thumb|300px|The Render mode preview of the first node]]&lt;br /&gt;
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]]&lt;br /&gt;
&lt;br /&gt;
* Notice the drop-down arrow on the right of the button. Click it, and select ''&amp;quot;Full&amp;quot;'' instead of ''&amp;quot;None&amp;quot;''.&lt;br /&gt;
* Your terrain should change colour to black. This means it's ready for a preview to be rendered onto it.&lt;br /&gt;
* Click the button itself now, instead of the drop-down. An &amp;quot;Active Tasks&amp;quot; window should pop up, and when it's done, you should see your dirt texture appear on your terrain model.&lt;br /&gt;
* You can switch the camera to Render mode too, which will show your terrain model's shading better.&lt;br /&gt;
* If you want a full-resolution preview of a small area, choose ''&amp;quot;Window&amp;quot;'' instead of ''&amp;quot;Full&amp;quot;'' from the drop-down menu.&lt;br /&gt;
** 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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
'''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.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
== Adding a second node ==&lt;br /&gt;
Now that the first layer of dirt is in place, we can try putting some grass on top of it!&lt;br /&gt;
* Again, {{accelbtn|RMB}} on your &amp;quot;Root&amp;quot; node and choose ''New -&amp;gt; Image Source'' (or press {{accelkey|shift}}{{accelkey|i}})&lt;br /&gt;
* This will make another new node below your &amp;quot;Dirt&amp;quot; node. &lt;br /&gt;
* Name this new node &amp;quot;Grass&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Again, the main map types need to be specified before the node can be rendered:&lt;br /&gt;
&lt;br /&gt;
=== Diffuse ===&lt;br /&gt;
* Make sure the Diffuse section is highlighted in the top right of the Terrain Editor.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to a generic tiling grass texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/grass_04_d.tga}}&lt;br /&gt;
* 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.&lt;br /&gt;
&lt;br /&gt;
=== Distribution ===&lt;br /&gt;
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!&lt;br /&gt;
* Make sure the Distribution section is highlighted in the top right.&lt;br /&gt;
* Change the {{keyname|Source Type}} from {{keyvalue|texture}} to {{keyvalue|geometryBased}}.&lt;br /&gt;
&lt;br /&gt;
=== Geometric Texture Distribution ===&lt;br /&gt;
[[Image:simplemega_geometric_distribution.png|thumb|300px|The geometric texture distribution settings of the second node]]&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
* ''Altitude Lower'' - Enabling this will limit the lower parts of the terrain from receiving this node's textures.&lt;br /&gt;
** {{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.&lt;br /&gt;
** {{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.&lt;br /&gt;
* ''Altitude Upper'' - Enabling this will limit the higher parts of the terrain from receiving this node's textures.&lt;br /&gt;
** {{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.&lt;br /&gt;
** {{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.&lt;br /&gt;
&lt;br /&gt;
* {{keyname|Clamp Distribution To Edge}} - Leave this on Default.&lt;br /&gt;
&lt;br /&gt;
* {{keyname|Resolution}} - The size in pixels of the resulting mask. The default value of {{keyvalue|256}} is fine for nearly any terrain model.&lt;br /&gt;
&lt;br /&gt;
* ''Slope Lower'' - Enabling this will limit shallower angles of the terrain model from receiving this node's textures.&lt;br /&gt;
** {{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.&lt;br /&gt;
** {{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.&lt;br /&gt;
* ''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.&lt;br /&gt;
** {{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.&lt;br /&gt;
** {{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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
=== Distribution Pattern ===&lt;br /&gt;
[[Image:simplemega_dist_ramps.jpg|thumb|300px|The difference between using or not using a Distribution Pattern, and varying Ramp Widths]]&lt;br /&gt;
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!&lt;br /&gt;
So what we want here is a texture to identify the &amp;quot;height&amp;quot; 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.&lt;br /&gt;
&lt;br /&gt;
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!&lt;br /&gt;
&lt;br /&gt;
* Make sure {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching heightmap or mask for your tiling grass texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/grass_04_mask.tga}}&lt;br /&gt;
* 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 &amp;quot;Window&amp;quot; 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.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
=== Local ===&lt;br /&gt;
Again we want the normal-map which matches the diffuse texture for the grass.&lt;br /&gt;
* Make sure the Local section is highlighted in the top right.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching normal map for your tiling grass texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/grass_04_local.tga}}&lt;br /&gt;
&lt;br /&gt;
=== Surface Type ===&lt;br /&gt;
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.&lt;br /&gt;
* Find the ''Surface Type Properties'' section of the property list.&lt;br /&gt;
* 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.&lt;br /&gt;
* Hit {{accelkey|enter}} to accept the surface type.&lt;br /&gt;
&lt;br /&gt;
Your grass textures should now produce correct &amp;quot;grass&amp;quot; effects when shot or collided with!&lt;br /&gt;
&lt;br /&gt;
=== Preview ===&lt;br /&gt;
[[Image:simplemega_secondnode_preview.jpg|thumb|300px|The Render mode preview of the second node blended with the first node]]&lt;br /&gt;
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.&lt;br /&gt;
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.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
== Adding a third node ==&lt;br /&gt;
[[Image:simplemega_thirdnode_preview.jpg|thumb|300px|The Render mode preview of the third node blended with the other two nodes]]&lt;br /&gt;
Now that the grass and dirt are in place, we need some rocks to make the terrain look more natural.&lt;br /&gt;
* Add a new Image Renderer node below your &amp;quot;Grass&amp;quot; node and name it &amp;quot;Rock&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Again, the main map types need to be specified before the node can be rendered:&lt;br /&gt;
&lt;br /&gt;
=== Diffuse ===&lt;br /&gt;
* Set the '''Diffuse''' texture and scale.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/rock_01_d.tga}} at a scale of {{keyvalue|32 32}}&lt;br /&gt;
&lt;br /&gt;
=== Distribution ===&lt;br /&gt;
Again we can use Geometric Texture Distribution to easily apply the rock textures only to the cliff-like angles.&lt;br /&gt;
* Make sure the Distribution section is highlighted in the top right.&lt;br /&gt;
* Change the {{keyname|Source Type}} to {{keyvalue|geometryBased}}.&lt;br /&gt;
* 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}}&lt;br /&gt;
&lt;br /&gt;
=== Distribution Pattern ===&lt;br /&gt;
Again this will control how the the rocks blend into the other nodes. Again, we want a texture to identify the &amp;quot;height&amp;quot; of the tiling rock texture.&lt;br /&gt;
&lt;br /&gt;
* Make sure the Distribution Pattern section is highlighted in the top right.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching heightmap or mask for your tiling rock texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/rock_01_h.tga}}&lt;br /&gt;
* 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 &amp;quot;Window&amp;quot; preview to see how the blending looks.&lt;br /&gt;
* Remember to set the {{keyname|Distribution Pattern Texture Scale}} to the same value as the Diffuse Scale, {{keyvalue|32 32}}.&lt;br /&gt;
&lt;br /&gt;
=== Local ===&lt;br /&gt;
Again we want the normal-map which matches the diffuse texture for the rocks.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Local''' section, browse to the matching normal map for your tiling rock texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/rock_01_local.tga}}&lt;br /&gt;
&lt;br /&gt;
=== Surface Type ===&lt;br /&gt;
* Find the ''Surface Type Properties'' section of the property list.&lt;br /&gt;
* In the {{keyname|Type}} field, enter {{keyvalue|stone}}.&lt;br /&gt;
* Hit {{accelkey|enter}} to accept the surface type.&lt;br /&gt;
&lt;br /&gt;
Your rock textures should now produce correct &amp;quot;stone&amp;quot; effects when shot or collided with.&lt;br /&gt;
&lt;br /&gt;
=== Preview ===&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Further tweaks ==&lt;br /&gt;
There are other simple changes that can be done in the Terrain Editor to make your MegaTexture look even better.&lt;br /&gt;
&lt;br /&gt;
=== Node order ===&lt;br /&gt;
[[Image:simplemega_node_order.png|frame|Click and drag a node to change the order]]&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
* {{accelbtn|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.&lt;br /&gt;
* Release {{accelbtn|LMB}} when you have positioned the node in the correct place.&lt;br /&gt;
* 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!&lt;br /&gt;
&lt;br /&gt;
=== Color changes ===&lt;br /&gt;
Maybe your dirt texture is too bright? Or maybe your grass looks a little ''too'' green?&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Let's say you want to make the dirt texture darker and a bit more red. Here's how you'd do it:&lt;br /&gt;
* Select your Dirt node.&lt;br /&gt;
* 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).&lt;br /&gt;
* A color wheel and brightness slider will pop up in a new window. You can use this to darken and tint your texture.&lt;br /&gt;
* Choose a darker brightness, and a color slightly towards red. I used '''RGB Values''' of 225, 220, 220.&lt;br /&gt;
* Hit ''OK'' to accept the color.&lt;br /&gt;
* Re-render your MegaTexture preview. You should notice that the dirt layer looks darker now!&lt;br /&gt;
&lt;br /&gt;
=== Texture rotation ===&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Render the MegaTexture ==&lt;br /&gt;
=== Save the Surface Tree ===&lt;br /&gt;
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 &amp;quot;Save and Unload&amp;quot; button in the Terrain Editor, or save the whole map.&lt;br /&gt;
&lt;br /&gt;
=== Compile Only Entities ===&lt;br /&gt;
At this stage, your MegaTexture material is still technically &amp;quot;broken&amp;quot;, 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.&lt;br /&gt;
&lt;br /&gt;
However, we need to compile the map in order to tell the [[renderLight]] process which atmosphere to use when lighting the MegaTexture!&lt;br /&gt;
&lt;br /&gt;
So the solution is to do an '''Only Entities''' compile. You can find this in the menu ''Compile -&amp;gt; 2 - Only Entities'' in editWorld. This should be done in a few seconds, and compiles all the information that renderLight needs.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Run the SDK Launcher ===&lt;br /&gt;
Now that your ''.sft'' is saved, go through all the steps outlined in the [[Generate a MegaTexture]] tutorial.&lt;br /&gt;
&lt;br /&gt;
== That's it! ==&lt;br /&gt;
[[Image:simplemega_ingame.jpg|thumb|300px|The MegaTexture in-game!]]&lt;br /&gt;
You've now created your very own MegaTexture to use in your map!&lt;br /&gt;
&lt;br /&gt;
Before you even compile the map, you can get an accurate preview of how it will look in-game by pressing {{accelkey|F6}} to toggle &amp;quot;anim&amp;quot; mode while in editWorld's &amp;quot;RENDER&amp;quot; Camera view (toggled with {{accelkey|F3}}).&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
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:&lt;br /&gt;
* 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.&lt;br /&gt;
* 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 ''&amp;lt; &amp;quot;mapname&amp;quot; &amp;gt;'' part described in [[A Simple First Megatexture#Creating a MegaTexture material|this section]]), otherwise it will not be searching for the correct images.&lt;br /&gt;
* 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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
* [[An Advanced Terrain and Megatexture]] - an advanced guide for complete MegaTexture creation&lt;br /&gt;
* [[Generate a MegaTexture]] - steps for generating a MegaTexture from the SDK launcher.&lt;br /&gt;
* [http://community.enemyterritory.com/forums/showthread.php?t=19326 Forum Thread] - includes textures to download&lt;br /&gt;
&lt;br /&gt;
[[Category:Art]]&lt;br /&gt;
[[Category:Basic Level Design]]&lt;br /&gt;
[[Category:Tutorials]]&lt;/div&gt;</summary>
		<author><name>Ducks</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.splashdamage.com/index.php?title=A_Simple_First_Megatexture&amp;diff=4065</id>
		<title>A Simple First Megatexture</title>
		<link rel="alternate" type="text/html" href="https://wiki.splashdamage.com/index.php?title=A_Simple_First_Megatexture&amp;diff=4065"/>
		<updated>2007-12-17T15:16:00Z</updated>

		<summary type="html">&lt;p&gt;Ducks: /* Texture rotation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Image:simplemega_ingame.jpg|right|thumb|500px|A simple MegaTexture, easily created with only 3 texture layers!]]&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
'''For this tutorial you must:'''&lt;br /&gt;
* Have a terrain model UV-mapped in the 0-1 range (covered in the simple first terrain tutorial)&lt;br /&gt;
* Have access to some tiling textures.&lt;br /&gt;
* Have a little understanding the ETQW material system&lt;br /&gt;
&lt;br /&gt;
If you don't have any of the above things, you are not ready to do this tutorial!&lt;br /&gt;
&lt;br /&gt;
'''This tutorial covers:'''&lt;br /&gt;
* How to set up a MegaTexture material&lt;br /&gt;
* How to create a Surface Tree&lt;br /&gt;
* How to add texture nodes in the Terrain Editor&lt;br /&gt;
* How to render and compile a full MegaTexture&lt;br /&gt;
&lt;br /&gt;
'''This tutorial does not cover:'''&lt;br /&gt;
* How to use Blender/Maya/Lightwave/ZBrush/Mudbox/3DSMax/Photoshop&lt;br /&gt;
* How to create tiling textures or heightmaps&lt;br /&gt;
* Anything overly complicated&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Creating a MegaTexture material ==&lt;br /&gt;
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:&lt;br /&gt;
 material megatextures/mapname		{ useTemplate megatextures/default_ambient&amp;lt; &amp;quot;mapname&amp;quot; &amp;gt; }&lt;br /&gt;
&lt;br /&gt;
This material would automatically search for a MegaTexture called {{filename|mapname.mega}} in the {{filename|/megatextures/}} folder. This example material uses the ''&amp;quot;default_ambient&amp;quot;'' 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]].&lt;br /&gt;
&lt;br /&gt;
Obviously you would want to use the actual name of your map instead of &amp;quot;mapname&amp;quot;, for consistency's sake and ease of reference.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Assigning the material ===&lt;br /&gt;
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).&lt;br /&gt;
Tips on this process can be found in the [[A Simple First Terrain|simple first terrain tutorial]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Creating the Surface Tree ==&lt;br /&gt;
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 &amp;quot;Save and Unload&amp;quot; button in the Terrain Editor.&lt;br /&gt;
[[Image:simplemega_terrainmodel.png|thumb|300px|Root node set up to use the correct terrain mesh]]&lt;br /&gt;
&lt;br /&gt;
=== Add the terrain mesh ===&lt;br /&gt;
Here's how you bring the terrain mesh into the surface tree:&lt;br /&gt;
* {{accelbtn|RMB}} on the left-hand pane, and choose ''New -&amp;gt; Tree'' via the menu.&lt;br /&gt;
** If you already have a Root node, click the &amp;quot;Begin Editing&amp;quot; button instead.&lt;br /&gt;
* Click on the Root node, and set {{keyname|Model}} to the name of the terrain mesh, in this case {{keyvalue|models/terrain/simpleterrain.obj}}.&lt;br /&gt;
* Press {{accelkey|enter}} to confirm the selection, and the terrain should appear in the 3D view.&lt;br /&gt;
&lt;br /&gt;
Be aware that your terrain model will probably appear bright orange or red.&lt;br /&gt;
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!&lt;br /&gt;
&lt;br /&gt;
=== Important note about nodes ===&lt;br /&gt;
When you are editing properties of nodes (names, numbers, texture sources etc.) always remember to hit {{accelkey|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 {{accelkey|enter}}, your changes may not be applied.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Create the first texture node ==&lt;br /&gt;
[[Image:simplemega_firstnode_diffuse.png|thumb|300px|The first texture node's diffuse texture properties]]&lt;br /&gt;
Now that the model is in place, you can start laying down the texture layers (or &amp;quot;nodes&amp;quot;) that will make up your MegaTexture.&lt;br /&gt;
&lt;br /&gt;
First you need to create a new Image Source node in the Terrain Editor.&lt;br /&gt;
* {{accelbtn|RMB}} on your &amp;quot;Root&amp;quot; node and choose ''New -&amp;gt; Image Source'' (or press {{accelkey|shift}}{{accelkey|i}})&lt;br /&gt;
* This will make a new node called &amp;quot;New Image Renderer&amp;quot;.&lt;br /&gt;
* You can rename this new node using the &amp;quot;Name&amp;quot; property field in the '''Object''' section.&lt;br /&gt;
* Rename the node &amp;quot;Dirt&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
You will notice in the top right of the Terrain Editor, a section listing things like &amp;quot;Diffuse&amp;quot;, &amp;quot;Distribution&amp;quot;, &amp;quot;Distribution Pattern&amp;quot; etc. Selecting one of these will list all of the properties for that section of the current node.&lt;br /&gt;
The ones we need to worry about are as follows:&lt;br /&gt;
&lt;br /&gt;
=== Diffuse ===&lt;br /&gt;
This is the colour map of the current node, and it should point to a tiling TGA texture.&lt;br /&gt;
* Make sure the Diffuse section is highlighted in the top right of the Terrain Editor.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to a generic tiling dirt texture. Remember to hit {{accelkey|enter}} afterwards!&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/dirt_02_d.tga}}&lt;br /&gt;
* The {{keyname|Scale}} field at the very bottom of the property list allows you to choose how much to tile the texture.&lt;br /&gt;
** 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!&lt;br /&gt;
** 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.&lt;br /&gt;
That's all you need to do for the Diffuse settings in this node.&lt;br /&gt;
&lt;br /&gt;
=== Distribution ===&lt;br /&gt;
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''.&lt;br /&gt;
* Make sure the Distribution section is highlighted in the top right.&lt;br /&gt;
* Since this is our first node, we want to show over the whole terrain. This means the distribution map should be 100% white.&lt;br /&gt;
* You can either assign a pure white TGA texture, or change the {{keyname|Source Type}} to {{keyvalue|geometryBased}}.&lt;br /&gt;
** {{keyvalue|geometryBased}} will by default create a fully white map, so if you don't have a white TGA handy, this is faster.&lt;br /&gt;
&lt;br /&gt;
=== Distribution Pattern ===&lt;br /&gt;
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.&lt;br /&gt;
* 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!&lt;br /&gt;
&lt;br /&gt;
=== Local ===&lt;br /&gt;
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.&lt;br /&gt;
* Make sure the Local section is highlighted in the top right.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching normal map for your tiling dirt texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/dirt_02_local.tga}}&lt;br /&gt;
* The Local texture's tiling amount is automatically the same as the Diffuse texture.&lt;br /&gt;
&lt;br /&gt;
=== Surface Type ===&lt;br /&gt;
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.&lt;br /&gt;
* Find the ''Surface Type Properties'' section of the property list.&lt;br /&gt;
* 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.&lt;br /&gt;
* Hit {{accelkey|enter}} to accept the surface type.&lt;br /&gt;
&lt;br /&gt;
Your dirt textures will now produce correct &amp;quot;dirt&amp;quot; effects when shot or collided with!&lt;br /&gt;
&lt;br /&gt;
=== Previewing the result ===&lt;br /&gt;
[[Image:simplemega_firstnode_preview.jpg|thumb|300px|The Render mode preview of the first node]]&lt;br /&gt;
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]]&lt;br /&gt;
&lt;br /&gt;
* Notice the drop-down arrow on the right of the button. Click it, and select ''&amp;quot;Full&amp;quot;'' instead of ''&amp;quot;None&amp;quot;''.&lt;br /&gt;
* Your terrain should change colour to black. This means it's ready for a preview to be rendered onto it.&lt;br /&gt;
* Click the button itself now, instead of the drop-down. An &amp;quot;Active Tasks&amp;quot; window should pop up, and when it's done, you should see your dirt texture appear on your terrain model.&lt;br /&gt;
* You can switch the camera to Render mode too, which will show your terrain model's shading better.&lt;br /&gt;
* If you want a full-resolution preview of a small area, choose ''&amp;quot;Window&amp;quot;'' instead of ''&amp;quot;Full&amp;quot;'' from the drop-down menu.&lt;br /&gt;
** 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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
'''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.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
== Adding a second node ==&lt;br /&gt;
Now that the first layer of dirt is in place, we can try putting some grass on top of it!&lt;br /&gt;
* Again, {{accelbtn|RMB}} on your &amp;quot;Root&amp;quot; node and choose ''New -&amp;gt; Image Source'' (or press {{accelkey|shift}}{{accelkey|i}})&lt;br /&gt;
* This will make another new node below your &amp;quot;Dirt&amp;quot; node. &lt;br /&gt;
* Name this new node &amp;quot;Grass&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Again, the main map types need to be specified before the node can be rendered:&lt;br /&gt;
&lt;br /&gt;
=== Diffuse ===&lt;br /&gt;
* Make sure the Diffuse section is highlighted in the top right of the Terrain Editor.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to a generic tiling grass texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/grass_04_d.tga}}&lt;br /&gt;
* 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.&lt;br /&gt;
&lt;br /&gt;
=== Distribution ===&lt;br /&gt;
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!&lt;br /&gt;
* Make sure the Distribution section is highlighted in the top right.&lt;br /&gt;
* Change the {{keyname|Source Type}} from {{keyvalue|texture}} to {{keyvalue|geometryBased}}.&lt;br /&gt;
&lt;br /&gt;
=== Geometric Texture Distribution ===&lt;br /&gt;
[[Image:simplemega_geometric_distribution.png|thumb|300px|The geometric texture distribution settings of the second node]]&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
* ''Altitude Lower'' - Enabling this will limit the lower parts of the terrain from receiving this node's textures.&lt;br /&gt;
** {{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.&lt;br /&gt;
** {{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.&lt;br /&gt;
* ''Altitude Upper'' - Enabling this will limit the higher parts of the terrain from receiving this node's textures.&lt;br /&gt;
** {{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.&lt;br /&gt;
** {{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.&lt;br /&gt;
&lt;br /&gt;
* {{keyname|Clamp Distribution To Edge}} - Leave this on Default.&lt;br /&gt;
&lt;br /&gt;
* {{keyname|Resolution}} - The size in pixels of the resulting mask. The default value of {{keyvalue|256}} is fine for nearly any terrain model.&lt;br /&gt;
&lt;br /&gt;
* ''Slope Lower'' - Enabling this will limit shallower angles of the terrain model from receiving this node's textures.&lt;br /&gt;
** {{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.&lt;br /&gt;
** {{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.&lt;br /&gt;
* ''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.&lt;br /&gt;
** {{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.&lt;br /&gt;
** {{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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
=== Distribution Pattern ===&lt;br /&gt;
[[Image:simplemega_dist_ramps.jpg|thumb|300px|The difference between using or not using a Distribution Pattern, and varying Ramp Widths]]&lt;br /&gt;
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!&lt;br /&gt;
So what we want here is a texture to identify the &amp;quot;height&amp;quot; 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.&lt;br /&gt;
&lt;br /&gt;
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!&lt;br /&gt;
&lt;br /&gt;
* Make sure {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching heightmap or mask for your tiling grass texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/grass_04_mask.tga}}&lt;br /&gt;
* 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 &amp;quot;Window&amp;quot; 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.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
=== Local ===&lt;br /&gt;
Again we want the normal-map which matches the diffuse texture for the grass.&lt;br /&gt;
* Make sure the Local section is highlighted in the top right.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching normal map for your tiling grass texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/grass_04_local.tga}}&lt;br /&gt;
&lt;br /&gt;
=== Surface Type ===&lt;br /&gt;
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.&lt;br /&gt;
* Find the ''Surface Type Properties'' section of the property list.&lt;br /&gt;
* 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.&lt;br /&gt;
* Hit {{accelkey|enter}} to accept the surface type.&lt;br /&gt;
&lt;br /&gt;
Your grass textures should now produce correct &amp;quot;grass&amp;quot; effects when shot or collided with!&lt;br /&gt;
&lt;br /&gt;
=== Preview ===&lt;br /&gt;
[[Image:simplemega_secondnode_preview.jpg|thumb|300px|The Render mode preview of the second node blended with the first node]]&lt;br /&gt;
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.&lt;br /&gt;
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.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
== Adding a third node ==&lt;br /&gt;
[[Image:simplemega_thirdnode_preview.jpg|thumb|300px|The Render mode preview of the third node blended with the other two nodes]]&lt;br /&gt;
Now that the grass and dirt are in place, we need some rocks to make the terrain look more natural.&lt;br /&gt;
* Add a new Image Renderer node below your &amp;quot;Grass&amp;quot; node and name it &amp;quot;Rock&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Again, the main map types need to be specified before the node can be rendered:&lt;br /&gt;
&lt;br /&gt;
=== Diffuse ===&lt;br /&gt;
* Set the '''Diffuse''' texture and scale.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/rock_01_d.tga}} at a scale of {{keyvalue|32 32}}&lt;br /&gt;
&lt;br /&gt;
=== Distribution ===&lt;br /&gt;
Again we can use Geometric Texture Distribution to easily apply the rock textures only to the cliff-like angles.&lt;br /&gt;
* Make sure the Distribution section is highlighted in the top right.&lt;br /&gt;
* Change the {{keyname|Source Type}} to {{keyvalue|geometryBased}}.&lt;br /&gt;
* 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}}&lt;br /&gt;
&lt;br /&gt;
=== Distribution Pattern ===&lt;br /&gt;
Again this will control how the the rocks blend into the other nodes. Again, we want a texture to identify the &amp;quot;height&amp;quot; of the tiling rock texture.&lt;br /&gt;
&lt;br /&gt;
* Make sure the Distribution Pattern section is highlighted in the top right.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching heightmap or mask for your tiling rock texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/rock_01_h.tga}}&lt;br /&gt;
* 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 &amp;quot;Window&amp;quot; preview to see how the blending looks.&lt;br /&gt;
* Remember to set the {{keyname|Distribution Pattern Texture Scale}} to the same value as the Diffuse Scale, {{keyvalue|32 32}}.&lt;br /&gt;
&lt;br /&gt;
=== Local ===&lt;br /&gt;
Again we want the normal-map which matches the diffuse texture for the rocks.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Local''' section, browse to the matching normal map for your tiling rock texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/rock_01_local.tga}}&lt;br /&gt;
&lt;br /&gt;
=== Surface Type ===&lt;br /&gt;
* Find the ''Surface Type Properties'' section of the property list.&lt;br /&gt;
* In the {{keyname|Type}} field, enter {{keyvalue|stone}}.&lt;br /&gt;
* Hit {{accelkey|enter}} to accept the surface type.&lt;br /&gt;
&lt;br /&gt;
Your rock textures should now produce correct &amp;quot;stone&amp;quot; effects when shot or collided with.&lt;br /&gt;
&lt;br /&gt;
=== Preview ===&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Further tweaks ==&lt;br /&gt;
There are other simple changes that can be done in the Terrain Editor to make your MegaTexture look even better.&lt;br /&gt;
&lt;br /&gt;
=== Node order ===&lt;br /&gt;
[Image:simplemega_node_order.png|frame|Click and drag a node to change the order]]&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
* {{accelbtn|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.&lt;br /&gt;
* Release {{accelbtn|LMB}} when you have positioned the node in the correct place.&lt;br /&gt;
* 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!&lt;br /&gt;
&lt;br /&gt;
=== Color changes ===&lt;br /&gt;
Maybe your dirt texture is too bright? Or maybe your grass looks a little ''too'' green?&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Let's say you want to make the dirt texture darker and a bit more red. Here's how you'd do it:&lt;br /&gt;
* Select your Dirt node.&lt;br /&gt;
* 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).&lt;br /&gt;
* A color wheel and brightness slider will pop up in a new window. You can use this to darken and tint your texture.&lt;br /&gt;
* Choose a darker brightness, and a color slightly towards red. I used '''RGB Values''' of 225, 220, 220.&lt;br /&gt;
* Hit ''OK'' to accept the color.&lt;br /&gt;
* Re-render your MegaTexture preview. You should notice that the dirt layer looks darker now!&lt;br /&gt;
&lt;br /&gt;
=== Texture rotation ===&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Render the MegaTexture ==&lt;br /&gt;
=== Save the Surface Tree ===&lt;br /&gt;
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 &amp;quot;Save and Unload&amp;quot; button in the Terrain Editor, or save the whole map.&lt;br /&gt;
&lt;br /&gt;
=== Compile Only Entities ===&lt;br /&gt;
At this stage, your MegaTexture material is still technically &amp;quot;broken&amp;quot;, 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.&lt;br /&gt;
&lt;br /&gt;
However, we need to compile the map in order to tell the [[renderLight]] process which atmosphere to use when lighting the MegaTexture!&lt;br /&gt;
&lt;br /&gt;
So the solution is to do an '''Only Entities''' compile. You can find this in the menu ''Compile -&amp;gt; 2 - Only Entities'' in editWorld. This should be done in a few seconds, and compiles all the information that renderLight needs.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Run the SDK Launcher ===&lt;br /&gt;
Now that your ''.sft'' is saved, go through all the steps outlined in the [[Generate a MegaTexture]] tutorial.&lt;br /&gt;
&lt;br /&gt;
== That's it! ==&lt;br /&gt;
[[Image:simplemega_ingame.jpg|thumb|300px|The MegaTexture in-game!]]&lt;br /&gt;
You've now created your very own MegaTexture to use in your map!&lt;br /&gt;
&lt;br /&gt;
Before you even compile the map, you can get an accurate preview of how it will look in-game by pressing {{accelkey|F6}} to toggle &amp;quot;anim&amp;quot; mode while in editWorld's &amp;quot;RENDER&amp;quot; Camera view (toggled with {{accelkey|F3}}).&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
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:&lt;br /&gt;
* 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.&lt;br /&gt;
* 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 ''&amp;lt; &amp;quot;mapname&amp;quot; &amp;gt;'' part described in [[A Simple First Megatexture#Creating a MegaTexture material|this section]]), otherwise it will not be searching for the correct images.&lt;br /&gt;
* 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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
* [[An Advanced Terrain and Megatexture]] - an advanced guide for complete MegaTexture creation&lt;br /&gt;
* [[Generate a MegaTexture]] - steps for generating a MegaTexture from the SDK launcher.&lt;br /&gt;
* [http://community.enemyterritory.com/forums/showthread.php?t=19326 Forum Thread] - includes textures to download&lt;br /&gt;
&lt;br /&gt;
[[Category:Art]]&lt;br /&gt;
[[Category:Basic Level Design]]&lt;br /&gt;
[[Category:Tutorials]]&lt;/div&gt;</summary>
		<author><name>Ducks</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.splashdamage.com/index.php?title=A_Simple_First_Megatexture&amp;diff=4064</id>
		<title>A Simple First Megatexture</title>
		<link rel="alternate" type="text/html" href="https://wiki.splashdamage.com/index.php?title=A_Simple_First_Megatexture&amp;diff=4064"/>
		<updated>2007-12-17T15:15:34Z</updated>

		<summary type="html">&lt;p&gt;Ducks: /* Texture rotation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Image:simplemega_ingame.jpg|right|thumb|500px|A simple MegaTexture, easily created with only 3 texture layers!]]&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
'''For this tutorial you must:'''&lt;br /&gt;
* Have a terrain model UV-mapped in the 0-1 range (covered in the simple first terrain tutorial)&lt;br /&gt;
* Have access to some tiling textures.&lt;br /&gt;
* Have a little understanding the ETQW material system&lt;br /&gt;
&lt;br /&gt;
If you don't have any of the above things, you are not ready to do this tutorial!&lt;br /&gt;
&lt;br /&gt;
'''This tutorial covers:'''&lt;br /&gt;
* How to set up a MegaTexture material&lt;br /&gt;
* How to create a Surface Tree&lt;br /&gt;
* How to add texture nodes in the Terrain Editor&lt;br /&gt;
* How to render and compile a full MegaTexture&lt;br /&gt;
&lt;br /&gt;
'''This tutorial does not cover:'''&lt;br /&gt;
* How to use Blender/Maya/Lightwave/ZBrush/Mudbox/3DSMax/Photoshop&lt;br /&gt;
* How to create tiling textures or heightmaps&lt;br /&gt;
* Anything overly complicated&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Creating a MegaTexture material ==&lt;br /&gt;
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:&lt;br /&gt;
 material megatextures/mapname		{ useTemplate megatextures/default_ambient&amp;lt; &amp;quot;mapname&amp;quot; &amp;gt; }&lt;br /&gt;
&lt;br /&gt;
This material would automatically search for a MegaTexture called {{filename|mapname.mega}} in the {{filename|/megatextures/}} folder. This example material uses the ''&amp;quot;default_ambient&amp;quot;'' 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]].&lt;br /&gt;
&lt;br /&gt;
Obviously you would want to use the actual name of your map instead of &amp;quot;mapname&amp;quot;, for consistency's sake and ease of reference.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Assigning the material ===&lt;br /&gt;
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).&lt;br /&gt;
Tips on this process can be found in the [[A Simple First Terrain|simple first terrain tutorial]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Creating the Surface Tree ==&lt;br /&gt;
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 &amp;quot;Save and Unload&amp;quot; button in the Terrain Editor.&lt;br /&gt;
[[Image:simplemega_terrainmodel.png|thumb|300px|Root node set up to use the correct terrain mesh]]&lt;br /&gt;
&lt;br /&gt;
=== Add the terrain mesh ===&lt;br /&gt;
Here's how you bring the terrain mesh into the surface tree:&lt;br /&gt;
* {{accelbtn|RMB}} on the left-hand pane, and choose ''New -&amp;gt; Tree'' via the menu.&lt;br /&gt;
** If you already have a Root node, click the &amp;quot;Begin Editing&amp;quot; button instead.&lt;br /&gt;
* Click on the Root node, and set {{keyname|Model}} to the name of the terrain mesh, in this case {{keyvalue|models/terrain/simpleterrain.obj}}.&lt;br /&gt;
* Press {{accelkey|enter}} to confirm the selection, and the terrain should appear in the 3D view.&lt;br /&gt;
&lt;br /&gt;
Be aware that your terrain model will probably appear bright orange or red.&lt;br /&gt;
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!&lt;br /&gt;
&lt;br /&gt;
=== Important note about nodes ===&lt;br /&gt;
When you are editing properties of nodes (names, numbers, texture sources etc.) always remember to hit {{accelkey|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 {{accelkey|enter}}, your changes may not be applied.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Create the first texture node ==&lt;br /&gt;
[[Image:simplemega_firstnode_diffuse.png|thumb|300px|The first texture node's diffuse texture properties]]&lt;br /&gt;
Now that the model is in place, you can start laying down the texture layers (or &amp;quot;nodes&amp;quot;) that will make up your MegaTexture.&lt;br /&gt;
&lt;br /&gt;
First you need to create a new Image Source node in the Terrain Editor.&lt;br /&gt;
* {{accelbtn|RMB}} on your &amp;quot;Root&amp;quot; node and choose ''New -&amp;gt; Image Source'' (or press {{accelkey|shift}}{{accelkey|i}})&lt;br /&gt;
* This will make a new node called &amp;quot;New Image Renderer&amp;quot;.&lt;br /&gt;
* You can rename this new node using the &amp;quot;Name&amp;quot; property field in the '''Object''' section.&lt;br /&gt;
* Rename the node &amp;quot;Dirt&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
You will notice in the top right of the Terrain Editor, a section listing things like &amp;quot;Diffuse&amp;quot;, &amp;quot;Distribution&amp;quot;, &amp;quot;Distribution Pattern&amp;quot; etc. Selecting one of these will list all of the properties for that section of the current node.&lt;br /&gt;
The ones we need to worry about are as follows:&lt;br /&gt;
&lt;br /&gt;
=== Diffuse ===&lt;br /&gt;
This is the colour map of the current node, and it should point to a tiling TGA texture.&lt;br /&gt;
* Make sure the Diffuse section is highlighted in the top right of the Terrain Editor.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to a generic tiling dirt texture. Remember to hit {{accelkey|enter}} afterwards!&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/dirt_02_d.tga}}&lt;br /&gt;
* The {{keyname|Scale}} field at the very bottom of the property list allows you to choose how much to tile the texture.&lt;br /&gt;
** 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!&lt;br /&gt;
** 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.&lt;br /&gt;
That's all you need to do for the Diffuse settings in this node.&lt;br /&gt;
&lt;br /&gt;
=== Distribution ===&lt;br /&gt;
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''.&lt;br /&gt;
* Make sure the Distribution section is highlighted in the top right.&lt;br /&gt;
* Since this is our first node, we want to show over the whole terrain. This means the distribution map should be 100% white.&lt;br /&gt;
* You can either assign a pure white TGA texture, or change the {{keyname|Source Type}} to {{keyvalue|geometryBased}}.&lt;br /&gt;
** {{keyvalue|geometryBased}} will by default create a fully white map, so if you don't have a white TGA handy, this is faster.&lt;br /&gt;
&lt;br /&gt;
=== Distribution Pattern ===&lt;br /&gt;
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.&lt;br /&gt;
* 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!&lt;br /&gt;
&lt;br /&gt;
=== Local ===&lt;br /&gt;
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.&lt;br /&gt;
* Make sure the Local section is highlighted in the top right.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching normal map for your tiling dirt texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/dirt_02_local.tga}}&lt;br /&gt;
* The Local texture's tiling amount is automatically the same as the Diffuse texture.&lt;br /&gt;
&lt;br /&gt;
=== Surface Type ===&lt;br /&gt;
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.&lt;br /&gt;
* Find the ''Surface Type Properties'' section of the property list.&lt;br /&gt;
* 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.&lt;br /&gt;
* Hit {{accelkey|enter}} to accept the surface type.&lt;br /&gt;
&lt;br /&gt;
Your dirt textures will now produce correct &amp;quot;dirt&amp;quot; effects when shot or collided with!&lt;br /&gt;
&lt;br /&gt;
=== Previewing the result ===&lt;br /&gt;
[[Image:simplemega_firstnode_preview.jpg|thumb|300px|The Render mode preview of the first node]]&lt;br /&gt;
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]]&lt;br /&gt;
&lt;br /&gt;
* Notice the drop-down arrow on the right of the button. Click it, and select ''&amp;quot;Full&amp;quot;'' instead of ''&amp;quot;None&amp;quot;''.&lt;br /&gt;
* Your terrain should change colour to black. This means it's ready for a preview to be rendered onto it.&lt;br /&gt;
* Click the button itself now, instead of the drop-down. An &amp;quot;Active Tasks&amp;quot; window should pop up, and when it's done, you should see your dirt texture appear on your terrain model.&lt;br /&gt;
* You can switch the camera to Render mode too, which will show your terrain model's shading better.&lt;br /&gt;
* If you want a full-resolution preview of a small area, choose ''&amp;quot;Window&amp;quot;'' instead of ''&amp;quot;Full&amp;quot;'' from the drop-down menu.&lt;br /&gt;
** 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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
'''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.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
== Adding a second node ==&lt;br /&gt;
Now that the first layer of dirt is in place, we can try putting some grass on top of it!&lt;br /&gt;
* Again, {{accelbtn|RMB}} on your &amp;quot;Root&amp;quot; node and choose ''New -&amp;gt; Image Source'' (or press {{accelkey|shift}}{{accelkey|i}})&lt;br /&gt;
* This will make another new node below your &amp;quot;Dirt&amp;quot; node. &lt;br /&gt;
* Name this new node &amp;quot;Grass&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Again, the main map types need to be specified before the node can be rendered:&lt;br /&gt;
&lt;br /&gt;
=== Diffuse ===&lt;br /&gt;
* Make sure the Diffuse section is highlighted in the top right of the Terrain Editor.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to a generic tiling grass texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/grass_04_d.tga}}&lt;br /&gt;
* 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.&lt;br /&gt;
&lt;br /&gt;
=== Distribution ===&lt;br /&gt;
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!&lt;br /&gt;
* Make sure the Distribution section is highlighted in the top right.&lt;br /&gt;
* Change the {{keyname|Source Type}} from {{keyvalue|texture}} to {{keyvalue|geometryBased}}.&lt;br /&gt;
&lt;br /&gt;
=== Geometric Texture Distribution ===&lt;br /&gt;
[[Image:simplemega_geometric_distribution.png|thumb|300px|The geometric texture distribution settings of the second node]]&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
* ''Altitude Lower'' - Enabling this will limit the lower parts of the terrain from receiving this node's textures.&lt;br /&gt;
** {{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.&lt;br /&gt;
** {{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.&lt;br /&gt;
* ''Altitude Upper'' - Enabling this will limit the higher parts of the terrain from receiving this node's textures.&lt;br /&gt;
** {{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.&lt;br /&gt;
** {{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.&lt;br /&gt;
&lt;br /&gt;
* {{keyname|Clamp Distribution To Edge}} - Leave this on Default.&lt;br /&gt;
&lt;br /&gt;
* {{keyname|Resolution}} - The size in pixels of the resulting mask. The default value of {{keyvalue|256}} is fine for nearly any terrain model.&lt;br /&gt;
&lt;br /&gt;
* ''Slope Lower'' - Enabling this will limit shallower angles of the terrain model from receiving this node's textures.&lt;br /&gt;
** {{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.&lt;br /&gt;
** {{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.&lt;br /&gt;
* ''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.&lt;br /&gt;
** {{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.&lt;br /&gt;
** {{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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
=== Distribution Pattern ===&lt;br /&gt;
[[Image:simplemega_dist_ramps.jpg|thumb|300px|The difference between using or not using a Distribution Pattern, and varying Ramp Widths]]&lt;br /&gt;
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!&lt;br /&gt;
So what we want here is a texture to identify the &amp;quot;height&amp;quot; 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.&lt;br /&gt;
&lt;br /&gt;
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!&lt;br /&gt;
&lt;br /&gt;
* Make sure {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching heightmap or mask for your tiling grass texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/grass_04_mask.tga}}&lt;br /&gt;
* 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 &amp;quot;Window&amp;quot; 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.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
=== Local ===&lt;br /&gt;
Again we want the normal-map which matches the diffuse texture for the grass.&lt;br /&gt;
* Make sure the Local section is highlighted in the top right.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching normal map for your tiling grass texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/grass_04_local.tga}}&lt;br /&gt;
&lt;br /&gt;
=== Surface Type ===&lt;br /&gt;
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.&lt;br /&gt;
* Find the ''Surface Type Properties'' section of the property list.&lt;br /&gt;
* 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.&lt;br /&gt;
* Hit {{accelkey|enter}} to accept the surface type.&lt;br /&gt;
&lt;br /&gt;
Your grass textures should now produce correct &amp;quot;grass&amp;quot; effects when shot or collided with!&lt;br /&gt;
&lt;br /&gt;
=== Preview ===&lt;br /&gt;
[[Image:simplemega_secondnode_preview.jpg|thumb|300px|The Render mode preview of the second node blended with the first node]]&lt;br /&gt;
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.&lt;br /&gt;
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.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
== Adding a third node ==&lt;br /&gt;
[[Image:simplemega_thirdnode_preview.jpg|thumb|300px|The Render mode preview of the third node blended with the other two nodes]]&lt;br /&gt;
Now that the grass and dirt are in place, we need some rocks to make the terrain look more natural.&lt;br /&gt;
* Add a new Image Renderer node below your &amp;quot;Grass&amp;quot; node and name it &amp;quot;Rock&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Again, the main map types need to be specified before the node can be rendered:&lt;br /&gt;
&lt;br /&gt;
=== Diffuse ===&lt;br /&gt;
* Set the '''Diffuse''' texture and scale.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/rock_01_d.tga}} at a scale of {{keyvalue|32 32}}&lt;br /&gt;
&lt;br /&gt;
=== Distribution ===&lt;br /&gt;
Again we can use Geometric Texture Distribution to easily apply the rock textures only to the cliff-like angles.&lt;br /&gt;
* Make sure the Distribution section is highlighted in the top right.&lt;br /&gt;
* Change the {{keyname|Source Type}} to {{keyvalue|geometryBased}}.&lt;br /&gt;
* 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}}&lt;br /&gt;
&lt;br /&gt;
=== Distribution Pattern ===&lt;br /&gt;
Again this will control how the the rocks blend into the other nodes. Again, we want a texture to identify the &amp;quot;height&amp;quot; of the tiling rock texture.&lt;br /&gt;
&lt;br /&gt;
* Make sure the Distribution Pattern section is highlighted in the top right.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching heightmap or mask for your tiling rock texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/rock_01_h.tga}}&lt;br /&gt;
* 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 &amp;quot;Window&amp;quot; preview to see how the blending looks.&lt;br /&gt;
* Remember to set the {{keyname|Distribution Pattern Texture Scale}} to the same value as the Diffuse Scale, {{keyvalue|32 32}}.&lt;br /&gt;
&lt;br /&gt;
=== Local ===&lt;br /&gt;
Again we want the normal-map which matches the diffuse texture for the rocks.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Local''' section, browse to the matching normal map for your tiling rock texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/rock_01_local.tga}}&lt;br /&gt;
&lt;br /&gt;
=== Surface Type ===&lt;br /&gt;
* Find the ''Surface Type Properties'' section of the property list.&lt;br /&gt;
* In the {{keyname|Type}} field, enter {{keyvalue|stone}}.&lt;br /&gt;
* Hit {{accelkey|enter}} to accept the surface type.&lt;br /&gt;
&lt;br /&gt;
Your rock textures should now produce correct &amp;quot;stone&amp;quot; effects when shot or collided with.&lt;br /&gt;
&lt;br /&gt;
=== Preview ===&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Further tweaks ==&lt;br /&gt;
There are other simple changes that can be done in the Terrain Editor to make your MegaTexture look even better.&lt;br /&gt;
&lt;br /&gt;
=== Node order ===&lt;br /&gt;
[Image:simplemega_node_order.png|frame|Click and drag a node to change the order]]&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
* {{accelbtn|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.&lt;br /&gt;
* Release {{accelbtn|LMB}} when you have positioned the node in the correct place.&lt;br /&gt;
* 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!&lt;br /&gt;
&lt;br /&gt;
=== Color changes ===&lt;br /&gt;
Maybe your dirt texture is too bright? Or maybe your grass looks a little ''too'' green?&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Let's say you want to make the dirt texture darker and a bit more red. Here's how you'd do it:&lt;br /&gt;
* Select your Dirt node.&lt;br /&gt;
* 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).&lt;br /&gt;
* A color wheel and brightness slider will pop up in a new window. You can use this to darken and tint your texture.&lt;br /&gt;
* Choose a darker brightness, and a color slightly towards red. I used '''RGB Values''' of 225, 220, 220.&lt;br /&gt;
* Hit ''OK'' to accept the color.&lt;br /&gt;
* Re-render your MegaTexture preview. You should notice that the dirt layer looks darker now!&lt;br /&gt;
&lt;br /&gt;
=== Texture rotation ===&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
For each node, you should also set the {{keyname|Distribution Pattern Texture Rotation}} to match the Rotation value if you want your distribution patterns to line up and work correctly.&lt;br /&gt;
&lt;br /&gt;
== Render the MegaTexture ==&lt;br /&gt;
=== Save the Surface Tree ===&lt;br /&gt;
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 &amp;quot;Save and Unload&amp;quot; button in the Terrain Editor, or save the whole map.&lt;br /&gt;
&lt;br /&gt;
=== Compile Only Entities ===&lt;br /&gt;
At this stage, your MegaTexture material is still technically &amp;quot;broken&amp;quot;, 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.&lt;br /&gt;
&lt;br /&gt;
However, we need to compile the map in order to tell the [[renderLight]] process which atmosphere to use when lighting the MegaTexture!&lt;br /&gt;
&lt;br /&gt;
So the solution is to do an '''Only Entities''' compile. You can find this in the menu ''Compile -&amp;gt; 2 - Only Entities'' in editWorld. This should be done in a few seconds, and compiles all the information that renderLight needs.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Run the SDK Launcher ===&lt;br /&gt;
Now that your ''.sft'' is saved, go through all the steps outlined in the [[Generate a MegaTexture]] tutorial.&lt;br /&gt;
&lt;br /&gt;
== That's it! ==&lt;br /&gt;
[[Image:simplemega_ingame.jpg|thumb|300px|The MegaTexture in-game!]]&lt;br /&gt;
You've now created your very own MegaTexture to use in your map!&lt;br /&gt;
&lt;br /&gt;
Before you even compile the map, you can get an accurate preview of how it will look in-game by pressing {{accelkey|F6}} to toggle &amp;quot;anim&amp;quot; mode while in editWorld's &amp;quot;RENDER&amp;quot; Camera view (toggled with {{accelkey|F3}}).&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
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:&lt;br /&gt;
* 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.&lt;br /&gt;
* 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 ''&amp;lt; &amp;quot;mapname&amp;quot; &amp;gt;'' part described in [[A Simple First Megatexture#Creating a MegaTexture material|this section]]), otherwise it will not be searching for the correct images.&lt;br /&gt;
* 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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
* [[An Advanced Terrain and Megatexture]] - an advanced guide for complete MegaTexture creation&lt;br /&gt;
* [[Generate a MegaTexture]] - steps for generating a MegaTexture from the SDK launcher.&lt;br /&gt;
* [http://community.enemyterritory.com/forums/showthread.php?t=19326 Forum Thread] - includes textures to download&lt;br /&gt;
&lt;br /&gt;
[[Category:Art]]&lt;br /&gt;
[[Category:Basic Level Design]]&lt;br /&gt;
[[Category:Tutorials]]&lt;/div&gt;</summary>
		<author><name>Ducks</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.splashdamage.com/index.php?title=A_Simple_First_Megatexture&amp;diff=4063</id>
		<title>A Simple First Megatexture</title>
		<link rel="alternate" type="text/html" href="https://wiki.splashdamage.com/index.php?title=A_Simple_First_Megatexture&amp;diff=4063"/>
		<updated>2007-12-17T15:14:57Z</updated>

		<summary type="html">&lt;p&gt;Ducks: /* Distribution Pattern */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Image:simplemega_ingame.jpg|right|thumb|500px|A simple MegaTexture, easily created with only 3 texture layers!]]&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
'''For this tutorial you must:'''&lt;br /&gt;
* Have a terrain model UV-mapped in the 0-1 range (covered in the simple first terrain tutorial)&lt;br /&gt;
* Have access to some tiling textures.&lt;br /&gt;
* Have a little understanding the ETQW material system&lt;br /&gt;
&lt;br /&gt;
If you don't have any of the above things, you are not ready to do this tutorial!&lt;br /&gt;
&lt;br /&gt;
'''This tutorial covers:'''&lt;br /&gt;
* How to set up a MegaTexture material&lt;br /&gt;
* How to create a Surface Tree&lt;br /&gt;
* How to add texture nodes in the Terrain Editor&lt;br /&gt;
* How to render and compile a full MegaTexture&lt;br /&gt;
&lt;br /&gt;
'''This tutorial does not cover:'''&lt;br /&gt;
* How to use Blender/Maya/Lightwave/ZBrush/Mudbox/3DSMax/Photoshop&lt;br /&gt;
* How to create tiling textures or heightmaps&lt;br /&gt;
* Anything overly complicated&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Creating a MegaTexture material ==&lt;br /&gt;
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:&lt;br /&gt;
 material megatextures/mapname		{ useTemplate megatextures/default_ambient&amp;lt; &amp;quot;mapname&amp;quot; &amp;gt; }&lt;br /&gt;
&lt;br /&gt;
This material would automatically search for a MegaTexture called {{filename|mapname.mega}} in the {{filename|/megatextures/}} folder. This example material uses the ''&amp;quot;default_ambient&amp;quot;'' 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]].&lt;br /&gt;
&lt;br /&gt;
Obviously you would want to use the actual name of your map instead of &amp;quot;mapname&amp;quot;, for consistency's sake and ease of reference.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Assigning the material ===&lt;br /&gt;
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).&lt;br /&gt;
Tips on this process can be found in the [[A Simple First Terrain|simple first terrain tutorial]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Creating the Surface Tree ==&lt;br /&gt;
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 &amp;quot;Save and Unload&amp;quot; button in the Terrain Editor.&lt;br /&gt;
[[Image:simplemega_terrainmodel.png|thumb|300px|Root node set up to use the correct terrain mesh]]&lt;br /&gt;
&lt;br /&gt;
=== Add the terrain mesh ===&lt;br /&gt;
Here's how you bring the terrain mesh into the surface tree:&lt;br /&gt;
* {{accelbtn|RMB}} on the left-hand pane, and choose ''New -&amp;gt; Tree'' via the menu.&lt;br /&gt;
** If you already have a Root node, click the &amp;quot;Begin Editing&amp;quot; button instead.&lt;br /&gt;
* Click on the Root node, and set {{keyname|Model}} to the name of the terrain mesh, in this case {{keyvalue|models/terrain/simpleterrain.obj}}.&lt;br /&gt;
* Press {{accelkey|enter}} to confirm the selection, and the terrain should appear in the 3D view.&lt;br /&gt;
&lt;br /&gt;
Be aware that your terrain model will probably appear bright orange or red.&lt;br /&gt;
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!&lt;br /&gt;
&lt;br /&gt;
=== Important note about nodes ===&lt;br /&gt;
When you are editing properties of nodes (names, numbers, texture sources etc.) always remember to hit {{accelkey|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 {{accelkey|enter}}, your changes may not be applied.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Create the first texture node ==&lt;br /&gt;
[[Image:simplemega_firstnode_diffuse.png|thumb|300px|The first texture node's diffuse texture properties]]&lt;br /&gt;
Now that the model is in place, you can start laying down the texture layers (or &amp;quot;nodes&amp;quot;) that will make up your MegaTexture.&lt;br /&gt;
&lt;br /&gt;
First you need to create a new Image Source node in the Terrain Editor.&lt;br /&gt;
* {{accelbtn|RMB}} on your &amp;quot;Root&amp;quot; node and choose ''New -&amp;gt; Image Source'' (or press {{accelkey|shift}}{{accelkey|i}})&lt;br /&gt;
* This will make a new node called &amp;quot;New Image Renderer&amp;quot;.&lt;br /&gt;
* You can rename this new node using the &amp;quot;Name&amp;quot; property field in the '''Object''' section.&lt;br /&gt;
* Rename the node &amp;quot;Dirt&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
You will notice in the top right of the Terrain Editor, a section listing things like &amp;quot;Diffuse&amp;quot;, &amp;quot;Distribution&amp;quot;, &amp;quot;Distribution Pattern&amp;quot; etc. Selecting one of these will list all of the properties for that section of the current node.&lt;br /&gt;
The ones we need to worry about are as follows:&lt;br /&gt;
&lt;br /&gt;
=== Diffuse ===&lt;br /&gt;
This is the colour map of the current node, and it should point to a tiling TGA texture.&lt;br /&gt;
* Make sure the Diffuse section is highlighted in the top right of the Terrain Editor.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to a generic tiling dirt texture. Remember to hit {{accelkey|enter}} afterwards!&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/dirt_02_d.tga}}&lt;br /&gt;
* The {{keyname|Scale}} field at the very bottom of the property list allows you to choose how much to tile the texture.&lt;br /&gt;
** 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!&lt;br /&gt;
** 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.&lt;br /&gt;
That's all you need to do for the Diffuse settings in this node.&lt;br /&gt;
&lt;br /&gt;
=== Distribution ===&lt;br /&gt;
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''.&lt;br /&gt;
* Make sure the Distribution section is highlighted in the top right.&lt;br /&gt;
* Since this is our first node, we want to show over the whole terrain. This means the distribution map should be 100% white.&lt;br /&gt;
* You can either assign a pure white TGA texture, or change the {{keyname|Source Type}} to {{keyvalue|geometryBased}}.&lt;br /&gt;
** {{keyvalue|geometryBased}} will by default create a fully white map, so if you don't have a white TGA handy, this is faster.&lt;br /&gt;
&lt;br /&gt;
=== Distribution Pattern ===&lt;br /&gt;
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.&lt;br /&gt;
* 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!&lt;br /&gt;
&lt;br /&gt;
=== Local ===&lt;br /&gt;
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.&lt;br /&gt;
* Make sure the Local section is highlighted in the top right.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching normal map for your tiling dirt texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/dirt_02_local.tga}}&lt;br /&gt;
* The Local texture's tiling amount is automatically the same as the Diffuse texture.&lt;br /&gt;
&lt;br /&gt;
=== Surface Type ===&lt;br /&gt;
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.&lt;br /&gt;
* Find the ''Surface Type Properties'' section of the property list.&lt;br /&gt;
* 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.&lt;br /&gt;
* Hit {{accelkey|enter}} to accept the surface type.&lt;br /&gt;
&lt;br /&gt;
Your dirt textures will now produce correct &amp;quot;dirt&amp;quot; effects when shot or collided with!&lt;br /&gt;
&lt;br /&gt;
=== Previewing the result ===&lt;br /&gt;
[[Image:simplemega_firstnode_preview.jpg|thumb|300px|The Render mode preview of the first node]]&lt;br /&gt;
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]]&lt;br /&gt;
&lt;br /&gt;
* Notice the drop-down arrow on the right of the button. Click it, and select ''&amp;quot;Full&amp;quot;'' instead of ''&amp;quot;None&amp;quot;''.&lt;br /&gt;
* Your terrain should change colour to black. This means it's ready for a preview to be rendered onto it.&lt;br /&gt;
* Click the button itself now, instead of the drop-down. An &amp;quot;Active Tasks&amp;quot; window should pop up, and when it's done, you should see your dirt texture appear on your terrain model.&lt;br /&gt;
* You can switch the camera to Render mode too, which will show your terrain model's shading better.&lt;br /&gt;
* If you want a full-resolution preview of a small area, choose ''&amp;quot;Window&amp;quot;'' instead of ''&amp;quot;Full&amp;quot;'' from the drop-down menu.&lt;br /&gt;
** 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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
'''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.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
== Adding a second node ==&lt;br /&gt;
Now that the first layer of dirt is in place, we can try putting some grass on top of it!&lt;br /&gt;
* Again, {{accelbtn|RMB}} on your &amp;quot;Root&amp;quot; node and choose ''New -&amp;gt; Image Source'' (or press {{accelkey|shift}}{{accelkey|i}})&lt;br /&gt;
* This will make another new node below your &amp;quot;Dirt&amp;quot; node. &lt;br /&gt;
* Name this new node &amp;quot;Grass&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Again, the main map types need to be specified before the node can be rendered:&lt;br /&gt;
&lt;br /&gt;
=== Diffuse ===&lt;br /&gt;
* Make sure the Diffuse section is highlighted in the top right of the Terrain Editor.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to a generic tiling grass texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/grass_04_d.tga}}&lt;br /&gt;
* 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.&lt;br /&gt;
&lt;br /&gt;
=== Distribution ===&lt;br /&gt;
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!&lt;br /&gt;
* Make sure the Distribution section is highlighted in the top right.&lt;br /&gt;
* Change the {{keyname|Source Type}} from {{keyvalue|texture}} to {{keyvalue|geometryBased}}.&lt;br /&gt;
&lt;br /&gt;
=== Geometric Texture Distribution ===&lt;br /&gt;
[[Image:simplemega_geometric_distribution.png|thumb|300px|The geometric texture distribution settings of the second node]]&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
* ''Altitude Lower'' - Enabling this will limit the lower parts of the terrain from receiving this node's textures.&lt;br /&gt;
** {{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.&lt;br /&gt;
** {{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.&lt;br /&gt;
* ''Altitude Upper'' - Enabling this will limit the higher parts of the terrain from receiving this node's textures.&lt;br /&gt;
** {{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.&lt;br /&gt;
** {{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.&lt;br /&gt;
&lt;br /&gt;
* {{keyname|Clamp Distribution To Edge}} - Leave this on Default.&lt;br /&gt;
&lt;br /&gt;
* {{keyname|Resolution}} - The size in pixels of the resulting mask. The default value of {{keyvalue|256}} is fine for nearly any terrain model.&lt;br /&gt;
&lt;br /&gt;
* ''Slope Lower'' - Enabling this will limit shallower angles of the terrain model from receiving this node's textures.&lt;br /&gt;
** {{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.&lt;br /&gt;
** {{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.&lt;br /&gt;
* ''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.&lt;br /&gt;
** {{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.&lt;br /&gt;
** {{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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
=== Distribution Pattern ===&lt;br /&gt;
[[Image:simplemega_dist_ramps.jpg|thumb|300px|The difference between using or not using a Distribution Pattern, and varying Ramp Widths]]&lt;br /&gt;
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!&lt;br /&gt;
So what we want here is a texture to identify the &amp;quot;height&amp;quot; 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.&lt;br /&gt;
&lt;br /&gt;
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!&lt;br /&gt;
&lt;br /&gt;
* Make sure {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching heightmap or mask for your tiling grass texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/grass_04_mask.tga}}&lt;br /&gt;
* 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 &amp;quot;Window&amp;quot; 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.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
=== Local ===&lt;br /&gt;
Again we want the normal-map which matches the diffuse texture for the grass.&lt;br /&gt;
* Make sure the Local section is highlighted in the top right.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching normal map for your tiling grass texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/grass_04_local.tga}}&lt;br /&gt;
&lt;br /&gt;
=== Surface Type ===&lt;br /&gt;
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.&lt;br /&gt;
* Find the ''Surface Type Properties'' section of the property list.&lt;br /&gt;
* 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.&lt;br /&gt;
* Hit {{accelkey|enter}} to accept the surface type.&lt;br /&gt;
&lt;br /&gt;
Your grass textures should now produce correct &amp;quot;grass&amp;quot; effects when shot or collided with!&lt;br /&gt;
&lt;br /&gt;
=== Preview ===&lt;br /&gt;
[[Image:simplemega_secondnode_preview.jpg|thumb|300px|The Render mode preview of the second node blended with the first node]]&lt;br /&gt;
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.&lt;br /&gt;
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.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
== Adding a third node ==&lt;br /&gt;
[[Image:simplemega_thirdnode_preview.jpg|thumb|300px|The Render mode preview of the third node blended with the other two nodes]]&lt;br /&gt;
Now that the grass and dirt are in place, we need some rocks to make the terrain look more natural.&lt;br /&gt;
* Add a new Image Renderer node below your &amp;quot;Grass&amp;quot; node and name it &amp;quot;Rock&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Again, the main map types need to be specified before the node can be rendered:&lt;br /&gt;
&lt;br /&gt;
=== Diffuse ===&lt;br /&gt;
* Set the '''Diffuse''' texture and scale.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/rock_01_d.tga}} at a scale of {{keyvalue|32 32}}&lt;br /&gt;
&lt;br /&gt;
=== Distribution ===&lt;br /&gt;
Again we can use Geometric Texture Distribution to easily apply the rock textures only to the cliff-like angles.&lt;br /&gt;
* Make sure the Distribution section is highlighted in the top right.&lt;br /&gt;
* Change the {{keyname|Source Type}} to {{keyvalue|geometryBased}}.&lt;br /&gt;
* 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}}&lt;br /&gt;
&lt;br /&gt;
=== Distribution Pattern ===&lt;br /&gt;
Again this will control how the the rocks blend into the other nodes. Again, we want a texture to identify the &amp;quot;height&amp;quot; of the tiling rock texture.&lt;br /&gt;
&lt;br /&gt;
* Make sure the Distribution Pattern section is highlighted in the top right.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching heightmap or mask for your tiling rock texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/rock_01_h.tga}}&lt;br /&gt;
* 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 &amp;quot;Window&amp;quot; preview to see how the blending looks.&lt;br /&gt;
* Remember to set the {{keyname|Distribution Pattern Texture Scale}} to the same value as the Diffuse Scale, {{keyvalue|32 32}}.&lt;br /&gt;
&lt;br /&gt;
=== Local ===&lt;br /&gt;
Again we want the normal-map which matches the diffuse texture for the rocks.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Local''' section, browse to the matching normal map for your tiling rock texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/rock_01_local.tga}}&lt;br /&gt;
&lt;br /&gt;
=== Surface Type ===&lt;br /&gt;
* Find the ''Surface Type Properties'' section of the property list.&lt;br /&gt;
* In the {{keyname|Type}} field, enter {{keyvalue|stone}}.&lt;br /&gt;
* Hit {{accelkey|enter}} to accept the surface type.&lt;br /&gt;
&lt;br /&gt;
Your rock textures should now produce correct &amp;quot;stone&amp;quot; effects when shot or collided with.&lt;br /&gt;
&lt;br /&gt;
=== Preview ===&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Further tweaks ==&lt;br /&gt;
There are other simple changes that can be done in the Terrain Editor to make your MegaTexture look even better.&lt;br /&gt;
&lt;br /&gt;
=== Node order ===&lt;br /&gt;
[Image:simplemega_node_order.png|frame|Click and drag a node to change the order]]&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
* {{accelbtn|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.&lt;br /&gt;
* Release {{accelbtn|LMB}} when you have positioned the node in the correct place.&lt;br /&gt;
* 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!&lt;br /&gt;
&lt;br /&gt;
=== Color changes ===&lt;br /&gt;
Maybe your dirt texture is too bright? Or maybe your grass looks a little ''too'' green?&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Let's say you want to make the dirt texture darker and a bit more red. Here's how you'd do it:&lt;br /&gt;
* Select your Dirt node.&lt;br /&gt;
* 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).&lt;br /&gt;
* A color wheel and brightness slider will pop up in a new window. You can use this to darken and tint your texture.&lt;br /&gt;
* Choose a darker brightness, and a color slightly towards red. I used '''RGB Values''' of 225, 220, 220.&lt;br /&gt;
* Hit ''OK'' to accept the color.&lt;br /&gt;
* Re-render your MegaTexture preview. You should notice that the dirt layer looks darker now!&lt;br /&gt;
&lt;br /&gt;
=== Texture rotation ===&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
For each node, you should also set the {{keyvname|Distribution Pattern Texture Rotation}} to match the Rotation value if you want your distribution patterns to line up and work correctly.&lt;br /&gt;
&lt;br /&gt;
== Render the MegaTexture ==&lt;br /&gt;
=== Save the Surface Tree ===&lt;br /&gt;
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 &amp;quot;Save and Unload&amp;quot; button in the Terrain Editor, or save the whole map.&lt;br /&gt;
&lt;br /&gt;
=== Compile Only Entities ===&lt;br /&gt;
At this stage, your MegaTexture material is still technically &amp;quot;broken&amp;quot;, 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.&lt;br /&gt;
&lt;br /&gt;
However, we need to compile the map in order to tell the [[renderLight]] process which atmosphere to use when lighting the MegaTexture!&lt;br /&gt;
&lt;br /&gt;
So the solution is to do an '''Only Entities''' compile. You can find this in the menu ''Compile -&amp;gt; 2 - Only Entities'' in editWorld. This should be done in a few seconds, and compiles all the information that renderLight needs.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Run the SDK Launcher ===&lt;br /&gt;
Now that your ''.sft'' is saved, go through all the steps outlined in the [[Generate a MegaTexture]] tutorial.&lt;br /&gt;
&lt;br /&gt;
== That's it! ==&lt;br /&gt;
[[Image:simplemega_ingame.jpg|thumb|300px|The MegaTexture in-game!]]&lt;br /&gt;
You've now created your very own MegaTexture to use in your map!&lt;br /&gt;
&lt;br /&gt;
Before you even compile the map, you can get an accurate preview of how it will look in-game by pressing {{accelkey|F6}} to toggle &amp;quot;anim&amp;quot; mode while in editWorld's &amp;quot;RENDER&amp;quot; Camera view (toggled with {{accelkey|F3}}).&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
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:&lt;br /&gt;
* 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.&lt;br /&gt;
* 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 ''&amp;lt; &amp;quot;mapname&amp;quot; &amp;gt;'' part described in [[A Simple First Megatexture#Creating a MegaTexture material|this section]]), otherwise it will not be searching for the correct images.&lt;br /&gt;
* 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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
* [[An Advanced Terrain and Megatexture]] - an advanced guide for complete MegaTexture creation&lt;br /&gt;
* [[Generate a MegaTexture]] - steps for generating a MegaTexture from the SDK launcher.&lt;br /&gt;
* [http://community.enemyterritory.com/forums/showthread.php?t=19326 Forum Thread] - includes textures to download&lt;br /&gt;
&lt;br /&gt;
[[Category:Art]]&lt;br /&gt;
[[Category:Basic Level Design]]&lt;br /&gt;
[[Category:Tutorials]]&lt;/div&gt;</summary>
		<author><name>Ducks</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.splashdamage.com/index.php?title=A_Simple_First_Megatexture&amp;diff=4062</id>
		<title>A Simple First Megatexture</title>
		<link rel="alternate" type="text/html" href="https://wiki.splashdamage.com/index.php?title=A_Simple_First_Megatexture&amp;diff=4062"/>
		<updated>2007-12-17T15:14:32Z</updated>

		<summary type="html">&lt;p&gt;Ducks: /* Distribution Pattern */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Image:simplemega_ingame.jpg|right|thumb|500px|A simple MegaTexture, easily created with only 3 texture layers!]]&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
'''For this tutorial you must:'''&lt;br /&gt;
* Have a terrain model UV-mapped in the 0-1 range (covered in the simple first terrain tutorial)&lt;br /&gt;
* Have access to some tiling textures.&lt;br /&gt;
* Have a little understanding the ETQW material system&lt;br /&gt;
&lt;br /&gt;
If you don't have any of the above things, you are not ready to do this tutorial!&lt;br /&gt;
&lt;br /&gt;
'''This tutorial covers:'''&lt;br /&gt;
* How to set up a MegaTexture material&lt;br /&gt;
* How to create a Surface Tree&lt;br /&gt;
* How to add texture nodes in the Terrain Editor&lt;br /&gt;
* How to render and compile a full MegaTexture&lt;br /&gt;
&lt;br /&gt;
'''This tutorial does not cover:'''&lt;br /&gt;
* How to use Blender/Maya/Lightwave/ZBrush/Mudbox/3DSMax/Photoshop&lt;br /&gt;
* How to create tiling textures or heightmaps&lt;br /&gt;
* Anything overly complicated&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Creating a MegaTexture material ==&lt;br /&gt;
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:&lt;br /&gt;
 material megatextures/mapname		{ useTemplate megatextures/default_ambient&amp;lt; &amp;quot;mapname&amp;quot; &amp;gt; }&lt;br /&gt;
&lt;br /&gt;
This material would automatically search for a MegaTexture called {{filename|mapname.mega}} in the {{filename|/megatextures/}} folder. This example material uses the ''&amp;quot;default_ambient&amp;quot;'' 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]].&lt;br /&gt;
&lt;br /&gt;
Obviously you would want to use the actual name of your map instead of &amp;quot;mapname&amp;quot;, for consistency's sake and ease of reference.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Assigning the material ===&lt;br /&gt;
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).&lt;br /&gt;
Tips on this process can be found in the [[A Simple First Terrain|simple first terrain tutorial]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Creating the Surface Tree ==&lt;br /&gt;
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 &amp;quot;Save and Unload&amp;quot; button in the Terrain Editor.&lt;br /&gt;
[[Image:simplemega_terrainmodel.png|thumb|300px|Root node set up to use the correct terrain mesh]]&lt;br /&gt;
&lt;br /&gt;
=== Add the terrain mesh ===&lt;br /&gt;
Here's how you bring the terrain mesh into the surface tree:&lt;br /&gt;
* {{accelbtn|RMB}} on the left-hand pane, and choose ''New -&amp;gt; Tree'' via the menu.&lt;br /&gt;
** If you already have a Root node, click the &amp;quot;Begin Editing&amp;quot; button instead.&lt;br /&gt;
* Click on the Root node, and set {{keyname|Model}} to the name of the terrain mesh, in this case {{keyvalue|models/terrain/simpleterrain.obj}}.&lt;br /&gt;
* Press {{accelkey|enter}} to confirm the selection, and the terrain should appear in the 3D view.&lt;br /&gt;
&lt;br /&gt;
Be aware that your terrain model will probably appear bright orange or red.&lt;br /&gt;
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!&lt;br /&gt;
&lt;br /&gt;
=== Important note about nodes ===&lt;br /&gt;
When you are editing properties of nodes (names, numbers, texture sources etc.) always remember to hit {{accelkey|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 {{accelkey|enter}}, your changes may not be applied.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Create the first texture node ==&lt;br /&gt;
[[Image:simplemega_firstnode_diffuse.png|thumb|300px|The first texture node's diffuse texture properties]]&lt;br /&gt;
Now that the model is in place, you can start laying down the texture layers (or &amp;quot;nodes&amp;quot;) that will make up your MegaTexture.&lt;br /&gt;
&lt;br /&gt;
First you need to create a new Image Source node in the Terrain Editor.&lt;br /&gt;
* {{accelbtn|RMB}} on your &amp;quot;Root&amp;quot; node and choose ''New -&amp;gt; Image Source'' (or press {{accelkey|shift}}{{accelkey|i}})&lt;br /&gt;
* This will make a new node called &amp;quot;New Image Renderer&amp;quot;.&lt;br /&gt;
* You can rename this new node using the &amp;quot;Name&amp;quot; property field in the '''Object''' section.&lt;br /&gt;
* Rename the node &amp;quot;Dirt&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
You will notice in the top right of the Terrain Editor, a section listing things like &amp;quot;Diffuse&amp;quot;, &amp;quot;Distribution&amp;quot;, &amp;quot;Distribution Pattern&amp;quot; etc. Selecting one of these will list all of the properties for that section of the current node.&lt;br /&gt;
The ones we need to worry about are as follows:&lt;br /&gt;
&lt;br /&gt;
=== Diffuse ===&lt;br /&gt;
This is the colour map of the current node, and it should point to a tiling TGA texture.&lt;br /&gt;
* Make sure the Diffuse section is highlighted in the top right of the Terrain Editor.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to a generic tiling dirt texture. Remember to hit {{accelkey|enter}} afterwards!&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/dirt_02_d.tga}}&lt;br /&gt;
* The {{keyname|Scale}} field at the very bottom of the property list allows you to choose how much to tile the texture.&lt;br /&gt;
** 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!&lt;br /&gt;
** 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.&lt;br /&gt;
That's all you need to do for the Diffuse settings in this node.&lt;br /&gt;
&lt;br /&gt;
=== Distribution ===&lt;br /&gt;
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''.&lt;br /&gt;
* Make sure the Distribution section is highlighted in the top right.&lt;br /&gt;
* Since this is our first node, we want to show over the whole terrain. This means the distribution map should be 100% white.&lt;br /&gt;
* You can either assign a pure white TGA texture, or change the {{keyname|Source Type}} to {{keyvalue|geometryBased}}.&lt;br /&gt;
** {{keyvalue|geometryBased}} will by default create a fully white map, so if you don't have a white TGA handy, this is faster.&lt;br /&gt;
&lt;br /&gt;
=== Distribution Pattern ===&lt;br /&gt;
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.&lt;br /&gt;
* 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!&lt;br /&gt;
&lt;br /&gt;
=== Local ===&lt;br /&gt;
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.&lt;br /&gt;
* Make sure the Local section is highlighted in the top right.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching normal map for your tiling dirt texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/dirt_02_local.tga}}&lt;br /&gt;
* The Local texture's tiling amount is automatically the same as the Diffuse texture.&lt;br /&gt;
&lt;br /&gt;
=== Surface Type ===&lt;br /&gt;
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.&lt;br /&gt;
* Find the ''Surface Type Properties'' section of the property list.&lt;br /&gt;
* 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.&lt;br /&gt;
* Hit {{accelkey|enter}} to accept the surface type.&lt;br /&gt;
&lt;br /&gt;
Your dirt textures will now produce correct &amp;quot;dirt&amp;quot; effects when shot or collided with!&lt;br /&gt;
&lt;br /&gt;
=== Previewing the result ===&lt;br /&gt;
[[Image:simplemega_firstnode_preview.jpg|thumb|300px|The Render mode preview of the first node]]&lt;br /&gt;
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]]&lt;br /&gt;
&lt;br /&gt;
* Notice the drop-down arrow on the right of the button. Click it, and select ''&amp;quot;Full&amp;quot;'' instead of ''&amp;quot;None&amp;quot;''.&lt;br /&gt;
* Your terrain should change colour to black. This means it's ready for a preview to be rendered onto it.&lt;br /&gt;
* Click the button itself now, instead of the drop-down. An &amp;quot;Active Tasks&amp;quot; window should pop up, and when it's done, you should see your dirt texture appear on your terrain model.&lt;br /&gt;
* You can switch the camera to Render mode too, which will show your terrain model's shading better.&lt;br /&gt;
* If you want a full-resolution preview of a small area, choose ''&amp;quot;Window&amp;quot;'' instead of ''&amp;quot;Full&amp;quot;'' from the drop-down menu.&lt;br /&gt;
** 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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
'''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.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
== Adding a second node ==&lt;br /&gt;
Now that the first layer of dirt is in place, we can try putting some grass on top of it!&lt;br /&gt;
* Again, {{accelbtn|RMB}} on your &amp;quot;Root&amp;quot; node and choose ''New -&amp;gt; Image Source'' (or press {{accelkey|shift}}{{accelkey|i}})&lt;br /&gt;
* This will make another new node below your &amp;quot;Dirt&amp;quot; node. &lt;br /&gt;
* Name this new node &amp;quot;Grass&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Again, the main map types need to be specified before the node can be rendered:&lt;br /&gt;
&lt;br /&gt;
=== Diffuse ===&lt;br /&gt;
* Make sure the Diffuse section is highlighted in the top right of the Terrain Editor.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to a generic tiling grass texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/grass_04_d.tga}}&lt;br /&gt;
* 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.&lt;br /&gt;
&lt;br /&gt;
=== Distribution ===&lt;br /&gt;
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!&lt;br /&gt;
* Make sure the Distribution section is highlighted in the top right.&lt;br /&gt;
* Change the {{keyname|Source Type}} from {{keyvalue|texture}} to {{keyvalue|geometryBased}}.&lt;br /&gt;
&lt;br /&gt;
=== Geometric Texture Distribution ===&lt;br /&gt;
[[Image:simplemega_geometric_distribution.png|thumb|300px|The geometric texture distribution settings of the second node]]&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
* ''Altitude Lower'' - Enabling this will limit the lower parts of the terrain from receiving this node's textures.&lt;br /&gt;
** {{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.&lt;br /&gt;
** {{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.&lt;br /&gt;
* ''Altitude Upper'' - Enabling this will limit the higher parts of the terrain from receiving this node's textures.&lt;br /&gt;
** {{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.&lt;br /&gt;
** {{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.&lt;br /&gt;
&lt;br /&gt;
* {{keyname|Clamp Distribution To Edge}} - Leave this on Default.&lt;br /&gt;
&lt;br /&gt;
* {{keyname|Resolution}} - The size in pixels of the resulting mask. The default value of {{keyvalue|256}} is fine for nearly any terrain model.&lt;br /&gt;
&lt;br /&gt;
* ''Slope Lower'' - Enabling this will limit shallower angles of the terrain model from receiving this node's textures.&lt;br /&gt;
** {{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.&lt;br /&gt;
** {{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.&lt;br /&gt;
* ''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.&lt;br /&gt;
** {{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.&lt;br /&gt;
** {{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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
=== Distribution Pattern ===&lt;br /&gt;
[[Image:simplemega_dist_ramps.jpg|thumb|300px|The difference between using or not using a Distribution Pattern, and varying Ramp Widths]]&lt;br /&gt;
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!&lt;br /&gt;
So what we want here is a texture to identify the &amp;quot;height&amp;quot; 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.&lt;br /&gt;
&lt;br /&gt;
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!&lt;br /&gt;
&lt;br /&gt;
* Make sure {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching heightmap or mask for your tiling grass texture.&lt;br /&gt;
** This example is using {{kevalue|textures/megagen/temperate/grass_04_mask.tga}}&lt;br /&gt;
* 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 &amp;quot;Window&amp;quot; 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.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
=== Local ===&lt;br /&gt;
Again we want the normal-map which matches the diffuse texture for the grass.&lt;br /&gt;
* Make sure the Local section is highlighted in the top right.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching normal map for your tiling grass texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/grass_04_local.tga}}&lt;br /&gt;
&lt;br /&gt;
=== Surface Type ===&lt;br /&gt;
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.&lt;br /&gt;
* Find the ''Surface Type Properties'' section of the property list.&lt;br /&gt;
* 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.&lt;br /&gt;
* Hit {{accelkey|enter}} to accept the surface type.&lt;br /&gt;
&lt;br /&gt;
Your grass textures should now produce correct &amp;quot;grass&amp;quot; effects when shot or collided with!&lt;br /&gt;
&lt;br /&gt;
=== Preview ===&lt;br /&gt;
[[Image:simplemega_secondnode_preview.jpg|thumb|300px|The Render mode preview of the second node blended with the first node]]&lt;br /&gt;
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.&lt;br /&gt;
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.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
== Adding a third node ==&lt;br /&gt;
[[Image:simplemega_thirdnode_preview.jpg|thumb|300px|The Render mode preview of the third node blended with the other two nodes]]&lt;br /&gt;
Now that the grass and dirt are in place, we need some rocks to make the terrain look more natural.&lt;br /&gt;
* Add a new Image Renderer node below your &amp;quot;Grass&amp;quot; node and name it &amp;quot;Rock&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Again, the main map types need to be specified before the node can be rendered:&lt;br /&gt;
&lt;br /&gt;
=== Diffuse ===&lt;br /&gt;
* Set the '''Diffuse''' texture and scale.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/rock_01_d.tga}} at a scale of {{keyvalue|32 32}}&lt;br /&gt;
&lt;br /&gt;
=== Distribution ===&lt;br /&gt;
Again we can use Geometric Texture Distribution to easily apply the rock textures only to the cliff-like angles.&lt;br /&gt;
* Make sure the Distribution section is highlighted in the top right.&lt;br /&gt;
* Change the {{keyname|Source Type}} to {{keyvalue|geometryBased}}.&lt;br /&gt;
* 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}}&lt;br /&gt;
&lt;br /&gt;
=== Distribution Pattern ===&lt;br /&gt;
Again this will control how the the rocks blend into the other nodes. Again, we want a texture to identify the &amp;quot;height&amp;quot; of the tiling rock texture.&lt;br /&gt;
&lt;br /&gt;
* Make sure the Distribution Pattern section is highlighted in the top right.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching heightmap or mask for your tiling rock texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/rock_01_h.tga}}&lt;br /&gt;
* 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 &amp;quot;Window&amp;quot; preview to see how the blending looks.&lt;br /&gt;
* Remember to set the {{keyname|Distribution Pattern Texture Scale}} to the same value as the Diffuse Scale, {{keyvalue|32 32}}.&lt;br /&gt;
&lt;br /&gt;
=== Local ===&lt;br /&gt;
Again we want the normal-map which matches the diffuse texture for the rocks.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Local''' section, browse to the matching normal map for your tiling rock texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/rock_01_local.tga}}&lt;br /&gt;
&lt;br /&gt;
=== Surface Type ===&lt;br /&gt;
* Find the ''Surface Type Properties'' section of the property list.&lt;br /&gt;
* In the {{keyname|Type}} field, enter {{keyvalue|stone}}.&lt;br /&gt;
* Hit {{accelkey|enter}} to accept the surface type.&lt;br /&gt;
&lt;br /&gt;
Your rock textures should now produce correct &amp;quot;stone&amp;quot; effects when shot or collided with.&lt;br /&gt;
&lt;br /&gt;
=== Preview ===&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Further tweaks ==&lt;br /&gt;
There are other simple changes that can be done in the Terrain Editor to make your MegaTexture look even better.&lt;br /&gt;
&lt;br /&gt;
=== Node order ===&lt;br /&gt;
[Image:simplemega_node_order.png|frame|Click and drag a node to change the order]]&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
* {{accelbtn|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.&lt;br /&gt;
* Release {{accelbtn|LMB}} when you have positioned the node in the correct place.&lt;br /&gt;
* 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!&lt;br /&gt;
&lt;br /&gt;
=== Color changes ===&lt;br /&gt;
Maybe your dirt texture is too bright? Or maybe your grass looks a little ''too'' green?&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Let's say you want to make the dirt texture darker and a bit more red. Here's how you'd do it:&lt;br /&gt;
* Select your Dirt node.&lt;br /&gt;
* 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).&lt;br /&gt;
* A color wheel and brightness slider will pop up in a new window. You can use this to darken and tint your texture.&lt;br /&gt;
* Choose a darker brightness, and a color slightly towards red. I used '''RGB Values''' of 225, 220, 220.&lt;br /&gt;
* Hit ''OK'' to accept the color.&lt;br /&gt;
* Re-render your MegaTexture preview. You should notice that the dirt layer looks darker now!&lt;br /&gt;
&lt;br /&gt;
=== Texture rotation ===&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
For each node, you should also set the {{keyvname|Distribution Pattern Texture Rotation}} to match the Rotation value if you want your distribution patterns to line up and work correctly.&lt;br /&gt;
&lt;br /&gt;
== Render the MegaTexture ==&lt;br /&gt;
=== Save the Surface Tree ===&lt;br /&gt;
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 &amp;quot;Save and Unload&amp;quot; button in the Terrain Editor, or save the whole map.&lt;br /&gt;
&lt;br /&gt;
=== Compile Only Entities ===&lt;br /&gt;
At this stage, your MegaTexture material is still technically &amp;quot;broken&amp;quot;, 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.&lt;br /&gt;
&lt;br /&gt;
However, we need to compile the map in order to tell the [[renderLight]] process which atmosphere to use when lighting the MegaTexture!&lt;br /&gt;
&lt;br /&gt;
So the solution is to do an '''Only Entities''' compile. You can find this in the menu ''Compile -&amp;gt; 2 - Only Entities'' in editWorld. This should be done in a few seconds, and compiles all the information that renderLight needs.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Run the SDK Launcher ===&lt;br /&gt;
Now that your ''.sft'' is saved, go through all the steps outlined in the [[Generate a MegaTexture]] tutorial.&lt;br /&gt;
&lt;br /&gt;
== That's it! ==&lt;br /&gt;
[[Image:simplemega_ingame.jpg|thumb|300px|The MegaTexture in-game!]]&lt;br /&gt;
You've now created your very own MegaTexture to use in your map!&lt;br /&gt;
&lt;br /&gt;
Before you even compile the map, you can get an accurate preview of how it will look in-game by pressing {{accelkey|F6}} to toggle &amp;quot;anim&amp;quot; mode while in editWorld's &amp;quot;RENDER&amp;quot; Camera view (toggled with {{accelkey|F3}}).&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
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:&lt;br /&gt;
* 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.&lt;br /&gt;
* 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 ''&amp;lt; &amp;quot;mapname&amp;quot; &amp;gt;'' part described in [[A Simple First Megatexture#Creating a MegaTexture material|this section]]), otherwise it will not be searching for the correct images.&lt;br /&gt;
* 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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
* [[An Advanced Terrain and Megatexture]] - an advanced guide for complete MegaTexture creation&lt;br /&gt;
* [[Generate a MegaTexture]] - steps for generating a MegaTexture from the SDK launcher.&lt;br /&gt;
* [http://community.enemyterritory.com/forums/showthread.php?t=19326 Forum Thread] - includes textures to download&lt;br /&gt;
&lt;br /&gt;
[[Category:Art]]&lt;br /&gt;
[[Category:Basic Level Design]]&lt;br /&gt;
[[Category:Tutorials]]&lt;/div&gt;</summary>
		<author><name>Ducks</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.splashdamage.com/index.php?title=A_Simple_First_Megatexture&amp;diff=4061</id>
		<title>A Simple First Megatexture</title>
		<link rel="alternate" type="text/html" href="https://wiki.splashdamage.com/index.php?title=A_Simple_First_Megatexture&amp;diff=4061"/>
		<updated>2007-12-17T15:12:31Z</updated>

		<summary type="html">&lt;p&gt;Ducks: /* Further tweaks */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Image:simplemega_ingame.jpg|right|thumb|500px|A simple MegaTexture, easily created with only 3 texture layers!]]&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
'''For this tutorial you must:'''&lt;br /&gt;
* Have a terrain model UV-mapped in the 0-1 range (covered in the simple first terrain tutorial)&lt;br /&gt;
* Have access to some tiling textures.&lt;br /&gt;
* Have a little understanding the ETQW material system&lt;br /&gt;
&lt;br /&gt;
If you don't have any of the above things, you are not ready to do this tutorial!&lt;br /&gt;
&lt;br /&gt;
'''This tutorial covers:'''&lt;br /&gt;
* How to set up a MegaTexture material&lt;br /&gt;
* How to create a Surface Tree&lt;br /&gt;
* How to add texture nodes in the Terrain Editor&lt;br /&gt;
* How to render and compile a full MegaTexture&lt;br /&gt;
&lt;br /&gt;
'''This tutorial does not cover:'''&lt;br /&gt;
* How to use Blender/Maya/Lightwave/ZBrush/Mudbox/3DSMax/Photoshop&lt;br /&gt;
* How to create tiling textures or heightmaps&lt;br /&gt;
* Anything overly complicated&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Creating a MegaTexture material ==&lt;br /&gt;
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:&lt;br /&gt;
 material megatextures/mapname		{ useTemplate megatextures/default_ambient&amp;lt; &amp;quot;mapname&amp;quot; &amp;gt; }&lt;br /&gt;
&lt;br /&gt;
This material would automatically search for a MegaTexture called {{filename|mapname.mega}} in the {{filename|/megatextures/}} folder. This example material uses the ''&amp;quot;default_ambient&amp;quot;'' 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]].&lt;br /&gt;
&lt;br /&gt;
Obviously you would want to use the actual name of your map instead of &amp;quot;mapname&amp;quot;, for consistency's sake and ease of reference.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Assigning the material ===&lt;br /&gt;
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).&lt;br /&gt;
Tips on this process can be found in the [[A Simple First Terrain|simple first terrain tutorial]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Creating the Surface Tree ==&lt;br /&gt;
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 &amp;quot;Save and Unload&amp;quot; button in the Terrain Editor.&lt;br /&gt;
[[Image:simplemega_terrainmodel.png|thumb|300px|Root node set up to use the correct terrain mesh]]&lt;br /&gt;
&lt;br /&gt;
=== Add the terrain mesh ===&lt;br /&gt;
Here's how you bring the terrain mesh into the surface tree:&lt;br /&gt;
* {{accelbtn|RMB}} on the left-hand pane, and choose ''New -&amp;gt; Tree'' via the menu.&lt;br /&gt;
** If you already have a Root node, click the &amp;quot;Begin Editing&amp;quot; button instead.&lt;br /&gt;
* Click on the Root node, and set {{keyname|Model}} to the name of the terrain mesh, in this case {{keyvalue|models/terrain/simpleterrain.obj}}.&lt;br /&gt;
* Press {{accelkey|enter}} to confirm the selection, and the terrain should appear in the 3D view.&lt;br /&gt;
&lt;br /&gt;
Be aware that your terrain model will probably appear bright orange or red.&lt;br /&gt;
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!&lt;br /&gt;
&lt;br /&gt;
=== Important note about nodes ===&lt;br /&gt;
When you are editing properties of nodes (names, numbers, texture sources etc.) always remember to hit {{accelkey|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 {{accelkey|enter}}, your changes may not be applied.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Create the first texture node ==&lt;br /&gt;
[[Image:simplemega_firstnode_diffuse.png|thumb|300px|The first texture node's diffuse texture properties]]&lt;br /&gt;
Now that the model is in place, you can start laying down the texture layers (or &amp;quot;nodes&amp;quot;) that will make up your MegaTexture.&lt;br /&gt;
&lt;br /&gt;
First you need to create a new Image Source node in the Terrain Editor.&lt;br /&gt;
* {{accelbtn|RMB}} on your &amp;quot;Root&amp;quot; node and choose ''New -&amp;gt; Image Source'' (or press {{accelkey|shift}}{{accelkey|i}})&lt;br /&gt;
* This will make a new node called &amp;quot;New Image Renderer&amp;quot;.&lt;br /&gt;
* You can rename this new node using the &amp;quot;Name&amp;quot; property field in the '''Object''' section.&lt;br /&gt;
* Rename the node &amp;quot;Dirt&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
You will notice in the top right of the Terrain Editor, a section listing things like &amp;quot;Diffuse&amp;quot;, &amp;quot;Distribution&amp;quot;, &amp;quot;Distribution Pattern&amp;quot; etc. Selecting one of these will list all of the properties for that section of the current node.&lt;br /&gt;
The ones we need to worry about are as follows:&lt;br /&gt;
&lt;br /&gt;
=== Diffuse ===&lt;br /&gt;
This is the colour map of the current node, and it should point to a tiling TGA texture.&lt;br /&gt;
* Make sure the Diffuse section is highlighted in the top right of the Terrain Editor.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to a generic tiling dirt texture. Remember to hit {{accelkey|enter}} afterwards!&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/dirt_02_d.tga}}&lt;br /&gt;
* The {{keyname|Scale}} field at the very bottom of the property list allows you to choose how much to tile the texture.&lt;br /&gt;
** 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!&lt;br /&gt;
** 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.&lt;br /&gt;
That's all you need to do for the Diffuse settings in this node.&lt;br /&gt;
&lt;br /&gt;
=== Distribution ===&lt;br /&gt;
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''.&lt;br /&gt;
* Make sure the Distribution section is highlighted in the top right.&lt;br /&gt;
* Since this is our first node, we want to show over the whole terrain. This means the distribution map should be 100% white.&lt;br /&gt;
* You can either assign a pure white TGA texture, or change the {{keyname|Source Type}} to {{keyvalue|geometryBased}}.&lt;br /&gt;
** {{keyvalue|geometryBased}} will by default create a fully white map, so if you don't have a white TGA handy, this is faster.&lt;br /&gt;
&lt;br /&gt;
=== Distribution Pattern ===&lt;br /&gt;
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.&lt;br /&gt;
* 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!&lt;br /&gt;
&lt;br /&gt;
=== Local ===&lt;br /&gt;
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.&lt;br /&gt;
* Make sure the Local section is highlighted in the top right.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching normal map for your tiling dirt texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/dirt_02_local.tga}}&lt;br /&gt;
* The Local texture's tiling amount is automatically the same as the Diffuse texture.&lt;br /&gt;
&lt;br /&gt;
=== Surface Type ===&lt;br /&gt;
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.&lt;br /&gt;
* Find the ''Surface Type Properties'' section of the property list.&lt;br /&gt;
* 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.&lt;br /&gt;
* Hit {{accelkey|enter}} to accept the surface type.&lt;br /&gt;
&lt;br /&gt;
Your dirt textures will now produce correct &amp;quot;dirt&amp;quot; effects when shot or collided with!&lt;br /&gt;
&lt;br /&gt;
=== Previewing the result ===&lt;br /&gt;
[[Image:simplemega_firstnode_preview.jpg|thumb|300px|The Render mode preview of the first node]]&lt;br /&gt;
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]]&lt;br /&gt;
&lt;br /&gt;
* Notice the drop-down arrow on the right of the button. Click it, and select ''&amp;quot;Full&amp;quot;'' instead of ''&amp;quot;None&amp;quot;''.&lt;br /&gt;
* Your terrain should change colour to black. This means it's ready for a preview to be rendered onto it.&lt;br /&gt;
* Click the button itself now, instead of the drop-down. An &amp;quot;Active Tasks&amp;quot; window should pop up, and when it's done, you should see your dirt texture appear on your terrain model.&lt;br /&gt;
* You can switch the camera to Render mode too, which will show your terrain model's shading better.&lt;br /&gt;
* If you want a full-resolution preview of a small area, choose ''&amp;quot;Window&amp;quot;'' instead of ''&amp;quot;Full&amp;quot;'' from the drop-down menu.&lt;br /&gt;
** 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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
'''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.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
== Adding a second node ==&lt;br /&gt;
Now that the first layer of dirt is in place, we can try putting some grass on top of it!&lt;br /&gt;
* Again, {{accelbtn|RMB}} on your &amp;quot;Root&amp;quot; node and choose ''New -&amp;gt; Image Source'' (or press {{accelkey|shift}}{{accelkey|i}})&lt;br /&gt;
* This will make another new node below your &amp;quot;Dirt&amp;quot; node. &lt;br /&gt;
* Name this new node &amp;quot;Grass&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Again, the main map types need to be specified before the node can be rendered:&lt;br /&gt;
&lt;br /&gt;
=== Diffuse ===&lt;br /&gt;
* Make sure the Diffuse section is highlighted in the top right of the Terrain Editor.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to a generic tiling grass texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/grass_04_d.tga}}&lt;br /&gt;
* 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.&lt;br /&gt;
&lt;br /&gt;
=== Distribution ===&lt;br /&gt;
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!&lt;br /&gt;
* Make sure the Distribution section is highlighted in the top right.&lt;br /&gt;
* Change the {{keyname|Source Type}} from {{keyvalue|texture}} to {{keyvalue|geometryBased}}.&lt;br /&gt;
&lt;br /&gt;
=== Geometric Texture Distribution ===&lt;br /&gt;
[[Image:simplemega_geometric_distribution.png|thumb|300px|The geometric texture distribution settings of the second node]]&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
* ''Altitude Lower'' - Enabling this will limit the lower parts of the terrain from receiving this node's textures.&lt;br /&gt;
** {{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.&lt;br /&gt;
** {{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.&lt;br /&gt;
* ''Altitude Upper'' - Enabling this will limit the higher parts of the terrain from receiving this node's textures.&lt;br /&gt;
** {{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.&lt;br /&gt;
** {{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.&lt;br /&gt;
&lt;br /&gt;
* {{keyname|Clamp Distribution To Edge}} - Leave this on Default.&lt;br /&gt;
&lt;br /&gt;
* {{keyname|Resolution}} - The size in pixels of the resulting mask. The default value of {{keyvalue|256}} is fine for nearly any terrain model.&lt;br /&gt;
&lt;br /&gt;
* ''Slope Lower'' - Enabling this will limit shallower angles of the terrain model from receiving this node's textures.&lt;br /&gt;
** {{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.&lt;br /&gt;
** {{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.&lt;br /&gt;
* ''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.&lt;br /&gt;
** {{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.&lt;br /&gt;
** {{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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
=== Distribution Pattern ===&lt;br /&gt;
[[Image:simplemega_dist_ramps.jpg|thumb|300px|The difference between using or not using a Distribution Pattern, and varying Ramp Widths]]&lt;br /&gt;
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!&lt;br /&gt;
So what we want here is a texture to identify the &amp;quot;height&amp;quot; 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.&lt;br /&gt;
&lt;br /&gt;
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!&lt;br /&gt;
&lt;br /&gt;
* Make sure {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching heightmap or mask for your tiling grass texture.&lt;br /&gt;
** This example is using {{filename|textures/megagen/temperate/grass_04_mask.tga}}&lt;br /&gt;
* 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 &amp;quot;Window&amp;quot; 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.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
=== Local ===&lt;br /&gt;
Again we want the normal-map which matches the diffuse texture for the grass.&lt;br /&gt;
* Make sure the Local section is highlighted in the top right.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching normal map for your tiling grass texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/grass_04_local.tga}}&lt;br /&gt;
&lt;br /&gt;
=== Surface Type ===&lt;br /&gt;
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.&lt;br /&gt;
* Find the ''Surface Type Properties'' section of the property list.&lt;br /&gt;
* 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.&lt;br /&gt;
* Hit {{accelkey|enter}} to accept the surface type.&lt;br /&gt;
&lt;br /&gt;
Your grass textures should now produce correct &amp;quot;grass&amp;quot; effects when shot or collided with!&lt;br /&gt;
&lt;br /&gt;
=== Preview ===&lt;br /&gt;
[[Image:simplemega_secondnode_preview.jpg|thumb|300px|The Render mode preview of the second node blended with the first node]]&lt;br /&gt;
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.&lt;br /&gt;
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.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
== Adding a third node ==&lt;br /&gt;
[[Image:simplemega_thirdnode_preview.jpg|thumb|300px|The Render mode preview of the third node blended with the other two nodes]]&lt;br /&gt;
Now that the grass and dirt are in place, we need some rocks to make the terrain look more natural.&lt;br /&gt;
* Add a new Image Renderer node below your &amp;quot;Grass&amp;quot; node and name it &amp;quot;Rock&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Again, the main map types need to be specified before the node can be rendered:&lt;br /&gt;
&lt;br /&gt;
=== Diffuse ===&lt;br /&gt;
* Set the '''Diffuse''' texture and scale.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/rock_01_d.tga}} at a scale of {{keyvalue|32 32}}&lt;br /&gt;
&lt;br /&gt;
=== Distribution ===&lt;br /&gt;
Again we can use Geometric Texture Distribution to easily apply the rock textures only to the cliff-like angles.&lt;br /&gt;
* Make sure the Distribution section is highlighted in the top right.&lt;br /&gt;
* Change the {{keyname|Source Type}} to {{keyvalue|geometryBased}}.&lt;br /&gt;
* 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}}&lt;br /&gt;
&lt;br /&gt;
=== Distribution Pattern ===&lt;br /&gt;
Again this will control how the the rocks blend into the other nodes. Again, we want a texture to identify the &amp;quot;height&amp;quot; of the tiling rock texture.&lt;br /&gt;
&lt;br /&gt;
* Make sure the Distribution Pattern section is highlighted in the top right.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching heightmap or mask for your tiling rock texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/rock_01_h.tga}}&lt;br /&gt;
* 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 &amp;quot;Window&amp;quot; preview to see how the blending looks.&lt;br /&gt;
* Remember to set the {{keyname|Distribution Pattern Texture Scale}} to the same value as the Diffuse Scale, {{keyvalue|32 32}}.&lt;br /&gt;
&lt;br /&gt;
=== Local ===&lt;br /&gt;
Again we want the normal-map which matches the diffuse texture for the rocks.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Local''' section, browse to the matching normal map for your tiling rock texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/rock_01_local.tga}}&lt;br /&gt;
&lt;br /&gt;
=== Surface Type ===&lt;br /&gt;
* Find the ''Surface Type Properties'' section of the property list.&lt;br /&gt;
* In the {{keyname|Type}} field, enter {{keyvalue|stone}}.&lt;br /&gt;
* Hit {{accelkey|enter}} to accept the surface type.&lt;br /&gt;
&lt;br /&gt;
Your rock textures should now produce correct &amp;quot;stone&amp;quot; effects when shot or collided with.&lt;br /&gt;
&lt;br /&gt;
=== Preview ===&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Further tweaks ==&lt;br /&gt;
There are other simple changes that can be done in the Terrain Editor to make your MegaTexture look even better.&lt;br /&gt;
&lt;br /&gt;
=== Node order ===&lt;br /&gt;
[Image:simplemega_node_order.png|frame|Click and drag a node to change the order]]&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
* {{accelbtn|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.&lt;br /&gt;
* Release {{accelbtn|LMB}} when you have positioned the node in the correct place.&lt;br /&gt;
* 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!&lt;br /&gt;
&lt;br /&gt;
=== Color changes ===&lt;br /&gt;
Maybe your dirt texture is too bright? Or maybe your grass looks a little ''too'' green?&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Let's say you want to make the dirt texture darker and a bit more red. Here's how you'd do it:&lt;br /&gt;
* Select your Dirt node.&lt;br /&gt;
* 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).&lt;br /&gt;
* A color wheel and brightness slider will pop up in a new window. You can use this to darken and tint your texture.&lt;br /&gt;
* Choose a darker brightness, and a color slightly towards red. I used '''RGB Values''' of 225, 220, 220.&lt;br /&gt;
* Hit ''OK'' to accept the color.&lt;br /&gt;
* Re-render your MegaTexture preview. You should notice that the dirt layer looks darker now!&lt;br /&gt;
&lt;br /&gt;
=== Texture rotation ===&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
For each node, you should also set the {{keyvname|Distribution Pattern Texture Rotation}} to match the Rotation value if you want your distribution patterns to line up and work correctly.&lt;br /&gt;
&lt;br /&gt;
== Render the MegaTexture ==&lt;br /&gt;
=== Save the Surface Tree ===&lt;br /&gt;
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 &amp;quot;Save and Unload&amp;quot; button in the Terrain Editor, or save the whole map.&lt;br /&gt;
&lt;br /&gt;
=== Compile Only Entities ===&lt;br /&gt;
At this stage, your MegaTexture material is still technically &amp;quot;broken&amp;quot;, 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.&lt;br /&gt;
&lt;br /&gt;
However, we need to compile the map in order to tell the [[renderLight]] process which atmosphere to use when lighting the MegaTexture!&lt;br /&gt;
&lt;br /&gt;
So the solution is to do an '''Only Entities''' compile. You can find this in the menu ''Compile -&amp;gt; 2 - Only Entities'' in editWorld. This should be done in a few seconds, and compiles all the information that renderLight needs.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Run the SDK Launcher ===&lt;br /&gt;
Now that your ''.sft'' is saved, go through all the steps outlined in the [[Generate a MegaTexture]] tutorial.&lt;br /&gt;
&lt;br /&gt;
== That's it! ==&lt;br /&gt;
[[Image:simplemega_ingame.jpg|thumb|300px|The MegaTexture in-game!]]&lt;br /&gt;
You've now created your very own MegaTexture to use in your map!&lt;br /&gt;
&lt;br /&gt;
Before you even compile the map, you can get an accurate preview of how it will look in-game by pressing {{accelkey|F6}} to toggle &amp;quot;anim&amp;quot; mode while in editWorld's &amp;quot;RENDER&amp;quot; Camera view (toggled with {{accelkey|F3}}).&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
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:&lt;br /&gt;
* 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.&lt;br /&gt;
* 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 ''&amp;lt; &amp;quot;mapname&amp;quot; &amp;gt;'' part described in [[A Simple First Megatexture#Creating a MegaTexture material|this section]]), otherwise it will not be searching for the correct images.&lt;br /&gt;
* 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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
* [[An Advanced Terrain and Megatexture]] - an advanced guide for complete MegaTexture creation&lt;br /&gt;
* [[Generate a MegaTexture]] - steps for generating a MegaTexture from the SDK launcher.&lt;br /&gt;
* [http://community.enemyterritory.com/forums/showthread.php?t=19326 Forum Thread] - includes textures to download&lt;br /&gt;
&lt;br /&gt;
[[Category:Art]]&lt;br /&gt;
[[Category:Basic Level Design]]&lt;br /&gt;
[[Category:Tutorials]]&lt;/div&gt;</summary>
		<author><name>Ducks</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.splashdamage.com/index.php?title=A_Simple_First_Megatexture&amp;diff=4060</id>
		<title>A Simple First Megatexture</title>
		<link rel="alternate" type="text/html" href="https://wiki.splashdamage.com/index.php?title=A_Simple_First_Megatexture&amp;diff=4060"/>
		<updated>2007-12-17T15:12:10Z</updated>

		<summary type="html">&lt;p&gt;Ducks: /* Further tweaks */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Image:simplemega_ingame.jpg|right|thumb|500px|A simple MegaTexture, easily created with only 3 texture layers!]]&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
'''For this tutorial you must:'''&lt;br /&gt;
* Have a terrain model UV-mapped in the 0-1 range (covered in the simple first terrain tutorial)&lt;br /&gt;
* Have access to some tiling textures.&lt;br /&gt;
* Have a little understanding the ETQW material system&lt;br /&gt;
&lt;br /&gt;
If you don't have any of the above things, you are not ready to do this tutorial!&lt;br /&gt;
&lt;br /&gt;
'''This tutorial covers:'''&lt;br /&gt;
* How to set up a MegaTexture material&lt;br /&gt;
* How to create a Surface Tree&lt;br /&gt;
* How to add texture nodes in the Terrain Editor&lt;br /&gt;
* How to render and compile a full MegaTexture&lt;br /&gt;
&lt;br /&gt;
'''This tutorial does not cover:'''&lt;br /&gt;
* How to use Blender/Maya/Lightwave/ZBrush/Mudbox/3DSMax/Photoshop&lt;br /&gt;
* How to create tiling textures or heightmaps&lt;br /&gt;
* Anything overly complicated&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Creating a MegaTexture material ==&lt;br /&gt;
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:&lt;br /&gt;
 material megatextures/mapname		{ useTemplate megatextures/default_ambient&amp;lt; &amp;quot;mapname&amp;quot; &amp;gt; }&lt;br /&gt;
&lt;br /&gt;
This material would automatically search for a MegaTexture called {{filename|mapname.mega}} in the {{filename|/megatextures/}} folder. This example material uses the ''&amp;quot;default_ambient&amp;quot;'' 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]].&lt;br /&gt;
&lt;br /&gt;
Obviously you would want to use the actual name of your map instead of &amp;quot;mapname&amp;quot;, for consistency's sake and ease of reference.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Assigning the material ===&lt;br /&gt;
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).&lt;br /&gt;
Tips on this process can be found in the [[A Simple First Terrain|simple first terrain tutorial]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Creating the Surface Tree ==&lt;br /&gt;
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 &amp;quot;Save and Unload&amp;quot; button in the Terrain Editor.&lt;br /&gt;
[[Image:simplemega_terrainmodel.png|thumb|300px|Root node set up to use the correct terrain mesh]]&lt;br /&gt;
&lt;br /&gt;
=== Add the terrain mesh ===&lt;br /&gt;
Here's how you bring the terrain mesh into the surface tree:&lt;br /&gt;
* {{accelbtn|RMB}} on the left-hand pane, and choose ''New -&amp;gt; Tree'' via the menu.&lt;br /&gt;
** If you already have a Root node, click the &amp;quot;Begin Editing&amp;quot; button instead.&lt;br /&gt;
* Click on the Root node, and set {{keyname|Model}} to the name of the terrain mesh, in this case {{keyvalue|models/terrain/simpleterrain.obj}}.&lt;br /&gt;
* Press {{accelkey|enter}} to confirm the selection, and the terrain should appear in the 3D view.&lt;br /&gt;
&lt;br /&gt;
Be aware that your terrain model will probably appear bright orange or red.&lt;br /&gt;
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!&lt;br /&gt;
&lt;br /&gt;
=== Important note about nodes ===&lt;br /&gt;
When you are editing properties of nodes (names, numbers, texture sources etc.) always remember to hit {{accelkey|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 {{accelkey|enter}}, your changes may not be applied.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Create the first texture node ==&lt;br /&gt;
[[Image:simplemega_firstnode_diffuse.png|thumb|300px|The first texture node's diffuse texture properties]]&lt;br /&gt;
Now that the model is in place, you can start laying down the texture layers (or &amp;quot;nodes&amp;quot;) that will make up your MegaTexture.&lt;br /&gt;
&lt;br /&gt;
First you need to create a new Image Source node in the Terrain Editor.&lt;br /&gt;
* {{accelbtn|RMB}} on your &amp;quot;Root&amp;quot; node and choose ''New -&amp;gt; Image Source'' (or press {{accelkey|shift}}{{accelkey|i}})&lt;br /&gt;
* This will make a new node called &amp;quot;New Image Renderer&amp;quot;.&lt;br /&gt;
* You can rename this new node using the &amp;quot;Name&amp;quot; property field in the '''Object''' section.&lt;br /&gt;
* Rename the node &amp;quot;Dirt&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
You will notice in the top right of the Terrain Editor, a section listing things like &amp;quot;Diffuse&amp;quot;, &amp;quot;Distribution&amp;quot;, &amp;quot;Distribution Pattern&amp;quot; etc. Selecting one of these will list all of the properties for that section of the current node.&lt;br /&gt;
The ones we need to worry about are as follows:&lt;br /&gt;
&lt;br /&gt;
=== Diffuse ===&lt;br /&gt;
This is the colour map of the current node, and it should point to a tiling TGA texture.&lt;br /&gt;
* Make sure the Diffuse section is highlighted in the top right of the Terrain Editor.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to a generic tiling dirt texture. Remember to hit {{accelkey|enter}} afterwards!&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/dirt_02_d.tga}}&lt;br /&gt;
* The {{keyname|Scale}} field at the very bottom of the property list allows you to choose how much to tile the texture.&lt;br /&gt;
** 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!&lt;br /&gt;
** 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.&lt;br /&gt;
That's all you need to do for the Diffuse settings in this node.&lt;br /&gt;
&lt;br /&gt;
=== Distribution ===&lt;br /&gt;
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''.&lt;br /&gt;
* Make sure the Distribution section is highlighted in the top right.&lt;br /&gt;
* Since this is our first node, we want to show over the whole terrain. This means the distribution map should be 100% white.&lt;br /&gt;
* You can either assign a pure white TGA texture, or change the {{keyname|Source Type}} to {{keyvalue|geometryBased}}.&lt;br /&gt;
** {{keyvalue|geometryBased}} will by default create a fully white map, so if you don't have a white TGA handy, this is faster.&lt;br /&gt;
&lt;br /&gt;
=== Distribution Pattern ===&lt;br /&gt;
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.&lt;br /&gt;
* 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!&lt;br /&gt;
&lt;br /&gt;
=== Local ===&lt;br /&gt;
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.&lt;br /&gt;
* Make sure the Local section is highlighted in the top right.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching normal map for your tiling dirt texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/dirt_02_local.tga}}&lt;br /&gt;
* The Local texture's tiling amount is automatically the same as the Diffuse texture.&lt;br /&gt;
&lt;br /&gt;
=== Surface Type ===&lt;br /&gt;
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.&lt;br /&gt;
* Find the ''Surface Type Properties'' section of the property list.&lt;br /&gt;
* 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.&lt;br /&gt;
* Hit {{accelkey|enter}} to accept the surface type.&lt;br /&gt;
&lt;br /&gt;
Your dirt textures will now produce correct &amp;quot;dirt&amp;quot; effects when shot or collided with!&lt;br /&gt;
&lt;br /&gt;
=== Previewing the result ===&lt;br /&gt;
[[Image:simplemega_firstnode_preview.jpg|thumb|300px|The Render mode preview of the first node]]&lt;br /&gt;
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]]&lt;br /&gt;
&lt;br /&gt;
* Notice the drop-down arrow on the right of the button. Click it, and select ''&amp;quot;Full&amp;quot;'' instead of ''&amp;quot;None&amp;quot;''.&lt;br /&gt;
* Your terrain should change colour to black. This means it's ready for a preview to be rendered onto it.&lt;br /&gt;
* Click the button itself now, instead of the drop-down. An &amp;quot;Active Tasks&amp;quot; window should pop up, and when it's done, you should see your dirt texture appear on your terrain model.&lt;br /&gt;
* You can switch the camera to Render mode too, which will show your terrain model's shading better.&lt;br /&gt;
* If you want a full-resolution preview of a small area, choose ''&amp;quot;Window&amp;quot;'' instead of ''&amp;quot;Full&amp;quot;'' from the drop-down menu.&lt;br /&gt;
** 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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
'''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.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
== Adding a second node ==&lt;br /&gt;
Now that the first layer of dirt is in place, we can try putting some grass on top of it!&lt;br /&gt;
* Again, {{accelbtn|RMB}} on your &amp;quot;Root&amp;quot; node and choose ''New -&amp;gt; Image Source'' (or press {{accelkey|shift}}{{accelkey|i}})&lt;br /&gt;
* This will make another new node below your &amp;quot;Dirt&amp;quot; node. &lt;br /&gt;
* Name this new node &amp;quot;Grass&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Again, the main map types need to be specified before the node can be rendered:&lt;br /&gt;
&lt;br /&gt;
=== Diffuse ===&lt;br /&gt;
* Make sure the Diffuse section is highlighted in the top right of the Terrain Editor.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to a generic tiling grass texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/grass_04_d.tga}}&lt;br /&gt;
* 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.&lt;br /&gt;
&lt;br /&gt;
=== Distribution ===&lt;br /&gt;
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!&lt;br /&gt;
* Make sure the Distribution section is highlighted in the top right.&lt;br /&gt;
* Change the {{keyname|Source Type}} from {{keyvalue|texture}} to {{keyvalue|geometryBased}}.&lt;br /&gt;
&lt;br /&gt;
=== Geometric Texture Distribution ===&lt;br /&gt;
[[Image:simplemega_geometric_distribution.png|thumb|300px|The geometric texture distribution settings of the second node]]&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
* ''Altitude Lower'' - Enabling this will limit the lower parts of the terrain from receiving this node's textures.&lt;br /&gt;
** {{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.&lt;br /&gt;
** {{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.&lt;br /&gt;
* ''Altitude Upper'' - Enabling this will limit the higher parts of the terrain from receiving this node's textures.&lt;br /&gt;
** {{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.&lt;br /&gt;
** {{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.&lt;br /&gt;
&lt;br /&gt;
* {{keyname|Clamp Distribution To Edge}} - Leave this on Default.&lt;br /&gt;
&lt;br /&gt;
* {{keyname|Resolution}} - The size in pixels of the resulting mask. The default value of {{keyvalue|256}} is fine for nearly any terrain model.&lt;br /&gt;
&lt;br /&gt;
* ''Slope Lower'' - Enabling this will limit shallower angles of the terrain model from receiving this node's textures.&lt;br /&gt;
** {{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.&lt;br /&gt;
** {{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.&lt;br /&gt;
* ''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.&lt;br /&gt;
** {{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.&lt;br /&gt;
** {{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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
=== Distribution Pattern ===&lt;br /&gt;
[[Image:simplemega_dist_ramps.jpg|thumb|300px|The difference between using or not using a Distribution Pattern, and varying Ramp Widths]]&lt;br /&gt;
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!&lt;br /&gt;
So what we want here is a texture to identify the &amp;quot;height&amp;quot; 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.&lt;br /&gt;
&lt;br /&gt;
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!&lt;br /&gt;
&lt;br /&gt;
* Make sure {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching heightmap or mask for your tiling grass texture.&lt;br /&gt;
** This example is using {{filename|textures/megagen/temperate/grass_04_mask.tga}}&lt;br /&gt;
* 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 &amp;quot;Window&amp;quot; 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.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
=== Local ===&lt;br /&gt;
Again we want the normal-map which matches the diffuse texture for the grass.&lt;br /&gt;
* Make sure the Local section is highlighted in the top right.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching normal map for your tiling grass texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/grass_04_local.tga}}&lt;br /&gt;
&lt;br /&gt;
=== Surface Type ===&lt;br /&gt;
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.&lt;br /&gt;
* Find the ''Surface Type Properties'' section of the property list.&lt;br /&gt;
* 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.&lt;br /&gt;
* Hit {{accelkey|enter}} to accept the surface type.&lt;br /&gt;
&lt;br /&gt;
Your grass textures should now produce correct &amp;quot;grass&amp;quot; effects when shot or collided with!&lt;br /&gt;
&lt;br /&gt;
=== Preview ===&lt;br /&gt;
[[Image:simplemega_secondnode_preview.jpg|thumb|300px|The Render mode preview of the second node blended with the first node]]&lt;br /&gt;
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.&lt;br /&gt;
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.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
== Adding a third node ==&lt;br /&gt;
[[Image:simplemega_thirdnode_preview.jpg|thumb|300px|The Render mode preview of the third node blended with the other two nodes]]&lt;br /&gt;
Now that the grass and dirt are in place, we need some rocks to make the terrain look more natural.&lt;br /&gt;
* Add a new Image Renderer node below your &amp;quot;Grass&amp;quot; node and name it &amp;quot;Rock&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Again, the main map types need to be specified before the node can be rendered:&lt;br /&gt;
&lt;br /&gt;
=== Diffuse ===&lt;br /&gt;
* Set the '''Diffuse''' texture and scale.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/rock_01_d.tga}} at a scale of {{keyvalue|32 32}}&lt;br /&gt;
&lt;br /&gt;
=== Distribution ===&lt;br /&gt;
Again we can use Geometric Texture Distribution to easily apply the rock textures only to the cliff-like angles.&lt;br /&gt;
* Make sure the Distribution section is highlighted in the top right.&lt;br /&gt;
* Change the {{keyname|Source Type}} to {{keyvalue|geometryBased}}.&lt;br /&gt;
* 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}}&lt;br /&gt;
&lt;br /&gt;
=== Distribution Pattern ===&lt;br /&gt;
Again this will control how the the rocks blend into the other nodes. Again, we want a texture to identify the &amp;quot;height&amp;quot; of the tiling rock texture.&lt;br /&gt;
&lt;br /&gt;
* Make sure the Distribution Pattern section is highlighted in the top right.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching heightmap or mask for your tiling rock texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/rock_01_h.tga}}&lt;br /&gt;
* 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 &amp;quot;Window&amp;quot; preview to see how the blending looks.&lt;br /&gt;
* Remember to set the {{keyname|Distribution Pattern Texture Scale}} to the same value as the Diffuse Scale, {{keyvalue|32 32}}.&lt;br /&gt;
&lt;br /&gt;
=== Local ===&lt;br /&gt;
Again we want the normal-map which matches the diffuse texture for the rocks.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Local''' section, browse to the matching normal map for your tiling rock texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/rock_01_local.tga}}&lt;br /&gt;
&lt;br /&gt;
=== Surface Type ===&lt;br /&gt;
* Find the ''Surface Type Properties'' section of the property list.&lt;br /&gt;
* In the {{keyname|Type}} field, enter {{keyvalue|stone}}.&lt;br /&gt;
* Hit {{accelkey|enter}} to accept the surface type.&lt;br /&gt;
&lt;br /&gt;
Your rock textures should now produce correct &amp;quot;stone&amp;quot; effects when shot or collided with.&lt;br /&gt;
&lt;br /&gt;
=== Preview ===&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Further tweaks ==&lt;br /&gt;
There are other simple changes that can be done in the Terrain Editor to make your MegaTexture look even better.&lt;br /&gt;
&lt;br /&gt;
=== Node order ===&lt;br /&gt;
[Image:simplemega_node_order.png|frame|Click and drag a node to change the order]]&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
* {{accelbtn|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.&lt;br /&gt;
* Release {{accelbtn|LMB}} when you have positioned the node in the correct place.&lt;br /&gt;
* 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!&lt;br /&gt;
&lt;br /&gt;
=== Color changes ====&lt;br /&gt;
Maybe your dirt texture is too bright? Or maybe your grass looks a little ''too'' green?&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Let's say you want to make the dirt texture darker and a bit more red. Here's how you'd do it:&lt;br /&gt;
* Select your Dirt node.&lt;br /&gt;
* 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).&lt;br /&gt;
* A color wheel and brightness slider will pop up in a new window. You can use this to darken and tint your texture.&lt;br /&gt;
* Choose a darker brightness, and a color slightly towards red. I used '''RGB Values''' of 225, 220, 220.&lt;br /&gt;
* Hit ''OK'' to accept the color.&lt;br /&gt;
* Re-render your MegaTexture preview. You should notice that the dirt layer looks darker now!&lt;br /&gt;
&lt;br /&gt;
=== Texture rotation ===&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
An easy way to overcome this is to play with the {{keyvname|Rotation}} value in the Texture Properties section of the Terrain Editor's property list.&lt;br /&gt;
For each node, you should also set the {{keyvname|Distribution Pattern Texture Rotation}} to match the Rotation value if you want your distribution patterns to line up and work correctly.&lt;br /&gt;
&lt;br /&gt;
== Render the MegaTexture ==&lt;br /&gt;
=== Save the Surface Tree ===&lt;br /&gt;
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 &amp;quot;Save and Unload&amp;quot; button in the Terrain Editor, or save the whole map.&lt;br /&gt;
&lt;br /&gt;
=== Compile Only Entities ===&lt;br /&gt;
At this stage, your MegaTexture material is still technically &amp;quot;broken&amp;quot;, 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.&lt;br /&gt;
&lt;br /&gt;
However, we need to compile the map in order to tell the [[renderLight]] process which atmosphere to use when lighting the MegaTexture!&lt;br /&gt;
&lt;br /&gt;
So the solution is to do an '''Only Entities''' compile. You can find this in the menu ''Compile -&amp;gt; 2 - Only Entities'' in editWorld. This should be done in a few seconds, and compiles all the information that renderLight needs.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Run the SDK Launcher ===&lt;br /&gt;
Now that your ''.sft'' is saved, go through all the steps outlined in the [[Generate a MegaTexture]] tutorial.&lt;br /&gt;
&lt;br /&gt;
== That's it! ==&lt;br /&gt;
[[Image:simplemega_ingame.jpg|thumb|300px|The MegaTexture in-game!]]&lt;br /&gt;
You've now created your very own MegaTexture to use in your map!&lt;br /&gt;
&lt;br /&gt;
Before you even compile the map, you can get an accurate preview of how it will look in-game by pressing {{accelkey|F6}} to toggle &amp;quot;anim&amp;quot; mode while in editWorld's &amp;quot;RENDER&amp;quot; Camera view (toggled with {{accelkey|F3}}).&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
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:&lt;br /&gt;
* 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.&lt;br /&gt;
* 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 ''&amp;lt; &amp;quot;mapname&amp;quot; &amp;gt;'' part described in [[A Simple First Megatexture#Creating a MegaTexture material|this section]]), otherwise it will not be searching for the correct images.&lt;br /&gt;
* 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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
* [[An Advanced Terrain and Megatexture]] - an advanced guide for complete MegaTexture creation&lt;br /&gt;
* [[Generate a MegaTexture]] - steps for generating a MegaTexture from the SDK launcher.&lt;br /&gt;
* [http://community.enemyterritory.com/forums/showthread.php?t=19326 Forum Thread] - includes textures to download&lt;br /&gt;
&lt;br /&gt;
[[Category:Art]]&lt;br /&gt;
[[Category:Basic Level Design]]&lt;br /&gt;
[[Category:Tutorials]]&lt;/div&gt;</summary>
		<author><name>Ducks</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.splashdamage.com/index.php?title=A_Simple_First_Megatexture&amp;diff=4059</id>
		<title>A Simple First Megatexture</title>
		<link rel="alternate" type="text/html" href="https://wiki.splashdamage.com/index.php?title=A_Simple_First_Megatexture&amp;diff=4059"/>
		<updated>2007-12-17T15:11:57Z</updated>

		<summary type="html">&lt;p&gt;Ducks: /* Adding a third node */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Image:simplemega_ingame.jpg|right|thumb|500px|A simple MegaTexture, easily created with only 3 texture layers!]]&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
'''For this tutorial you must:'''&lt;br /&gt;
* Have a terrain model UV-mapped in the 0-1 range (covered in the simple first terrain tutorial)&lt;br /&gt;
* Have access to some tiling textures.&lt;br /&gt;
* Have a little understanding the ETQW material system&lt;br /&gt;
&lt;br /&gt;
If you don't have any of the above things, you are not ready to do this tutorial!&lt;br /&gt;
&lt;br /&gt;
'''This tutorial covers:'''&lt;br /&gt;
* How to set up a MegaTexture material&lt;br /&gt;
* How to create a Surface Tree&lt;br /&gt;
* How to add texture nodes in the Terrain Editor&lt;br /&gt;
* How to render and compile a full MegaTexture&lt;br /&gt;
&lt;br /&gt;
'''This tutorial does not cover:'''&lt;br /&gt;
* How to use Blender/Maya/Lightwave/ZBrush/Mudbox/3DSMax/Photoshop&lt;br /&gt;
* How to create tiling textures or heightmaps&lt;br /&gt;
* Anything overly complicated&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Creating a MegaTexture material ==&lt;br /&gt;
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:&lt;br /&gt;
 material megatextures/mapname		{ useTemplate megatextures/default_ambient&amp;lt; &amp;quot;mapname&amp;quot; &amp;gt; }&lt;br /&gt;
&lt;br /&gt;
This material would automatically search for a MegaTexture called {{filename|mapname.mega}} in the {{filename|/megatextures/}} folder. This example material uses the ''&amp;quot;default_ambient&amp;quot;'' 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]].&lt;br /&gt;
&lt;br /&gt;
Obviously you would want to use the actual name of your map instead of &amp;quot;mapname&amp;quot;, for consistency's sake and ease of reference.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Assigning the material ===&lt;br /&gt;
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).&lt;br /&gt;
Tips on this process can be found in the [[A Simple First Terrain|simple first terrain tutorial]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Creating the Surface Tree ==&lt;br /&gt;
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 &amp;quot;Save and Unload&amp;quot; button in the Terrain Editor.&lt;br /&gt;
[[Image:simplemega_terrainmodel.png|thumb|300px|Root node set up to use the correct terrain mesh]]&lt;br /&gt;
&lt;br /&gt;
=== Add the terrain mesh ===&lt;br /&gt;
Here's how you bring the terrain mesh into the surface tree:&lt;br /&gt;
* {{accelbtn|RMB}} on the left-hand pane, and choose ''New -&amp;gt; Tree'' via the menu.&lt;br /&gt;
** If you already have a Root node, click the &amp;quot;Begin Editing&amp;quot; button instead.&lt;br /&gt;
* Click on the Root node, and set {{keyname|Model}} to the name of the terrain mesh, in this case {{keyvalue|models/terrain/simpleterrain.obj}}.&lt;br /&gt;
* Press {{accelkey|enter}} to confirm the selection, and the terrain should appear in the 3D view.&lt;br /&gt;
&lt;br /&gt;
Be aware that your terrain model will probably appear bright orange or red.&lt;br /&gt;
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!&lt;br /&gt;
&lt;br /&gt;
=== Important note about nodes ===&lt;br /&gt;
When you are editing properties of nodes (names, numbers, texture sources etc.) always remember to hit {{accelkey|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 {{accelkey|enter}}, your changes may not be applied.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Create the first texture node ==&lt;br /&gt;
[[Image:simplemega_firstnode_diffuse.png|thumb|300px|The first texture node's diffuse texture properties]]&lt;br /&gt;
Now that the model is in place, you can start laying down the texture layers (or &amp;quot;nodes&amp;quot;) that will make up your MegaTexture.&lt;br /&gt;
&lt;br /&gt;
First you need to create a new Image Source node in the Terrain Editor.&lt;br /&gt;
* {{accelbtn|RMB}} on your &amp;quot;Root&amp;quot; node and choose ''New -&amp;gt; Image Source'' (or press {{accelkey|shift}}{{accelkey|i}})&lt;br /&gt;
* This will make a new node called &amp;quot;New Image Renderer&amp;quot;.&lt;br /&gt;
* You can rename this new node using the &amp;quot;Name&amp;quot; property field in the '''Object''' section.&lt;br /&gt;
* Rename the node &amp;quot;Dirt&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
You will notice in the top right of the Terrain Editor, a section listing things like &amp;quot;Diffuse&amp;quot;, &amp;quot;Distribution&amp;quot;, &amp;quot;Distribution Pattern&amp;quot; etc. Selecting one of these will list all of the properties for that section of the current node.&lt;br /&gt;
The ones we need to worry about are as follows:&lt;br /&gt;
&lt;br /&gt;
=== Diffuse ===&lt;br /&gt;
This is the colour map of the current node, and it should point to a tiling TGA texture.&lt;br /&gt;
* Make sure the Diffuse section is highlighted in the top right of the Terrain Editor.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to a generic tiling dirt texture. Remember to hit {{accelkey|enter}} afterwards!&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/dirt_02_d.tga}}&lt;br /&gt;
* The {{keyname|Scale}} field at the very bottom of the property list allows you to choose how much to tile the texture.&lt;br /&gt;
** 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!&lt;br /&gt;
** 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.&lt;br /&gt;
That's all you need to do for the Diffuse settings in this node.&lt;br /&gt;
&lt;br /&gt;
=== Distribution ===&lt;br /&gt;
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''.&lt;br /&gt;
* Make sure the Distribution section is highlighted in the top right.&lt;br /&gt;
* Since this is our first node, we want to show over the whole terrain. This means the distribution map should be 100% white.&lt;br /&gt;
* You can either assign a pure white TGA texture, or change the {{keyname|Source Type}} to {{keyvalue|geometryBased}}.&lt;br /&gt;
** {{keyvalue|geometryBased}} will by default create a fully white map, so if you don't have a white TGA handy, this is faster.&lt;br /&gt;
&lt;br /&gt;
=== Distribution Pattern ===&lt;br /&gt;
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.&lt;br /&gt;
* 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!&lt;br /&gt;
&lt;br /&gt;
=== Local ===&lt;br /&gt;
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.&lt;br /&gt;
* Make sure the Local section is highlighted in the top right.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching normal map for your tiling dirt texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/dirt_02_local.tga}}&lt;br /&gt;
* The Local texture's tiling amount is automatically the same as the Diffuse texture.&lt;br /&gt;
&lt;br /&gt;
=== Surface Type ===&lt;br /&gt;
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.&lt;br /&gt;
* Find the ''Surface Type Properties'' section of the property list.&lt;br /&gt;
* 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.&lt;br /&gt;
* Hit {{accelkey|enter}} to accept the surface type.&lt;br /&gt;
&lt;br /&gt;
Your dirt textures will now produce correct &amp;quot;dirt&amp;quot; effects when shot or collided with!&lt;br /&gt;
&lt;br /&gt;
=== Previewing the result ===&lt;br /&gt;
[[Image:simplemega_firstnode_preview.jpg|thumb|300px|The Render mode preview of the first node]]&lt;br /&gt;
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]]&lt;br /&gt;
&lt;br /&gt;
* Notice the drop-down arrow on the right of the button. Click it, and select ''&amp;quot;Full&amp;quot;'' instead of ''&amp;quot;None&amp;quot;''.&lt;br /&gt;
* Your terrain should change colour to black. This means it's ready for a preview to be rendered onto it.&lt;br /&gt;
* Click the button itself now, instead of the drop-down. An &amp;quot;Active Tasks&amp;quot; window should pop up, and when it's done, you should see your dirt texture appear on your terrain model.&lt;br /&gt;
* You can switch the camera to Render mode too, which will show your terrain model's shading better.&lt;br /&gt;
* If you want a full-resolution preview of a small area, choose ''&amp;quot;Window&amp;quot;'' instead of ''&amp;quot;Full&amp;quot;'' from the drop-down menu.&lt;br /&gt;
** 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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
'''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.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
== Adding a second node ==&lt;br /&gt;
Now that the first layer of dirt is in place, we can try putting some grass on top of it!&lt;br /&gt;
* Again, {{accelbtn|RMB}} on your &amp;quot;Root&amp;quot; node and choose ''New -&amp;gt; Image Source'' (or press {{accelkey|shift}}{{accelkey|i}})&lt;br /&gt;
* This will make another new node below your &amp;quot;Dirt&amp;quot; node. &lt;br /&gt;
* Name this new node &amp;quot;Grass&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Again, the main map types need to be specified before the node can be rendered:&lt;br /&gt;
&lt;br /&gt;
=== Diffuse ===&lt;br /&gt;
* Make sure the Diffuse section is highlighted in the top right of the Terrain Editor.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to a generic tiling grass texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/grass_04_d.tga}}&lt;br /&gt;
* 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.&lt;br /&gt;
&lt;br /&gt;
=== Distribution ===&lt;br /&gt;
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!&lt;br /&gt;
* Make sure the Distribution section is highlighted in the top right.&lt;br /&gt;
* Change the {{keyname|Source Type}} from {{keyvalue|texture}} to {{keyvalue|geometryBased}}.&lt;br /&gt;
&lt;br /&gt;
=== Geometric Texture Distribution ===&lt;br /&gt;
[[Image:simplemega_geometric_distribution.png|thumb|300px|The geometric texture distribution settings of the second node]]&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
* ''Altitude Lower'' - Enabling this will limit the lower parts of the terrain from receiving this node's textures.&lt;br /&gt;
** {{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.&lt;br /&gt;
** {{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.&lt;br /&gt;
* ''Altitude Upper'' - Enabling this will limit the higher parts of the terrain from receiving this node's textures.&lt;br /&gt;
** {{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.&lt;br /&gt;
** {{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.&lt;br /&gt;
&lt;br /&gt;
* {{keyname|Clamp Distribution To Edge}} - Leave this on Default.&lt;br /&gt;
&lt;br /&gt;
* {{keyname|Resolution}} - The size in pixels of the resulting mask. The default value of {{keyvalue|256}} is fine for nearly any terrain model.&lt;br /&gt;
&lt;br /&gt;
* ''Slope Lower'' - Enabling this will limit shallower angles of the terrain model from receiving this node's textures.&lt;br /&gt;
** {{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.&lt;br /&gt;
** {{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.&lt;br /&gt;
* ''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.&lt;br /&gt;
** {{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.&lt;br /&gt;
** {{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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
=== Distribution Pattern ===&lt;br /&gt;
[[Image:simplemega_dist_ramps.jpg|thumb|300px|The difference between using or not using a Distribution Pattern, and varying Ramp Widths]]&lt;br /&gt;
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!&lt;br /&gt;
So what we want here is a texture to identify the &amp;quot;height&amp;quot; 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.&lt;br /&gt;
&lt;br /&gt;
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!&lt;br /&gt;
&lt;br /&gt;
* Make sure {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching heightmap or mask for your tiling grass texture.&lt;br /&gt;
** This example is using {{filename|textures/megagen/temperate/grass_04_mask.tga}}&lt;br /&gt;
* 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 &amp;quot;Window&amp;quot; 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.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
=== Local ===&lt;br /&gt;
Again we want the normal-map which matches the diffuse texture for the grass.&lt;br /&gt;
* Make sure the Local section is highlighted in the top right.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching normal map for your tiling grass texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/grass_04_local.tga}}&lt;br /&gt;
&lt;br /&gt;
=== Surface Type ===&lt;br /&gt;
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.&lt;br /&gt;
* Find the ''Surface Type Properties'' section of the property list.&lt;br /&gt;
* 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.&lt;br /&gt;
* Hit {{accelkey|enter}} to accept the surface type.&lt;br /&gt;
&lt;br /&gt;
Your grass textures should now produce correct &amp;quot;grass&amp;quot; effects when shot or collided with!&lt;br /&gt;
&lt;br /&gt;
=== Preview ===&lt;br /&gt;
[[Image:simplemega_secondnode_preview.jpg|thumb|300px|The Render mode preview of the second node blended with the first node]]&lt;br /&gt;
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.&lt;br /&gt;
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.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
== Adding a third node ==&lt;br /&gt;
[[Image:simplemega_thirdnode_preview.jpg|thumb|300px|The Render mode preview of the third node blended with the other two nodes]]&lt;br /&gt;
Now that the grass and dirt are in place, we need some rocks to make the terrain look more natural.&lt;br /&gt;
* Add a new Image Renderer node below your &amp;quot;Grass&amp;quot; node and name it &amp;quot;Rock&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Again, the main map types need to be specified before the node can be rendered:&lt;br /&gt;
&lt;br /&gt;
=== Diffuse ===&lt;br /&gt;
* Set the '''Diffuse''' texture and scale.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/rock_01_d.tga}} at a scale of {{keyvalue|32 32}}&lt;br /&gt;
&lt;br /&gt;
=== Distribution ===&lt;br /&gt;
Again we can use Geometric Texture Distribution to easily apply the rock textures only to the cliff-like angles.&lt;br /&gt;
* Make sure the Distribution section is highlighted in the top right.&lt;br /&gt;
* Change the {{keyname|Source Type}} to {{keyvalue|geometryBased}}.&lt;br /&gt;
* 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}}&lt;br /&gt;
&lt;br /&gt;
=== Distribution Pattern ===&lt;br /&gt;
Again this will control how the the rocks blend into the other nodes. Again, we want a texture to identify the &amp;quot;height&amp;quot; of the tiling rock texture.&lt;br /&gt;
&lt;br /&gt;
* Make sure the Distribution Pattern section is highlighted in the top right.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching heightmap or mask for your tiling rock texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/rock_01_h.tga}}&lt;br /&gt;
* 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 &amp;quot;Window&amp;quot; preview to see how the blending looks.&lt;br /&gt;
* Remember to set the {{keyname|Distribution Pattern Texture Scale}} to the same value as the Diffuse Scale, {{keyvalue|32 32}}.&lt;br /&gt;
&lt;br /&gt;
=== Local ===&lt;br /&gt;
Again we want the normal-map which matches the diffuse texture for the rocks.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Local''' section, browse to the matching normal map for your tiling rock texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/rock_01_local.tga}}&lt;br /&gt;
&lt;br /&gt;
=== Surface Type ===&lt;br /&gt;
* Find the ''Surface Type Properties'' section of the property list.&lt;br /&gt;
* In the {{keyname|Type}} field, enter {{keyvalue|stone}}.&lt;br /&gt;
* Hit {{accelkey|enter}} to accept the surface type.&lt;br /&gt;
&lt;br /&gt;
Your rock textures should now produce correct &amp;quot;stone&amp;quot; effects when shot or collided with.&lt;br /&gt;
&lt;br /&gt;
=== Preview ===&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Further tweaks ==&lt;br /&gt;
There are other simple changes that can be done in the Terrain Editor to make your MegaTexture look even better.&lt;br /&gt;
&lt;br /&gt;
==== Node order ====&lt;br /&gt;
[Image:simplemega_node_order.png|frame|Click and drag a node to change the order]]&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
* {{accelbtn|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.&lt;br /&gt;
* Release {{accelbtn|LMB}} when you have positioned the node in the correct place.&lt;br /&gt;
* 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!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Color changes ==== &lt;br /&gt;
Maybe your dirt texture is too bright? Or maybe your grass looks a little ''too'' green?&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Let's say you want to make the dirt texture darker and a bit more red. Here's how you'd do it:&lt;br /&gt;
* Select your Dirt node.&lt;br /&gt;
* 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).&lt;br /&gt;
* A color wheel and brightness slider will pop up in a new window. You can use this to darken and tint your texture.&lt;br /&gt;
* Choose a darker brightness, and a color slightly towards red. I used '''RGB Values''' of 225, 220, 220.&lt;br /&gt;
* Hit ''OK'' to accept the color.&lt;br /&gt;
* Re-render your MegaTexture preview. You should notice that the dirt layer looks darker now!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Texture rotation ====&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
An easy way to overcome this is to play with the {{keyvname|Rotation}} value in the Texture Properties section of the Terrain Editor's property list.&lt;br /&gt;
For each node, you should also set the {{keyvname|Distribution Pattern Texture Rotation}} to match the Rotation value if you want your distribution patterns to line up and work correctly.&lt;br /&gt;
&lt;br /&gt;
== Render the MegaTexture ==&lt;br /&gt;
=== Save the Surface Tree ===&lt;br /&gt;
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 &amp;quot;Save and Unload&amp;quot; button in the Terrain Editor, or save the whole map.&lt;br /&gt;
&lt;br /&gt;
=== Compile Only Entities ===&lt;br /&gt;
At this stage, your MegaTexture material is still technically &amp;quot;broken&amp;quot;, 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.&lt;br /&gt;
&lt;br /&gt;
However, we need to compile the map in order to tell the [[renderLight]] process which atmosphere to use when lighting the MegaTexture!&lt;br /&gt;
&lt;br /&gt;
So the solution is to do an '''Only Entities''' compile. You can find this in the menu ''Compile -&amp;gt; 2 - Only Entities'' in editWorld. This should be done in a few seconds, and compiles all the information that renderLight needs.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Run the SDK Launcher ===&lt;br /&gt;
Now that your ''.sft'' is saved, go through all the steps outlined in the [[Generate a MegaTexture]] tutorial.&lt;br /&gt;
&lt;br /&gt;
== That's it! ==&lt;br /&gt;
[[Image:simplemega_ingame.jpg|thumb|300px|The MegaTexture in-game!]]&lt;br /&gt;
You've now created your very own MegaTexture to use in your map!&lt;br /&gt;
&lt;br /&gt;
Before you even compile the map, you can get an accurate preview of how it will look in-game by pressing {{accelkey|F6}} to toggle &amp;quot;anim&amp;quot; mode while in editWorld's &amp;quot;RENDER&amp;quot; Camera view (toggled with {{accelkey|F3}}).&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
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:&lt;br /&gt;
* 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.&lt;br /&gt;
* 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 ''&amp;lt; &amp;quot;mapname&amp;quot; &amp;gt;'' part described in [[A Simple First Megatexture#Creating a MegaTexture material|this section]]), otherwise it will not be searching for the correct images.&lt;br /&gt;
* 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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
* [[An Advanced Terrain and Megatexture]] - an advanced guide for complete MegaTexture creation&lt;br /&gt;
* [[Generate a MegaTexture]] - steps for generating a MegaTexture from the SDK launcher.&lt;br /&gt;
* [http://community.enemyterritory.com/forums/showthread.php?t=19326 Forum Thread] - includes textures to download&lt;br /&gt;
&lt;br /&gt;
[[Category:Art]]&lt;br /&gt;
[[Category:Basic Level Design]]&lt;br /&gt;
[[Category:Tutorials]]&lt;/div&gt;</summary>
		<author><name>Ducks</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.splashdamage.com/index.php?title=A_Simple_First_Megatexture&amp;diff=4058</id>
		<title>A Simple First Megatexture</title>
		<link rel="alternate" type="text/html" href="https://wiki.splashdamage.com/index.php?title=A_Simple_First_Megatexture&amp;diff=4058"/>
		<updated>2007-12-17T15:11:49Z</updated>

		<summary type="html">&lt;p&gt;Ducks: /* Adding a third node */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Image:simplemega_ingame.jpg|right|thumb|500px|A simple MegaTexture, easily created with only 3 texture layers!]]&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
'''For this tutorial you must:'''&lt;br /&gt;
* Have a terrain model UV-mapped in the 0-1 range (covered in the simple first terrain tutorial)&lt;br /&gt;
* Have access to some tiling textures.&lt;br /&gt;
* Have a little understanding the ETQW material system&lt;br /&gt;
&lt;br /&gt;
If you don't have any of the above things, you are not ready to do this tutorial!&lt;br /&gt;
&lt;br /&gt;
'''This tutorial covers:'''&lt;br /&gt;
* How to set up a MegaTexture material&lt;br /&gt;
* How to create a Surface Tree&lt;br /&gt;
* How to add texture nodes in the Terrain Editor&lt;br /&gt;
* How to render and compile a full MegaTexture&lt;br /&gt;
&lt;br /&gt;
'''This tutorial does not cover:'''&lt;br /&gt;
* How to use Blender/Maya/Lightwave/ZBrush/Mudbox/3DSMax/Photoshop&lt;br /&gt;
* How to create tiling textures or heightmaps&lt;br /&gt;
* Anything overly complicated&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Creating a MegaTexture material ==&lt;br /&gt;
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:&lt;br /&gt;
 material megatextures/mapname		{ useTemplate megatextures/default_ambient&amp;lt; &amp;quot;mapname&amp;quot; &amp;gt; }&lt;br /&gt;
&lt;br /&gt;
This material would automatically search for a MegaTexture called {{filename|mapname.mega}} in the {{filename|/megatextures/}} folder. This example material uses the ''&amp;quot;default_ambient&amp;quot;'' 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]].&lt;br /&gt;
&lt;br /&gt;
Obviously you would want to use the actual name of your map instead of &amp;quot;mapname&amp;quot;, for consistency's sake and ease of reference.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Assigning the material ===&lt;br /&gt;
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).&lt;br /&gt;
Tips on this process can be found in the [[A Simple First Terrain|simple first terrain tutorial]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Creating the Surface Tree ==&lt;br /&gt;
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 &amp;quot;Save and Unload&amp;quot; button in the Terrain Editor.&lt;br /&gt;
[[Image:simplemega_terrainmodel.png|thumb|300px|Root node set up to use the correct terrain mesh]]&lt;br /&gt;
&lt;br /&gt;
=== Add the terrain mesh ===&lt;br /&gt;
Here's how you bring the terrain mesh into the surface tree:&lt;br /&gt;
* {{accelbtn|RMB}} on the left-hand pane, and choose ''New -&amp;gt; Tree'' via the menu.&lt;br /&gt;
** If you already have a Root node, click the &amp;quot;Begin Editing&amp;quot; button instead.&lt;br /&gt;
* Click on the Root node, and set {{keyname|Model}} to the name of the terrain mesh, in this case {{keyvalue|models/terrain/simpleterrain.obj}}.&lt;br /&gt;
* Press {{accelkey|enter}} to confirm the selection, and the terrain should appear in the 3D view.&lt;br /&gt;
&lt;br /&gt;
Be aware that your terrain model will probably appear bright orange or red.&lt;br /&gt;
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!&lt;br /&gt;
&lt;br /&gt;
=== Important note about nodes ===&lt;br /&gt;
When you are editing properties of nodes (names, numbers, texture sources etc.) always remember to hit {{accelkey|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 {{accelkey|enter}}, your changes may not be applied.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Create the first texture node ==&lt;br /&gt;
[[Image:simplemega_firstnode_diffuse.png|thumb|300px|The first texture node's diffuse texture properties]]&lt;br /&gt;
Now that the model is in place, you can start laying down the texture layers (or &amp;quot;nodes&amp;quot;) that will make up your MegaTexture.&lt;br /&gt;
&lt;br /&gt;
First you need to create a new Image Source node in the Terrain Editor.&lt;br /&gt;
* {{accelbtn|RMB}} on your &amp;quot;Root&amp;quot; node and choose ''New -&amp;gt; Image Source'' (or press {{accelkey|shift}}{{accelkey|i}})&lt;br /&gt;
* This will make a new node called &amp;quot;New Image Renderer&amp;quot;.&lt;br /&gt;
* You can rename this new node using the &amp;quot;Name&amp;quot; property field in the '''Object''' section.&lt;br /&gt;
* Rename the node &amp;quot;Dirt&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
You will notice in the top right of the Terrain Editor, a section listing things like &amp;quot;Diffuse&amp;quot;, &amp;quot;Distribution&amp;quot;, &amp;quot;Distribution Pattern&amp;quot; etc. Selecting one of these will list all of the properties for that section of the current node.&lt;br /&gt;
The ones we need to worry about are as follows:&lt;br /&gt;
&lt;br /&gt;
=== Diffuse ===&lt;br /&gt;
This is the colour map of the current node, and it should point to a tiling TGA texture.&lt;br /&gt;
* Make sure the Diffuse section is highlighted in the top right of the Terrain Editor.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to a generic tiling dirt texture. Remember to hit {{accelkey|enter}} afterwards!&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/dirt_02_d.tga}}&lt;br /&gt;
* The {{keyname|Scale}} field at the very bottom of the property list allows you to choose how much to tile the texture.&lt;br /&gt;
** 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!&lt;br /&gt;
** 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.&lt;br /&gt;
That's all you need to do for the Diffuse settings in this node.&lt;br /&gt;
&lt;br /&gt;
=== Distribution ===&lt;br /&gt;
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''.&lt;br /&gt;
* Make sure the Distribution section is highlighted in the top right.&lt;br /&gt;
* Since this is our first node, we want to show over the whole terrain. This means the distribution map should be 100% white.&lt;br /&gt;
* You can either assign a pure white TGA texture, or change the {{keyname|Source Type}} to {{keyvalue|geometryBased}}.&lt;br /&gt;
** {{keyvalue|geometryBased}} will by default create a fully white map, so if you don't have a white TGA handy, this is faster.&lt;br /&gt;
&lt;br /&gt;
=== Distribution Pattern ===&lt;br /&gt;
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.&lt;br /&gt;
* 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!&lt;br /&gt;
&lt;br /&gt;
=== Local ===&lt;br /&gt;
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.&lt;br /&gt;
* Make sure the Local section is highlighted in the top right.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching normal map for your tiling dirt texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/dirt_02_local.tga}}&lt;br /&gt;
* The Local texture's tiling amount is automatically the same as the Diffuse texture.&lt;br /&gt;
&lt;br /&gt;
=== Surface Type ===&lt;br /&gt;
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.&lt;br /&gt;
* Find the ''Surface Type Properties'' section of the property list.&lt;br /&gt;
* 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.&lt;br /&gt;
* Hit {{accelkey|enter}} to accept the surface type.&lt;br /&gt;
&lt;br /&gt;
Your dirt textures will now produce correct &amp;quot;dirt&amp;quot; effects when shot or collided with!&lt;br /&gt;
&lt;br /&gt;
=== Previewing the result ===&lt;br /&gt;
[[Image:simplemega_firstnode_preview.jpg|thumb|300px|The Render mode preview of the first node]]&lt;br /&gt;
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]]&lt;br /&gt;
&lt;br /&gt;
* Notice the drop-down arrow on the right of the button. Click it, and select ''&amp;quot;Full&amp;quot;'' instead of ''&amp;quot;None&amp;quot;''.&lt;br /&gt;
* Your terrain should change colour to black. This means it's ready for a preview to be rendered onto it.&lt;br /&gt;
* Click the button itself now, instead of the drop-down. An &amp;quot;Active Tasks&amp;quot; window should pop up, and when it's done, you should see your dirt texture appear on your terrain model.&lt;br /&gt;
* You can switch the camera to Render mode too, which will show your terrain model's shading better.&lt;br /&gt;
* If you want a full-resolution preview of a small area, choose ''&amp;quot;Window&amp;quot;'' instead of ''&amp;quot;Full&amp;quot;'' from the drop-down menu.&lt;br /&gt;
** 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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
'''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.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
== Adding a second node ==&lt;br /&gt;
Now that the first layer of dirt is in place, we can try putting some grass on top of it!&lt;br /&gt;
* Again, {{accelbtn|RMB}} on your &amp;quot;Root&amp;quot; node and choose ''New -&amp;gt; Image Source'' (or press {{accelkey|shift}}{{accelkey|i}})&lt;br /&gt;
* This will make another new node below your &amp;quot;Dirt&amp;quot; node. &lt;br /&gt;
* Name this new node &amp;quot;Grass&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Again, the main map types need to be specified before the node can be rendered:&lt;br /&gt;
&lt;br /&gt;
=== Diffuse ===&lt;br /&gt;
* Make sure the Diffuse section is highlighted in the top right of the Terrain Editor.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to a generic tiling grass texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/grass_04_d.tga}}&lt;br /&gt;
* 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.&lt;br /&gt;
&lt;br /&gt;
=== Distribution ===&lt;br /&gt;
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!&lt;br /&gt;
* Make sure the Distribution section is highlighted in the top right.&lt;br /&gt;
* Change the {{keyname|Source Type}} from {{keyvalue|texture}} to {{keyvalue|geometryBased}}.&lt;br /&gt;
&lt;br /&gt;
=== Geometric Texture Distribution ===&lt;br /&gt;
[[Image:simplemega_geometric_distribution.png|thumb|300px|The geometric texture distribution settings of the second node]]&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
* ''Altitude Lower'' - Enabling this will limit the lower parts of the terrain from receiving this node's textures.&lt;br /&gt;
** {{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.&lt;br /&gt;
** {{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.&lt;br /&gt;
* ''Altitude Upper'' - Enabling this will limit the higher parts of the terrain from receiving this node's textures.&lt;br /&gt;
** {{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.&lt;br /&gt;
** {{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.&lt;br /&gt;
&lt;br /&gt;
* {{keyname|Clamp Distribution To Edge}} - Leave this on Default.&lt;br /&gt;
&lt;br /&gt;
* {{keyname|Resolution}} - The size in pixels of the resulting mask. The default value of {{keyvalue|256}} is fine for nearly any terrain model.&lt;br /&gt;
&lt;br /&gt;
* ''Slope Lower'' - Enabling this will limit shallower angles of the terrain model from receiving this node's textures.&lt;br /&gt;
** {{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.&lt;br /&gt;
** {{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.&lt;br /&gt;
* ''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.&lt;br /&gt;
** {{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.&lt;br /&gt;
** {{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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
=== Distribution Pattern ===&lt;br /&gt;
[[Image:simplemega_dist_ramps.jpg|thumb|300px|The difference between using or not using a Distribution Pattern, and varying Ramp Widths]]&lt;br /&gt;
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!&lt;br /&gt;
So what we want here is a texture to identify the &amp;quot;height&amp;quot; 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.&lt;br /&gt;
&lt;br /&gt;
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!&lt;br /&gt;
&lt;br /&gt;
* Make sure {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching heightmap or mask for your tiling grass texture.&lt;br /&gt;
** This example is using {{filename|textures/megagen/temperate/grass_04_mask.tga}}&lt;br /&gt;
* 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 &amp;quot;Window&amp;quot; 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.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
=== Local ===&lt;br /&gt;
Again we want the normal-map which matches the diffuse texture for the grass.&lt;br /&gt;
* Make sure the Local section is highlighted in the top right.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching normal map for your tiling grass texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/grass_04_local.tga}}&lt;br /&gt;
&lt;br /&gt;
=== Surface Type ===&lt;br /&gt;
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.&lt;br /&gt;
* Find the ''Surface Type Properties'' section of the property list.&lt;br /&gt;
* 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.&lt;br /&gt;
* Hit {{accelkey|enter}} to accept the surface type.&lt;br /&gt;
&lt;br /&gt;
Your grass textures should now produce correct &amp;quot;grass&amp;quot; effects when shot or collided with!&lt;br /&gt;
&lt;br /&gt;
=== Preview ===&lt;br /&gt;
[[Image:simplemega_secondnode_preview.jpg|thumb|300px|The Render mode preview of the second node blended with the first node]]&lt;br /&gt;
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.&lt;br /&gt;
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.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
== Adding a third node ==&lt;br /&gt;
[[Image:simplemega_thirdnode_preview.jpg|thumb|300px|The Render mode preview of the third node blended with the other two nodes]]&lt;br /&gt;
Now that the grass and dirt are in place, we need some rocks to make the terrain look more natural.&lt;br /&gt;
* Add a new Image Renderer node below your &amp;quot;Grass&amp;quot; node and name it &amp;quot;Rock&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Again, the main map types need to be specified before the node can be rendered:&lt;br /&gt;
&lt;br /&gt;
=== Diffuse ===&lt;br /&gt;
* Set the '''Diffuse''' texture and scale.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/rock_01_d.tga}} at a scale of {{keyvalue|32 32}}&lt;br /&gt;
&lt;br /&gt;
=== Distribution ===&lt;br /&gt;
Again we can use Geometric Texture Distribution to easily apply the rock textures only to the cliff-like angles.&lt;br /&gt;
* Make sure the Distribution section is highlighted in the top right.&lt;br /&gt;
* Change the {{keyname|Source Type}} to {{keyvalue|geometryBased}}.&lt;br /&gt;
* 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}}&lt;br /&gt;
&lt;br /&gt;
=== Distribution Pattern ===&lt;br /&gt;
Again this will control how the the rocks blend into the other nodes. Again, we want a texture to identify the &amp;quot;height&amp;quot; of the tiling rock texture.&lt;br /&gt;
&lt;br /&gt;
* Make sure the Distribution Pattern section is highlighted in the top right.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching heightmap or mask for your tiling rock texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/rock_01_h.tga}}&lt;br /&gt;
* 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 &amp;quot;Window&amp;quot; preview to see how the blending looks.&lt;br /&gt;
* Remember to set the {{keyname|Distribution Pattern Texture Scale}} to the same value as the Diffuse Scale, {{keyvalue|32 32}}.&lt;br /&gt;
&lt;br /&gt;
=== Local ===&lt;br /&gt;
Again we want the normal-map which matches the diffuse texture for the rocks.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Local''' section, browse to the matching normal map for your tiling rock texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/rock_01_local.tga}}&lt;br /&gt;
&lt;br /&gt;
=== Surface Type ===&lt;br /&gt;
* Find the ''Surface Type Properties'' section of the property list.&lt;br /&gt;
* In the {{keyname|Type}} field, enter {{keyvalue|stone}}.&lt;br /&gt;
* Hit {{accelkey|enter}} to accept the surface type.&lt;br /&gt;
&lt;br /&gt;
Your rock textures should now produce correct &amp;quot;stone&amp;quot; effects when shot or collided with.&lt;br /&gt;
&lt;br /&gt;
=== Preview again! ===&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Further tweaks ==&lt;br /&gt;
There are other simple changes that can be done in the Terrain Editor to make your MegaTexture look even better.&lt;br /&gt;
&lt;br /&gt;
==== Node order ====&lt;br /&gt;
[Image:simplemega_node_order.png|frame|Click and drag a node to change the order]]&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
* {{accelbtn|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.&lt;br /&gt;
* Release {{accelbtn|LMB}} when you have positioned the node in the correct place.&lt;br /&gt;
* 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!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Color changes ==== &lt;br /&gt;
Maybe your dirt texture is too bright? Or maybe your grass looks a little ''too'' green?&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Let's say you want to make the dirt texture darker and a bit more red. Here's how you'd do it:&lt;br /&gt;
* Select your Dirt node.&lt;br /&gt;
* 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).&lt;br /&gt;
* A color wheel and brightness slider will pop up in a new window. You can use this to darken and tint your texture.&lt;br /&gt;
* Choose a darker brightness, and a color slightly towards red. I used '''RGB Values''' of 225, 220, 220.&lt;br /&gt;
* Hit ''OK'' to accept the color.&lt;br /&gt;
* Re-render your MegaTexture preview. You should notice that the dirt layer looks darker now!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Texture rotation ====&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
An easy way to overcome this is to play with the {{keyvname|Rotation}} value in the Texture Properties section of the Terrain Editor's property list.&lt;br /&gt;
For each node, you should also set the {{keyvname|Distribution Pattern Texture Rotation}} to match the Rotation value if you want your distribution patterns to line up and work correctly.&lt;br /&gt;
&lt;br /&gt;
== Render the MegaTexture ==&lt;br /&gt;
=== Save the Surface Tree ===&lt;br /&gt;
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 &amp;quot;Save and Unload&amp;quot; button in the Terrain Editor, or save the whole map.&lt;br /&gt;
&lt;br /&gt;
=== Compile Only Entities ===&lt;br /&gt;
At this stage, your MegaTexture material is still technically &amp;quot;broken&amp;quot;, 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.&lt;br /&gt;
&lt;br /&gt;
However, we need to compile the map in order to tell the [[renderLight]] process which atmosphere to use when lighting the MegaTexture!&lt;br /&gt;
&lt;br /&gt;
So the solution is to do an '''Only Entities''' compile. You can find this in the menu ''Compile -&amp;gt; 2 - Only Entities'' in editWorld. This should be done in a few seconds, and compiles all the information that renderLight needs.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Run the SDK Launcher ===&lt;br /&gt;
Now that your ''.sft'' is saved, go through all the steps outlined in the [[Generate a MegaTexture]] tutorial.&lt;br /&gt;
&lt;br /&gt;
== That's it! ==&lt;br /&gt;
[[Image:simplemega_ingame.jpg|thumb|300px|The MegaTexture in-game!]]&lt;br /&gt;
You've now created your very own MegaTexture to use in your map!&lt;br /&gt;
&lt;br /&gt;
Before you even compile the map, you can get an accurate preview of how it will look in-game by pressing {{accelkey|F6}} to toggle &amp;quot;anim&amp;quot; mode while in editWorld's &amp;quot;RENDER&amp;quot; Camera view (toggled with {{accelkey|F3}}).&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
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:&lt;br /&gt;
* 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.&lt;br /&gt;
* 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 ''&amp;lt; &amp;quot;mapname&amp;quot; &amp;gt;'' part described in [[A Simple First Megatexture#Creating a MegaTexture material|this section]]), otherwise it will not be searching for the correct images.&lt;br /&gt;
* 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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
* [[An Advanced Terrain and Megatexture]] - an advanced guide for complete MegaTexture creation&lt;br /&gt;
* [[Generate a MegaTexture]] - steps for generating a MegaTexture from the SDK launcher.&lt;br /&gt;
* [http://community.enemyterritory.com/forums/showthread.php?t=19326 Forum Thread] - includes textures to download&lt;br /&gt;
&lt;br /&gt;
[[Category:Art]]&lt;br /&gt;
[[Category:Basic Level Design]]&lt;br /&gt;
[[Category:Tutorials]]&lt;/div&gt;</summary>
		<author><name>Ducks</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.splashdamage.com/index.php?title=A_Simple_First_Megatexture&amp;diff=4057</id>
		<title>A Simple First Megatexture</title>
		<link rel="alternate" type="text/html" href="https://wiki.splashdamage.com/index.php?title=A_Simple_First_Megatexture&amp;diff=4057"/>
		<updated>2007-12-17T15:11:23Z</updated>

		<summary type="html">&lt;p&gt;Ducks: /* Create the first texture node */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Image:simplemega_ingame.jpg|right|thumb|500px|A simple MegaTexture, easily created with only 3 texture layers!]]&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
'''For this tutorial you must:'''&lt;br /&gt;
* Have a terrain model UV-mapped in the 0-1 range (covered in the simple first terrain tutorial)&lt;br /&gt;
* Have access to some tiling textures.&lt;br /&gt;
* Have a little understanding the ETQW material system&lt;br /&gt;
&lt;br /&gt;
If you don't have any of the above things, you are not ready to do this tutorial!&lt;br /&gt;
&lt;br /&gt;
'''This tutorial covers:'''&lt;br /&gt;
* How to set up a MegaTexture material&lt;br /&gt;
* How to create a Surface Tree&lt;br /&gt;
* How to add texture nodes in the Terrain Editor&lt;br /&gt;
* How to render and compile a full MegaTexture&lt;br /&gt;
&lt;br /&gt;
'''This tutorial does not cover:'''&lt;br /&gt;
* How to use Blender/Maya/Lightwave/ZBrush/Mudbox/3DSMax/Photoshop&lt;br /&gt;
* How to create tiling textures or heightmaps&lt;br /&gt;
* Anything overly complicated&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Creating a MegaTexture material ==&lt;br /&gt;
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:&lt;br /&gt;
 material megatextures/mapname		{ useTemplate megatextures/default_ambient&amp;lt; &amp;quot;mapname&amp;quot; &amp;gt; }&lt;br /&gt;
&lt;br /&gt;
This material would automatically search for a MegaTexture called {{filename|mapname.mega}} in the {{filename|/megatextures/}} folder. This example material uses the ''&amp;quot;default_ambient&amp;quot;'' 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]].&lt;br /&gt;
&lt;br /&gt;
Obviously you would want to use the actual name of your map instead of &amp;quot;mapname&amp;quot;, for consistency's sake and ease of reference.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Assigning the material ===&lt;br /&gt;
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).&lt;br /&gt;
Tips on this process can be found in the [[A Simple First Terrain|simple first terrain tutorial]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Creating the Surface Tree ==&lt;br /&gt;
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 &amp;quot;Save and Unload&amp;quot; button in the Terrain Editor.&lt;br /&gt;
[[Image:simplemega_terrainmodel.png|thumb|300px|Root node set up to use the correct terrain mesh]]&lt;br /&gt;
&lt;br /&gt;
=== Add the terrain mesh ===&lt;br /&gt;
Here's how you bring the terrain mesh into the surface tree:&lt;br /&gt;
* {{accelbtn|RMB}} on the left-hand pane, and choose ''New -&amp;gt; Tree'' via the menu.&lt;br /&gt;
** If you already have a Root node, click the &amp;quot;Begin Editing&amp;quot; button instead.&lt;br /&gt;
* Click on the Root node, and set {{keyname|Model}} to the name of the terrain mesh, in this case {{keyvalue|models/terrain/simpleterrain.obj}}.&lt;br /&gt;
* Press {{accelkey|enter}} to confirm the selection, and the terrain should appear in the 3D view.&lt;br /&gt;
&lt;br /&gt;
Be aware that your terrain model will probably appear bright orange or red.&lt;br /&gt;
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!&lt;br /&gt;
&lt;br /&gt;
=== Important note about nodes ===&lt;br /&gt;
When you are editing properties of nodes (names, numbers, texture sources etc.) always remember to hit {{accelkey|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 {{accelkey|enter}}, your changes may not be applied.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Create the first texture node ==&lt;br /&gt;
[[Image:simplemega_firstnode_diffuse.png|thumb|300px|The first texture node's diffuse texture properties]]&lt;br /&gt;
Now that the model is in place, you can start laying down the texture layers (or &amp;quot;nodes&amp;quot;) that will make up your MegaTexture.&lt;br /&gt;
&lt;br /&gt;
First you need to create a new Image Source node in the Terrain Editor.&lt;br /&gt;
* {{accelbtn|RMB}} on your &amp;quot;Root&amp;quot; node and choose ''New -&amp;gt; Image Source'' (or press {{accelkey|shift}}{{accelkey|i}})&lt;br /&gt;
* This will make a new node called &amp;quot;New Image Renderer&amp;quot;.&lt;br /&gt;
* You can rename this new node using the &amp;quot;Name&amp;quot; property field in the '''Object''' section.&lt;br /&gt;
* Rename the node &amp;quot;Dirt&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
You will notice in the top right of the Terrain Editor, a section listing things like &amp;quot;Diffuse&amp;quot;, &amp;quot;Distribution&amp;quot;, &amp;quot;Distribution Pattern&amp;quot; etc. Selecting one of these will list all of the properties for that section of the current node.&lt;br /&gt;
The ones we need to worry about are as follows:&lt;br /&gt;
&lt;br /&gt;
=== Diffuse ===&lt;br /&gt;
This is the colour map of the current node, and it should point to a tiling TGA texture.&lt;br /&gt;
* Make sure the Diffuse section is highlighted in the top right of the Terrain Editor.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to a generic tiling dirt texture. Remember to hit {{accelkey|enter}} afterwards!&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/dirt_02_d.tga}}&lt;br /&gt;
* The {{keyname|Scale}} field at the very bottom of the property list allows you to choose how much to tile the texture.&lt;br /&gt;
** 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!&lt;br /&gt;
** 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.&lt;br /&gt;
That's all you need to do for the Diffuse settings in this node.&lt;br /&gt;
&lt;br /&gt;
=== Distribution ===&lt;br /&gt;
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''.&lt;br /&gt;
* Make sure the Distribution section is highlighted in the top right.&lt;br /&gt;
* Since this is our first node, we want to show over the whole terrain. This means the distribution map should be 100% white.&lt;br /&gt;
* You can either assign a pure white TGA texture, or change the {{keyname|Source Type}} to {{keyvalue|geometryBased}}.&lt;br /&gt;
** {{keyvalue|geometryBased}} will by default create a fully white map, so if you don't have a white TGA handy, this is faster.&lt;br /&gt;
&lt;br /&gt;
=== Distribution Pattern ===&lt;br /&gt;
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.&lt;br /&gt;
* 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!&lt;br /&gt;
&lt;br /&gt;
=== Local ===&lt;br /&gt;
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.&lt;br /&gt;
* Make sure the Local section is highlighted in the top right.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching normal map for your tiling dirt texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/dirt_02_local.tga}}&lt;br /&gt;
* The Local texture's tiling amount is automatically the same as the Diffuse texture.&lt;br /&gt;
&lt;br /&gt;
=== Surface Type ===&lt;br /&gt;
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.&lt;br /&gt;
* Find the ''Surface Type Properties'' section of the property list.&lt;br /&gt;
* 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.&lt;br /&gt;
* Hit {{accelkey|enter}} to accept the surface type.&lt;br /&gt;
&lt;br /&gt;
Your dirt textures will now produce correct &amp;quot;dirt&amp;quot; effects when shot or collided with!&lt;br /&gt;
&lt;br /&gt;
=== Previewing the result ===&lt;br /&gt;
[[Image:simplemega_firstnode_preview.jpg|thumb|300px|The Render mode preview of the first node]]&lt;br /&gt;
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]]&lt;br /&gt;
&lt;br /&gt;
* Notice the drop-down arrow on the right of the button. Click it, and select ''&amp;quot;Full&amp;quot;'' instead of ''&amp;quot;None&amp;quot;''.&lt;br /&gt;
* Your terrain should change colour to black. This means it's ready for a preview to be rendered onto it.&lt;br /&gt;
* Click the button itself now, instead of the drop-down. An &amp;quot;Active Tasks&amp;quot; window should pop up, and when it's done, you should see your dirt texture appear on your terrain model.&lt;br /&gt;
* You can switch the camera to Render mode too, which will show your terrain model's shading better.&lt;br /&gt;
* If you want a full-resolution preview of a small area, choose ''&amp;quot;Window&amp;quot;'' instead of ''&amp;quot;Full&amp;quot;'' from the drop-down menu.&lt;br /&gt;
** 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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
'''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.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
== Adding a second node ==&lt;br /&gt;
Now that the first layer of dirt is in place, we can try putting some grass on top of it!&lt;br /&gt;
* Again, {{accelbtn|RMB}} on your &amp;quot;Root&amp;quot; node and choose ''New -&amp;gt; Image Source'' (or press {{accelkey|shift}}{{accelkey|i}})&lt;br /&gt;
* This will make another new node below your &amp;quot;Dirt&amp;quot; node. &lt;br /&gt;
* Name this new node &amp;quot;Grass&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Again, the main map types need to be specified before the node can be rendered:&lt;br /&gt;
&lt;br /&gt;
=== Diffuse ===&lt;br /&gt;
* Make sure the Diffuse section is highlighted in the top right of the Terrain Editor.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to a generic tiling grass texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/grass_04_d.tga}}&lt;br /&gt;
* 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.&lt;br /&gt;
&lt;br /&gt;
=== Distribution ===&lt;br /&gt;
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!&lt;br /&gt;
* Make sure the Distribution section is highlighted in the top right.&lt;br /&gt;
* Change the {{keyname|Source Type}} from {{keyvalue|texture}} to {{keyvalue|geometryBased}}.&lt;br /&gt;
&lt;br /&gt;
=== Geometric Texture Distribution ===&lt;br /&gt;
[[Image:simplemega_geometric_distribution.png|thumb|300px|The geometric texture distribution settings of the second node]]&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
* ''Altitude Lower'' - Enabling this will limit the lower parts of the terrain from receiving this node's textures.&lt;br /&gt;
** {{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.&lt;br /&gt;
** {{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.&lt;br /&gt;
* ''Altitude Upper'' - Enabling this will limit the higher parts of the terrain from receiving this node's textures.&lt;br /&gt;
** {{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.&lt;br /&gt;
** {{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.&lt;br /&gt;
&lt;br /&gt;
* {{keyname|Clamp Distribution To Edge}} - Leave this on Default.&lt;br /&gt;
&lt;br /&gt;
* {{keyname|Resolution}} - The size in pixels of the resulting mask. The default value of {{keyvalue|256}} is fine for nearly any terrain model.&lt;br /&gt;
&lt;br /&gt;
* ''Slope Lower'' - Enabling this will limit shallower angles of the terrain model from receiving this node's textures.&lt;br /&gt;
** {{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.&lt;br /&gt;
** {{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.&lt;br /&gt;
* ''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.&lt;br /&gt;
** {{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.&lt;br /&gt;
** {{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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
=== Distribution Pattern ===&lt;br /&gt;
[[Image:simplemega_dist_ramps.jpg|thumb|300px|The difference between using or not using a Distribution Pattern, and varying Ramp Widths]]&lt;br /&gt;
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!&lt;br /&gt;
So what we want here is a texture to identify the &amp;quot;height&amp;quot; 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.&lt;br /&gt;
&lt;br /&gt;
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!&lt;br /&gt;
&lt;br /&gt;
* Make sure {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching heightmap or mask for your tiling grass texture.&lt;br /&gt;
** This example is using {{filename|textures/megagen/temperate/grass_04_mask.tga}}&lt;br /&gt;
* 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 &amp;quot;Window&amp;quot; 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.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
=== Local ===&lt;br /&gt;
Again we want the normal-map which matches the diffuse texture for the grass.&lt;br /&gt;
* Make sure the Local section is highlighted in the top right.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching normal map for your tiling grass texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/grass_04_local.tga}}&lt;br /&gt;
&lt;br /&gt;
=== Surface Type ===&lt;br /&gt;
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.&lt;br /&gt;
* Find the ''Surface Type Properties'' section of the property list.&lt;br /&gt;
* 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.&lt;br /&gt;
* Hit {{accelkey|enter}} to accept the surface type.&lt;br /&gt;
&lt;br /&gt;
Your grass textures should now produce correct &amp;quot;grass&amp;quot; effects when shot or collided with!&lt;br /&gt;
&lt;br /&gt;
=== Preview ===&lt;br /&gt;
[[Image:simplemega_secondnode_preview.jpg|thumb|300px|The Render mode preview of the second node blended with the first node]]&lt;br /&gt;
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.&lt;br /&gt;
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.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
== Adding a third node ==&lt;br /&gt;
[[Image:simplemega_thirdnode_preview.jpg|thumb|300px|The Render mode preview of the third node blended with the other two nodes]]&lt;br /&gt;
Now that the grass and dirt are in place, we need some rocks to make the terrain look more natural.&lt;br /&gt;
* Add a new Image Renderer node below your &amp;quot;Grass&amp;quot; node and name it &amp;quot;Rock&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Again, the main map types need to be specified before the node can be rendered:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Diffuse ====&lt;br /&gt;
* Set the '''Diffuse''' texture and scale.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/rock_01_d.tga}} at a scale of {{keyvalue|32 32}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Distribution ====&lt;br /&gt;
Again we can use Geometric Texture Distribution to easily apply the rock textures only to the cliff-like angles.&lt;br /&gt;
* Make sure the Distribution section is highlighted in the top right.&lt;br /&gt;
* Change the {{keyname|Source Type}} to {{keyvalue|geometryBased}}.&lt;br /&gt;
* 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}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Distribution Pattern ====&lt;br /&gt;
Again this will control how the the rocks blend into the other nodes. Again, we want a texture to identify the &amp;quot;height&amp;quot; of the tiling rock texture.&lt;br /&gt;
&lt;br /&gt;
* Make sure the Distribution Pattern section is highlighted in the top right.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching heightmap or mask for your tiling rock texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/rock_01_h.tga}}&lt;br /&gt;
* 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 &amp;quot;Window&amp;quot; preview to see how the blending looks.&lt;br /&gt;
* Remember to set the {{keyname|Distribution Pattern Texture Scale}} to the same value as the Diffuse Scale, {{keyvalue|32 32}}.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Local ====&lt;br /&gt;
Again we want the normal-map which matches the diffuse texture for the rocks.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Local''' section, browse to the matching normal map for your tiling rock texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/rock_01_local.tga}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Surface Type ====&lt;br /&gt;
* Find the ''Surface Type Properties'' section of the property list.&lt;br /&gt;
* In the {{keyname|Type}} field, enter {{keyvalue|stone}}.&lt;br /&gt;
* Hit {{accelkey|enter}} to accept the surface type.&lt;br /&gt;
&lt;br /&gt;
Your rock textures should now produce correct &amp;quot;stone&amp;quot; effects when shot or collided with.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Preview again! ====&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Further tweaks ==&lt;br /&gt;
There are other simple changes that can be done in the Terrain Editor to make your MegaTexture look even better.&lt;br /&gt;
&lt;br /&gt;
==== Node order ====&lt;br /&gt;
[Image:simplemega_node_order.png|frame|Click and drag a node to change the order]]&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
* {{accelbtn|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.&lt;br /&gt;
* Release {{accelbtn|LMB}} when you have positioned the node in the correct place.&lt;br /&gt;
* 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!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Color changes ==== &lt;br /&gt;
Maybe your dirt texture is too bright? Or maybe your grass looks a little ''too'' green?&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Let's say you want to make the dirt texture darker and a bit more red. Here's how you'd do it:&lt;br /&gt;
* Select your Dirt node.&lt;br /&gt;
* 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).&lt;br /&gt;
* A color wheel and brightness slider will pop up in a new window. You can use this to darken and tint your texture.&lt;br /&gt;
* Choose a darker brightness, and a color slightly towards red. I used '''RGB Values''' of 225, 220, 220.&lt;br /&gt;
* Hit ''OK'' to accept the color.&lt;br /&gt;
* Re-render your MegaTexture preview. You should notice that the dirt layer looks darker now!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Texture rotation ====&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
An easy way to overcome this is to play with the {{keyvname|Rotation}} value in the Texture Properties section of the Terrain Editor's property list.&lt;br /&gt;
For each node, you should also set the {{keyvname|Distribution Pattern Texture Rotation}} to match the Rotation value if you want your distribution patterns to line up and work correctly.&lt;br /&gt;
&lt;br /&gt;
== Render the MegaTexture ==&lt;br /&gt;
=== Save the Surface Tree ===&lt;br /&gt;
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 &amp;quot;Save and Unload&amp;quot; button in the Terrain Editor, or save the whole map.&lt;br /&gt;
&lt;br /&gt;
=== Compile Only Entities ===&lt;br /&gt;
At this stage, your MegaTexture material is still technically &amp;quot;broken&amp;quot;, 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.&lt;br /&gt;
&lt;br /&gt;
However, we need to compile the map in order to tell the [[renderLight]] process which atmosphere to use when lighting the MegaTexture!&lt;br /&gt;
&lt;br /&gt;
So the solution is to do an '''Only Entities''' compile. You can find this in the menu ''Compile -&amp;gt; 2 - Only Entities'' in editWorld. This should be done in a few seconds, and compiles all the information that renderLight needs.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Run the SDK Launcher ===&lt;br /&gt;
Now that your ''.sft'' is saved, go through all the steps outlined in the [[Generate a MegaTexture]] tutorial.&lt;br /&gt;
&lt;br /&gt;
== That's it! ==&lt;br /&gt;
[[Image:simplemega_ingame.jpg|thumb|300px|The MegaTexture in-game!]]&lt;br /&gt;
You've now created your very own MegaTexture to use in your map!&lt;br /&gt;
&lt;br /&gt;
Before you even compile the map, you can get an accurate preview of how it will look in-game by pressing {{accelkey|F6}} to toggle &amp;quot;anim&amp;quot; mode while in editWorld's &amp;quot;RENDER&amp;quot; Camera view (toggled with {{accelkey|F3}}).&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
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:&lt;br /&gt;
* 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.&lt;br /&gt;
* 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 ''&amp;lt; &amp;quot;mapname&amp;quot; &amp;gt;'' part described in [[A Simple First Megatexture#Creating a MegaTexture material|this section]]), otherwise it will not be searching for the correct images.&lt;br /&gt;
* 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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
* [[An Advanced Terrain and Megatexture]] - an advanced guide for complete MegaTexture creation&lt;br /&gt;
* [[Generate a MegaTexture]] - steps for generating a MegaTexture from the SDK launcher.&lt;br /&gt;
* [http://community.enemyterritory.com/forums/showthread.php?t=19326 Forum Thread] - includes textures to download&lt;br /&gt;
&lt;br /&gt;
[[Category:Art]]&lt;br /&gt;
[[Category:Basic Level Design]]&lt;br /&gt;
[[Category:Tutorials]]&lt;/div&gt;</summary>
		<author><name>Ducks</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.splashdamage.com/index.php?title=A_Simple_First_Megatexture&amp;diff=4056</id>
		<title>A Simple First Megatexture</title>
		<link rel="alternate" type="text/html" href="https://wiki.splashdamage.com/index.php?title=A_Simple_First_Megatexture&amp;diff=4056"/>
		<updated>2007-12-17T15:10:58Z</updated>

		<summary type="html">&lt;p&gt;Ducks: /* Adding a second node */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Image:simplemega_ingame.jpg|right|thumb|500px|A simple MegaTexture, easily created with only 3 texture layers!]]&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
'''For this tutorial you must:'''&lt;br /&gt;
* Have a terrain model UV-mapped in the 0-1 range (covered in the simple first terrain tutorial)&lt;br /&gt;
* Have access to some tiling textures.&lt;br /&gt;
* Have a little understanding the ETQW material system&lt;br /&gt;
&lt;br /&gt;
If you don't have any of the above things, you are not ready to do this tutorial!&lt;br /&gt;
&lt;br /&gt;
'''This tutorial covers:'''&lt;br /&gt;
* How to set up a MegaTexture material&lt;br /&gt;
* How to create a Surface Tree&lt;br /&gt;
* How to add texture nodes in the Terrain Editor&lt;br /&gt;
* How to render and compile a full MegaTexture&lt;br /&gt;
&lt;br /&gt;
'''This tutorial does not cover:'''&lt;br /&gt;
* How to use Blender/Maya/Lightwave/ZBrush/Mudbox/3DSMax/Photoshop&lt;br /&gt;
* How to create tiling textures or heightmaps&lt;br /&gt;
* Anything overly complicated&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Creating a MegaTexture material ==&lt;br /&gt;
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:&lt;br /&gt;
 material megatextures/mapname		{ useTemplate megatextures/default_ambient&amp;lt; &amp;quot;mapname&amp;quot; &amp;gt; }&lt;br /&gt;
&lt;br /&gt;
This material would automatically search for a MegaTexture called {{filename|mapname.mega}} in the {{filename|/megatextures/}} folder. This example material uses the ''&amp;quot;default_ambient&amp;quot;'' 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]].&lt;br /&gt;
&lt;br /&gt;
Obviously you would want to use the actual name of your map instead of &amp;quot;mapname&amp;quot;, for consistency's sake and ease of reference.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Assigning the material ===&lt;br /&gt;
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).&lt;br /&gt;
Tips on this process can be found in the [[A Simple First Terrain|simple first terrain tutorial]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Creating the Surface Tree ==&lt;br /&gt;
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 &amp;quot;Save and Unload&amp;quot; button in the Terrain Editor.&lt;br /&gt;
[[Image:simplemega_terrainmodel.png|thumb|300px|Root node set up to use the correct terrain mesh]]&lt;br /&gt;
&lt;br /&gt;
=== Add the terrain mesh ===&lt;br /&gt;
Here's how you bring the terrain mesh into the surface tree:&lt;br /&gt;
* {{accelbtn|RMB}} on the left-hand pane, and choose ''New -&amp;gt; Tree'' via the menu.&lt;br /&gt;
** If you already have a Root node, click the &amp;quot;Begin Editing&amp;quot; button instead.&lt;br /&gt;
* Click on the Root node, and set {{keyname|Model}} to the name of the terrain mesh, in this case {{keyvalue|models/terrain/simpleterrain.obj}}.&lt;br /&gt;
* Press {{accelkey|enter}} to confirm the selection, and the terrain should appear in the 3D view.&lt;br /&gt;
&lt;br /&gt;
Be aware that your terrain model will probably appear bright orange or red.&lt;br /&gt;
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!&lt;br /&gt;
&lt;br /&gt;
=== Important note about nodes ===&lt;br /&gt;
When you are editing properties of nodes (names, numbers, texture sources etc.) always remember to hit {{accelkey|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 {{accelkey|enter}}, your changes may not be applied.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Create the first texture node ==&lt;br /&gt;
[[Image:simplemega_firstnode_diffuse.png|thumb|300px|The first texture node's diffuse texture properties]]&lt;br /&gt;
Now that the model is in place, you can start laying down the texture layers (or &amp;quot;nodes&amp;quot;) that will make up your MegaTexture.&lt;br /&gt;
&lt;br /&gt;
First you need to create a new Image Source node in the Terrain Editor.&lt;br /&gt;
* {{accelbtn|RMB}} on your &amp;quot;Root&amp;quot; node and choose ''New -&amp;gt; Image Source'' (or press {{accelkey|shift}}{{accelkey|i}})&lt;br /&gt;
* This will make a new node called &amp;quot;New Image Renderer&amp;quot;.&lt;br /&gt;
* You can rename this new node using the &amp;quot;Name&amp;quot; property field in the '''Object''' section.&lt;br /&gt;
* Rename the node &amp;quot;Dirt&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You will notice in the top right of the Terrain Editor, a section listing things like &amp;quot;Diffuse&amp;quot;, &amp;quot;Distribution&amp;quot;, &amp;quot;Distribution Pattern&amp;quot; etc. Selecting one of these will list all of the properties for that section of the current node.&lt;br /&gt;
The ones we need to worry about are as follows:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Diffuse ====&lt;br /&gt;
This is the colour map of the current node, and it should point to a tiling TGA texture.&lt;br /&gt;
* Make sure the Diffuse section is highlighted in the top right of the Terrain Editor.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to a generic tiling dirt texture. Remember to hit {{accelkey|enter}} afterwards!&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/dirt_02_d.tga}}&lt;br /&gt;
* The {{keyname|Scale}} field at the very bottom of the property list allows you to choose how much to tile the texture.&lt;br /&gt;
** 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!&lt;br /&gt;
** 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.&lt;br /&gt;
That's all you need to do for the Diffuse settings in this node.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Distribution ====&lt;br /&gt;
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''.&lt;br /&gt;
* Make sure the Distribution section is highlighted in the top right.&lt;br /&gt;
* Since this is our first node, we want to show over the whole terrain. This means the distribution map should be 100% white.&lt;br /&gt;
* You can either assign a pure white TGA texture, or change the {{keyname|Source Type}} to {{keyvalue|geometryBased}}.&lt;br /&gt;
** {{keyvalue|geometryBased}} will by default create a fully white map, so if you don't have a white TGA handy, this is faster.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Distribution Pattern ====&lt;br /&gt;
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.&lt;br /&gt;
* 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!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Local ====&lt;br /&gt;
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.&lt;br /&gt;
* Make sure the Local section is highlighted in the top right.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching normal map for your tiling dirt texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/dirt_02_local.tga}}&lt;br /&gt;
* The Local texture's tiling amount is automatically the same as the Diffuse texture.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Surface Type ====&lt;br /&gt;
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.&lt;br /&gt;
* Find the ''Surface Type Properties'' section of the property list.&lt;br /&gt;
* 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.&lt;br /&gt;
* Hit {{accelkey|enter}} to accept the surface type.&lt;br /&gt;
&lt;br /&gt;
Your dirt textures will now produce correct &amp;quot;dirt&amp;quot; effects when shot or collided with!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Previewing the result ====&lt;br /&gt;
[[Image:simplemega_firstnode_preview.jpg|thumb|300px|The Render mode preview of the first node]]&lt;br /&gt;
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]]&lt;br /&gt;
&lt;br /&gt;
* Notice the drop-down arrow on the right of the button. Click it, and select ''&amp;quot;Full&amp;quot;'' instead of ''&amp;quot;None&amp;quot;''.&lt;br /&gt;
* Your terrain should change colour to black. This means it's ready for a preview to be rendered onto it.&lt;br /&gt;
* Click the button itself now, instead of the drop-down. An &amp;quot;Active Tasks&amp;quot; window should pop up, and when it's done, you should see your dirt texture appear on your terrain model.&lt;br /&gt;
* You can switch the camera to Render mode too, which will show your terrain model's shading better.&lt;br /&gt;
* If you want a full-resolution preview of a small area, choose ''&amp;quot;Window&amp;quot;'' instead of ''&amp;quot;Full&amp;quot;'' from the drop-down menu.&lt;br /&gt;
** 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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
'''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.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
== Adding a second node ==&lt;br /&gt;
Now that the first layer of dirt is in place, we can try putting some grass on top of it!&lt;br /&gt;
* Again, {{accelbtn|RMB}} on your &amp;quot;Root&amp;quot; node and choose ''New -&amp;gt; Image Source'' (or press {{accelkey|shift}}{{accelkey|i}})&lt;br /&gt;
* This will make another new node below your &amp;quot;Dirt&amp;quot; node. &lt;br /&gt;
* Name this new node &amp;quot;Grass&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Again, the main map types need to be specified before the node can be rendered:&lt;br /&gt;
&lt;br /&gt;
=== Diffuse ===&lt;br /&gt;
* Make sure the Diffuse section is highlighted in the top right of the Terrain Editor.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to a generic tiling grass texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/grass_04_d.tga}}&lt;br /&gt;
* 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.&lt;br /&gt;
&lt;br /&gt;
=== Distribution ===&lt;br /&gt;
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!&lt;br /&gt;
* Make sure the Distribution section is highlighted in the top right.&lt;br /&gt;
* Change the {{keyname|Source Type}} from {{keyvalue|texture}} to {{keyvalue|geometryBased}}.&lt;br /&gt;
&lt;br /&gt;
=== Geometric Texture Distribution ===&lt;br /&gt;
[[Image:simplemega_geometric_distribution.png|thumb|300px|The geometric texture distribution settings of the second node]]&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
* ''Altitude Lower'' - Enabling this will limit the lower parts of the terrain from receiving this node's textures.&lt;br /&gt;
** {{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.&lt;br /&gt;
** {{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.&lt;br /&gt;
* ''Altitude Upper'' - Enabling this will limit the higher parts of the terrain from receiving this node's textures.&lt;br /&gt;
** {{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.&lt;br /&gt;
** {{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.&lt;br /&gt;
&lt;br /&gt;
* {{keyname|Clamp Distribution To Edge}} - Leave this on Default.&lt;br /&gt;
&lt;br /&gt;
* {{keyname|Resolution}} - The size in pixels of the resulting mask. The default value of {{keyvalue|256}} is fine for nearly any terrain model.&lt;br /&gt;
&lt;br /&gt;
* ''Slope Lower'' - Enabling this will limit shallower angles of the terrain model from receiving this node's textures.&lt;br /&gt;
** {{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.&lt;br /&gt;
** {{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.&lt;br /&gt;
* ''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.&lt;br /&gt;
** {{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.&lt;br /&gt;
** {{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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
=== Distribution Pattern ===&lt;br /&gt;
[[Image:simplemega_dist_ramps.jpg|thumb|300px|The difference between using or not using a Distribution Pattern, and varying Ramp Widths]]&lt;br /&gt;
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!&lt;br /&gt;
So what we want here is a texture to identify the &amp;quot;height&amp;quot; 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.&lt;br /&gt;
&lt;br /&gt;
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!&lt;br /&gt;
&lt;br /&gt;
* Make sure {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching heightmap or mask for your tiling grass texture.&lt;br /&gt;
** This example is using {{filename|textures/megagen/temperate/grass_04_mask.tga}}&lt;br /&gt;
* 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 &amp;quot;Window&amp;quot; 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.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
=== Local ===&lt;br /&gt;
Again we want the normal-map which matches the diffuse texture for the grass.&lt;br /&gt;
* Make sure the Local section is highlighted in the top right.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching normal map for your tiling grass texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/grass_04_local.tga}}&lt;br /&gt;
&lt;br /&gt;
=== Surface Type ===&lt;br /&gt;
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.&lt;br /&gt;
* Find the ''Surface Type Properties'' section of the property list.&lt;br /&gt;
* 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.&lt;br /&gt;
* Hit {{accelkey|enter}} to accept the surface type.&lt;br /&gt;
&lt;br /&gt;
Your grass textures should now produce correct &amp;quot;grass&amp;quot; effects when shot or collided with!&lt;br /&gt;
&lt;br /&gt;
=== Preview ===&lt;br /&gt;
[[Image:simplemega_secondnode_preview.jpg|thumb|300px|The Render mode preview of the second node blended with the first node]]&lt;br /&gt;
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.&lt;br /&gt;
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.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
== Adding a third node ==&lt;br /&gt;
[[Image:simplemega_thirdnode_preview.jpg|thumb|300px|The Render mode preview of the third node blended with the other two nodes]]&lt;br /&gt;
Now that the grass and dirt are in place, we need some rocks to make the terrain look more natural.&lt;br /&gt;
* Add a new Image Renderer node below your &amp;quot;Grass&amp;quot; node and name it &amp;quot;Rock&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Again, the main map types need to be specified before the node can be rendered:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Diffuse ====&lt;br /&gt;
* Set the '''Diffuse''' texture and scale.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/rock_01_d.tga}} at a scale of {{keyvalue|32 32}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Distribution ====&lt;br /&gt;
Again we can use Geometric Texture Distribution to easily apply the rock textures only to the cliff-like angles.&lt;br /&gt;
* Make sure the Distribution section is highlighted in the top right.&lt;br /&gt;
* Change the {{keyname|Source Type}} to {{keyvalue|geometryBased}}.&lt;br /&gt;
* 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}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Distribution Pattern ====&lt;br /&gt;
Again this will control how the the rocks blend into the other nodes. Again, we want a texture to identify the &amp;quot;height&amp;quot; of the tiling rock texture.&lt;br /&gt;
&lt;br /&gt;
* Make sure the Distribution Pattern section is highlighted in the top right.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching heightmap or mask for your tiling rock texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/rock_01_h.tga}}&lt;br /&gt;
* 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 &amp;quot;Window&amp;quot; preview to see how the blending looks.&lt;br /&gt;
* Remember to set the {{keyname|Distribution Pattern Texture Scale}} to the same value as the Diffuse Scale, {{keyvalue|32 32}}.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Local ====&lt;br /&gt;
Again we want the normal-map which matches the diffuse texture for the rocks.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Local''' section, browse to the matching normal map for your tiling rock texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/rock_01_local.tga}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Surface Type ====&lt;br /&gt;
* Find the ''Surface Type Properties'' section of the property list.&lt;br /&gt;
* In the {{keyname|Type}} field, enter {{keyvalue|stone}}.&lt;br /&gt;
* Hit {{accelkey|enter}} to accept the surface type.&lt;br /&gt;
&lt;br /&gt;
Your rock textures should now produce correct &amp;quot;stone&amp;quot; effects when shot or collided with.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Preview again! ====&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Further tweaks ==&lt;br /&gt;
There are other simple changes that can be done in the Terrain Editor to make your MegaTexture look even better.&lt;br /&gt;
&lt;br /&gt;
==== Node order ====&lt;br /&gt;
[Image:simplemega_node_order.png|frame|Click and drag a node to change the order]]&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
* {{accelbtn|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.&lt;br /&gt;
* Release {{accelbtn|LMB}} when you have positioned the node in the correct place.&lt;br /&gt;
* 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!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Color changes ==== &lt;br /&gt;
Maybe your dirt texture is too bright? Or maybe your grass looks a little ''too'' green?&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Let's say you want to make the dirt texture darker and a bit more red. Here's how you'd do it:&lt;br /&gt;
* Select your Dirt node.&lt;br /&gt;
* 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).&lt;br /&gt;
* A color wheel and brightness slider will pop up in a new window. You can use this to darken and tint your texture.&lt;br /&gt;
* Choose a darker brightness, and a color slightly towards red. I used '''RGB Values''' of 225, 220, 220.&lt;br /&gt;
* Hit ''OK'' to accept the color.&lt;br /&gt;
* Re-render your MegaTexture preview. You should notice that the dirt layer looks darker now!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Texture rotation ====&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
An easy way to overcome this is to play with the {{keyvname|Rotation}} value in the Texture Properties section of the Terrain Editor's property list.&lt;br /&gt;
For each node, you should also set the {{keyvname|Distribution Pattern Texture Rotation}} to match the Rotation value if you want your distribution patterns to line up and work correctly.&lt;br /&gt;
&lt;br /&gt;
== Render the MegaTexture ==&lt;br /&gt;
=== Save the Surface Tree ===&lt;br /&gt;
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 &amp;quot;Save and Unload&amp;quot; button in the Terrain Editor, or save the whole map.&lt;br /&gt;
&lt;br /&gt;
=== Compile Only Entities ===&lt;br /&gt;
At this stage, your MegaTexture material is still technically &amp;quot;broken&amp;quot;, 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.&lt;br /&gt;
&lt;br /&gt;
However, we need to compile the map in order to tell the [[renderLight]] process which atmosphere to use when lighting the MegaTexture!&lt;br /&gt;
&lt;br /&gt;
So the solution is to do an '''Only Entities''' compile. You can find this in the menu ''Compile -&amp;gt; 2 - Only Entities'' in editWorld. This should be done in a few seconds, and compiles all the information that renderLight needs.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Run the SDK Launcher ===&lt;br /&gt;
Now that your ''.sft'' is saved, go through all the steps outlined in the [[Generate a MegaTexture]] tutorial.&lt;br /&gt;
&lt;br /&gt;
== That's it! ==&lt;br /&gt;
[[Image:simplemega_ingame.jpg|thumb|300px|The MegaTexture in-game!]]&lt;br /&gt;
You've now created your very own MegaTexture to use in your map!&lt;br /&gt;
&lt;br /&gt;
Before you even compile the map, you can get an accurate preview of how it will look in-game by pressing {{accelkey|F6}} to toggle &amp;quot;anim&amp;quot; mode while in editWorld's &amp;quot;RENDER&amp;quot; Camera view (toggled with {{accelkey|F3}}).&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
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:&lt;br /&gt;
* 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.&lt;br /&gt;
* 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 ''&amp;lt; &amp;quot;mapname&amp;quot; &amp;gt;'' part described in [[A Simple First Megatexture#Creating a MegaTexture material|this section]]), otherwise it will not be searching for the correct images.&lt;br /&gt;
* 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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
* [[An Advanced Terrain and Megatexture]] - an advanced guide for complete MegaTexture creation&lt;br /&gt;
* [[Generate a MegaTexture]] - steps for generating a MegaTexture from the SDK launcher.&lt;br /&gt;
* [http://community.enemyterritory.com/forums/showthread.php?t=19326 Forum Thread] - includes textures to download&lt;br /&gt;
&lt;br /&gt;
[[Category:Art]]&lt;br /&gt;
[[Category:Basic Level Design]]&lt;br /&gt;
[[Category:Tutorials]]&lt;/div&gt;</summary>
		<author><name>Ducks</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.splashdamage.com/index.php?title=A_Simple_First_Megatexture&amp;diff=4055</id>
		<title>A Simple First Megatexture</title>
		<link rel="alternate" type="text/html" href="https://wiki.splashdamage.com/index.php?title=A_Simple_First_Megatexture&amp;diff=4055"/>
		<updated>2007-12-17T15:08:42Z</updated>

		<summary type="html">&lt;p&gt;Ducks: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Image:simplemega_ingame.jpg|right|thumb|500px|A simple MegaTexture, easily created with only 3 texture layers!]]&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
'''For this tutorial you must:'''&lt;br /&gt;
* Have a terrain model UV-mapped in the 0-1 range (covered in the simple first terrain tutorial)&lt;br /&gt;
* Have access to some tiling textures.&lt;br /&gt;
* Have a little understanding the ETQW material system&lt;br /&gt;
&lt;br /&gt;
If you don't have any of the above things, you are not ready to do this tutorial!&lt;br /&gt;
&lt;br /&gt;
'''This tutorial covers:'''&lt;br /&gt;
* How to set up a MegaTexture material&lt;br /&gt;
* How to create a Surface Tree&lt;br /&gt;
* How to add texture nodes in the Terrain Editor&lt;br /&gt;
* How to render and compile a full MegaTexture&lt;br /&gt;
&lt;br /&gt;
'''This tutorial does not cover:'''&lt;br /&gt;
* How to use Blender/Maya/Lightwave/ZBrush/Mudbox/3DSMax/Photoshop&lt;br /&gt;
* How to create tiling textures or heightmaps&lt;br /&gt;
* Anything overly complicated&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Creating a MegaTexture material ==&lt;br /&gt;
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:&lt;br /&gt;
 material megatextures/mapname		{ useTemplate megatextures/default_ambient&amp;lt; &amp;quot;mapname&amp;quot; &amp;gt; }&lt;br /&gt;
&lt;br /&gt;
This material would automatically search for a MegaTexture called {{filename|mapname.mega}} in the {{filename|/megatextures/}} folder. This example material uses the ''&amp;quot;default_ambient&amp;quot;'' 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]].&lt;br /&gt;
&lt;br /&gt;
Obviously you would want to use the actual name of your map instead of &amp;quot;mapname&amp;quot;, for consistency's sake and ease of reference.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Assigning the material ===&lt;br /&gt;
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).&lt;br /&gt;
Tips on this process can be found in the [[A Simple First Terrain|simple first terrain tutorial]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Creating the Surface Tree ==&lt;br /&gt;
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 &amp;quot;Save and Unload&amp;quot; button in the Terrain Editor.&lt;br /&gt;
[[Image:simplemega_terrainmodel.png|thumb|300px|Root node set up to use the correct terrain mesh]]&lt;br /&gt;
&lt;br /&gt;
=== Add the terrain mesh ===&lt;br /&gt;
Here's how you bring the terrain mesh into the surface tree:&lt;br /&gt;
* {{accelbtn|RMB}} on the left-hand pane, and choose ''New -&amp;gt; Tree'' via the menu.&lt;br /&gt;
** If you already have a Root node, click the &amp;quot;Begin Editing&amp;quot; button instead.&lt;br /&gt;
* Click on the Root node, and set {{keyname|Model}} to the name of the terrain mesh, in this case {{keyvalue|models/terrain/simpleterrain.obj}}.&lt;br /&gt;
* Press {{accelkey|enter}} to confirm the selection, and the terrain should appear in the 3D view.&lt;br /&gt;
&lt;br /&gt;
Be aware that your terrain model will probably appear bright orange or red.&lt;br /&gt;
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!&lt;br /&gt;
&lt;br /&gt;
=== Important note about nodes ===&lt;br /&gt;
When you are editing properties of nodes (names, numbers, texture sources etc.) always remember to hit {{accelkey|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 {{accelkey|enter}}, your changes may not be applied.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Create the first texture node ==&lt;br /&gt;
[[Image:simplemega_firstnode_diffuse.png|thumb|300px|The first texture node's diffuse texture properties]]&lt;br /&gt;
Now that the model is in place, you can start laying down the texture layers (or &amp;quot;nodes&amp;quot;) that will make up your MegaTexture.&lt;br /&gt;
&lt;br /&gt;
First you need to create a new Image Source node in the Terrain Editor.&lt;br /&gt;
* {{accelbtn|RMB}} on your &amp;quot;Root&amp;quot; node and choose ''New -&amp;gt; Image Source'' (or press {{accelkey|shift}}{{accelkey|i}})&lt;br /&gt;
* This will make a new node called &amp;quot;New Image Renderer&amp;quot;.&lt;br /&gt;
* You can rename this new node using the &amp;quot;Name&amp;quot; property field in the '''Object''' section.&lt;br /&gt;
* Rename the node &amp;quot;Dirt&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You will notice in the top right of the Terrain Editor, a section listing things like &amp;quot;Diffuse&amp;quot;, &amp;quot;Distribution&amp;quot;, &amp;quot;Distribution Pattern&amp;quot; etc. Selecting one of these will list all of the properties for that section of the current node.&lt;br /&gt;
The ones we need to worry about are as follows:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Diffuse ====&lt;br /&gt;
This is the colour map of the current node, and it should point to a tiling TGA texture.&lt;br /&gt;
* Make sure the Diffuse section is highlighted in the top right of the Terrain Editor.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to a generic tiling dirt texture. Remember to hit {{accelkey|enter}} afterwards!&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/dirt_02_d.tga}}&lt;br /&gt;
* The {{keyname|Scale}} field at the very bottom of the property list allows you to choose how much to tile the texture.&lt;br /&gt;
** 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!&lt;br /&gt;
** 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.&lt;br /&gt;
That's all you need to do for the Diffuse settings in this node.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Distribution ====&lt;br /&gt;
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''.&lt;br /&gt;
* Make sure the Distribution section is highlighted in the top right.&lt;br /&gt;
* Since this is our first node, we want to show over the whole terrain. This means the distribution map should be 100% white.&lt;br /&gt;
* You can either assign a pure white TGA texture, or change the {{keyname|Source Type}} to {{keyvalue|geometryBased}}.&lt;br /&gt;
** {{keyvalue|geometryBased}} will by default create a fully white map, so if you don't have a white TGA handy, this is faster.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Distribution Pattern ====&lt;br /&gt;
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.&lt;br /&gt;
* 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!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Local ====&lt;br /&gt;
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.&lt;br /&gt;
* Make sure the Local section is highlighted in the top right.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching normal map for your tiling dirt texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/dirt_02_local.tga}}&lt;br /&gt;
* The Local texture's tiling amount is automatically the same as the Diffuse texture.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Surface Type ====&lt;br /&gt;
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.&lt;br /&gt;
* Find the ''Surface Type Properties'' section of the property list.&lt;br /&gt;
* 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.&lt;br /&gt;
* Hit {{accelkey|enter}} to accept the surface type.&lt;br /&gt;
&lt;br /&gt;
Your dirt textures will now produce correct &amp;quot;dirt&amp;quot; effects when shot or collided with!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Previewing the result ====&lt;br /&gt;
[[Image:simplemega_firstnode_preview.jpg|thumb|300px|The Render mode preview of the first node]]&lt;br /&gt;
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]]&lt;br /&gt;
&lt;br /&gt;
* Notice the drop-down arrow on the right of the button. Click it, and select ''&amp;quot;Full&amp;quot;'' instead of ''&amp;quot;None&amp;quot;''.&lt;br /&gt;
* Your terrain should change colour to black. This means it's ready for a preview to be rendered onto it.&lt;br /&gt;
* Click the button itself now, instead of the drop-down. An &amp;quot;Active Tasks&amp;quot; window should pop up, and when it's done, you should see your dirt texture appear on your terrain model.&lt;br /&gt;
* You can switch the camera to Render mode too, which will show your terrain model's shading better.&lt;br /&gt;
* If you want a full-resolution preview of a small area, choose ''&amp;quot;Window&amp;quot;'' instead of ''&amp;quot;Full&amp;quot;'' from the drop-down menu.&lt;br /&gt;
** 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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
'''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.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
== Adding a second node ==&lt;br /&gt;
Now that the first layer of dirt is in place, we can try putting some grass on top of it!&lt;br /&gt;
* Again, {{accelbtn|RMB}} on your &amp;quot;Root&amp;quot; node and choose ''New -&amp;gt; Image Source'' (or press {{accelkey|shift}}{{accelkey|i}})&lt;br /&gt;
* This will make another new node below your &amp;quot;Dirt&amp;quot; node. &lt;br /&gt;
* Name this new node &amp;quot;Grass&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Again, the main map types need to be specified before the node can be rendered:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Diffuse ====&lt;br /&gt;
* Make sure the Diffuse section is highlighted in the top right of the Terrain Editor.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to a generic tiling grass texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/grass_04_d.tga}}&lt;br /&gt;
* 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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Distribution ====&lt;br /&gt;
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!&lt;br /&gt;
* Make sure the Distribution section is highlighted in the top right.&lt;br /&gt;
* Change the {{keyname|Source Type}} from {{keyvalue|texture}} to {{keyvalue|geometryBased}}.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Geometric Texture Distribution ====&lt;br /&gt;
[[Image:simplemega_geometric_distribution.png|thumb|300px|The geometric texture distribution settings of the second node]]&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
* ''Altitude Lower'' - Enabling this will limit the lower parts of the terrain from receiving this node's textures.&lt;br /&gt;
** {{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.&lt;br /&gt;
** {{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.&lt;br /&gt;
* ''Altitude Upper'' - Enabling this will limit the higher parts of the terrain from receiving this node's textures.&lt;br /&gt;
** {{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.&lt;br /&gt;
** {{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.&lt;br /&gt;
&lt;br /&gt;
* {{keyname|Clamp Distribution To Edge}} - Leave this on Default.&lt;br /&gt;
&lt;br /&gt;
* {{keyname|Resolution}} - The size in pixels of the resulting mask. The default value of {{keyvalue|256}} is fine for nearly any terrain model.&lt;br /&gt;
&lt;br /&gt;
* ''Slope Lower'' - Enabling this will limit shallower angles of the terrain model from receiving this node's textures.&lt;br /&gt;
** {{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.&lt;br /&gt;
** {{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.&lt;br /&gt;
* ''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.&lt;br /&gt;
** {{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.&lt;br /&gt;
** {{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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Distribution Pattern ====&lt;br /&gt;
[[Image:simplemega_dist_ramps.jpg|thumb|300px|The difference between using or not using a Distribution Pattern, and varying Ramp Widths]]&lt;br /&gt;
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!&lt;br /&gt;
So what we want here is a texture to identify the &amp;quot;height&amp;quot; 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.&lt;br /&gt;
&lt;br /&gt;
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!&lt;br /&gt;
&lt;br /&gt;
* Make sure {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching heightmap or mask for your tiling grass texture.&lt;br /&gt;
** This example is using {{filename|textures/megagen/temperate/grass_04_mask.tga}}&lt;br /&gt;
* 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 &amp;quot;Window&amp;quot; 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.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Local ====&lt;br /&gt;
Again we want the normal-map which matches the diffuse texture for the grass.&lt;br /&gt;
* Make sure the Local section is highlighted in the top right.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching normal map for your tiling grass texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/grass_04_local.tga}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Surface Type ====&lt;br /&gt;
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.&lt;br /&gt;
* Find the ''Surface Type Properties'' section of the property list.&lt;br /&gt;
* 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.&lt;br /&gt;
* Hit {{accelkey|enter}} to accept the surface type.&lt;br /&gt;
&lt;br /&gt;
Your grass textures should now produce correct &amp;quot;grass&amp;quot; effects when shot or collided with!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Preview again! ===&lt;br /&gt;
[[Image:simplemega_secondnode_preview.jpg|thumb|300px|The Render mode preview of the second node blended with the first node]]&lt;br /&gt;
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.&lt;br /&gt;
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.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
== Adding a third node ==&lt;br /&gt;
[[Image:simplemega_thirdnode_preview.jpg|thumb|300px|The Render mode preview of the third node blended with the other two nodes]]&lt;br /&gt;
Now that the grass and dirt are in place, we need some rocks to make the terrain look more natural.&lt;br /&gt;
* Add a new Image Renderer node below your &amp;quot;Grass&amp;quot; node and name it &amp;quot;Rock&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Again, the main map types need to be specified before the node can be rendered:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Diffuse ====&lt;br /&gt;
* Set the '''Diffuse''' texture and scale.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/rock_01_d.tga}} at a scale of {{keyvalue|32 32}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Distribution ====&lt;br /&gt;
Again we can use Geometric Texture Distribution to easily apply the rock textures only to the cliff-like angles.&lt;br /&gt;
* Make sure the Distribution section is highlighted in the top right.&lt;br /&gt;
* Change the {{keyname|Source Type}} to {{keyvalue|geometryBased}}.&lt;br /&gt;
* 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}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Distribution Pattern ====&lt;br /&gt;
Again this will control how the the rocks blend into the other nodes. Again, we want a texture to identify the &amp;quot;height&amp;quot; of the tiling rock texture.&lt;br /&gt;
&lt;br /&gt;
* Make sure the Distribution Pattern section is highlighted in the top right.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching heightmap or mask for your tiling rock texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/rock_01_h.tga}}&lt;br /&gt;
* 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 &amp;quot;Window&amp;quot; preview to see how the blending looks.&lt;br /&gt;
* Remember to set the {{keyname|Distribution Pattern Texture Scale}} to the same value as the Diffuse Scale, {{keyvalue|32 32}}.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Local ====&lt;br /&gt;
Again we want the normal-map which matches the diffuse texture for the rocks.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Local''' section, browse to the matching normal map for your tiling rock texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/rock_01_local.tga}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Surface Type ====&lt;br /&gt;
* Find the ''Surface Type Properties'' section of the property list.&lt;br /&gt;
* In the {{keyname|Type}} field, enter {{keyvalue|stone}}.&lt;br /&gt;
* Hit {{accelkey|enter}} to accept the surface type.&lt;br /&gt;
&lt;br /&gt;
Your rock textures should now produce correct &amp;quot;stone&amp;quot; effects when shot or collided with.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Preview again! ====&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Further tweaks ==&lt;br /&gt;
There are other simple changes that can be done in the Terrain Editor to make your MegaTexture look even better.&lt;br /&gt;
&lt;br /&gt;
==== Node order ====&lt;br /&gt;
[Image:simplemega_node_order.png|frame|Click and drag a node to change the order]]&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
* {{accelbtn|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.&lt;br /&gt;
* Release {{accelbtn|LMB}} when you have positioned the node in the correct place.&lt;br /&gt;
* 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!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Color changes ==== &lt;br /&gt;
Maybe your dirt texture is too bright? Or maybe your grass looks a little ''too'' green?&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Let's say you want to make the dirt texture darker and a bit more red. Here's how you'd do it:&lt;br /&gt;
* Select your Dirt node.&lt;br /&gt;
* 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).&lt;br /&gt;
* A color wheel and brightness slider will pop up in a new window. You can use this to darken and tint your texture.&lt;br /&gt;
* Choose a darker brightness, and a color slightly towards red. I used '''RGB Values''' of 225, 220, 220.&lt;br /&gt;
* Hit ''OK'' to accept the color.&lt;br /&gt;
* Re-render your MegaTexture preview. You should notice that the dirt layer looks darker now!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Texture rotation ====&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
An easy way to overcome this is to play with the {{keyvname|Rotation}} value in the Texture Properties section of the Terrain Editor's property list.&lt;br /&gt;
For each node, you should also set the {{keyvname|Distribution Pattern Texture Rotation}} to match the Rotation value if you want your distribution patterns to line up and work correctly.&lt;br /&gt;
&lt;br /&gt;
== Render the MegaTexture ==&lt;br /&gt;
=== Save the Surface Tree ===&lt;br /&gt;
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 &amp;quot;Save and Unload&amp;quot; button in the Terrain Editor, or save the whole map.&lt;br /&gt;
&lt;br /&gt;
=== Compile Only Entities ===&lt;br /&gt;
At this stage, your MegaTexture material is still technically &amp;quot;broken&amp;quot;, 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.&lt;br /&gt;
&lt;br /&gt;
However, we need to compile the map in order to tell the [[renderLight]] process which atmosphere to use when lighting the MegaTexture!&lt;br /&gt;
&lt;br /&gt;
So the solution is to do an '''Only Entities''' compile. You can find this in the menu ''Compile -&amp;gt; 2 - Only Entities'' in editWorld. This should be done in a few seconds, and compiles all the information that renderLight needs.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Run the SDK Launcher ===&lt;br /&gt;
Now that your ''.sft'' is saved, go through all the steps outlined in the [[Generate a MegaTexture]] tutorial.&lt;br /&gt;
&lt;br /&gt;
== That's it! ==&lt;br /&gt;
[[Image:simplemega_ingame.jpg|thumb|300px|The MegaTexture in-game!]]&lt;br /&gt;
You've now created your very own MegaTexture to use in your map!&lt;br /&gt;
&lt;br /&gt;
Before you even compile the map, you can get an accurate preview of how it will look in-game by pressing {{accelkey|F6}} to toggle &amp;quot;anim&amp;quot; mode while in editWorld's &amp;quot;RENDER&amp;quot; Camera view (toggled with {{accelkey|F3}}).&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
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:&lt;br /&gt;
* 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.&lt;br /&gt;
* 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 ''&amp;lt; &amp;quot;mapname&amp;quot; &amp;gt;'' part described in [[A Simple First Megatexture#Creating a MegaTexture material|this section]]), otherwise it will not be searching for the correct images.&lt;br /&gt;
* 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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
* [[An Advanced Terrain and Megatexture]] - an advanced guide for complete MegaTexture creation&lt;br /&gt;
* [[Generate a MegaTexture]] - steps for generating a MegaTexture from the SDK launcher.&lt;br /&gt;
* [http://community.enemyterritory.com/forums/showthread.php?t=19326 Forum Thread] - includes textures to download&lt;br /&gt;
&lt;br /&gt;
[[Category:Art]]&lt;br /&gt;
[[Category:Basic Level Design]]&lt;br /&gt;
[[Category:Tutorials]]&lt;/div&gt;</summary>
		<author><name>Ducks</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.splashdamage.com/index.php?title=A_Simple_First_Megatexture&amp;diff=4054</id>
		<title>A Simple First Megatexture</title>
		<link rel="alternate" type="text/html" href="https://wiki.splashdamage.com/index.php?title=A_Simple_First_Megatexture&amp;diff=4054"/>
		<updated>2007-12-17T15:08:33Z</updated>

		<summary type="html">&lt;p&gt;Ducks: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Image:simplemega_ingame.jpg|right|thumb|500px|A simple MegaTexture, easily created with only 3 texture layers!]]&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
= Introduction =&lt;br /&gt;
'''For this tutorial you must:'''&lt;br /&gt;
* Have a terrain model UV-mapped in the 0-1 range (covered in the simple first terrain tutorial)&lt;br /&gt;
* Have access to some tiling textures.&lt;br /&gt;
* Have a little understanding the ETQW material system&lt;br /&gt;
&lt;br /&gt;
If you don't have any of the above things, you are not ready to do this tutorial!&lt;br /&gt;
&lt;br /&gt;
'''This tutorial covers:'''&lt;br /&gt;
* How to set up a MegaTexture material&lt;br /&gt;
* How to create a Surface Tree&lt;br /&gt;
* How to add texture nodes in the Terrain Editor&lt;br /&gt;
* How to render and compile a full MegaTexture&lt;br /&gt;
&lt;br /&gt;
'''This tutorial does not cover:'''&lt;br /&gt;
* How to use Blender/Maya/Lightwave/ZBrush/Mudbox/3DSMax/Photoshop&lt;br /&gt;
* How to create tiling textures or heightmaps&lt;br /&gt;
* Anything overly complicated&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Creating a MegaTexture material ==&lt;br /&gt;
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:&lt;br /&gt;
 material megatextures/mapname		{ useTemplate megatextures/default_ambient&amp;lt; &amp;quot;mapname&amp;quot; &amp;gt; }&lt;br /&gt;
&lt;br /&gt;
This material would automatically search for a MegaTexture called {{filename|mapname.mega}} in the {{filename|/megatextures/}} folder. This example material uses the ''&amp;quot;default_ambient&amp;quot;'' 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]].&lt;br /&gt;
&lt;br /&gt;
Obviously you would want to use the actual name of your map instead of &amp;quot;mapname&amp;quot;, for consistency's sake and ease of reference.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Assigning the material ===&lt;br /&gt;
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).&lt;br /&gt;
Tips on this process can be found in the [[A Simple First Terrain|simple first terrain tutorial]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Creating the Surface Tree ==&lt;br /&gt;
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 &amp;quot;Save and Unload&amp;quot; button in the Terrain Editor.&lt;br /&gt;
[[Image:simplemega_terrainmodel.png|thumb|300px|Root node set up to use the correct terrain mesh]]&lt;br /&gt;
&lt;br /&gt;
=== Add the terrain mesh ===&lt;br /&gt;
Here's how you bring the terrain mesh into the surface tree:&lt;br /&gt;
* {{accelbtn|RMB}} on the left-hand pane, and choose ''New -&amp;gt; Tree'' via the menu.&lt;br /&gt;
** If you already have a Root node, click the &amp;quot;Begin Editing&amp;quot; button instead.&lt;br /&gt;
* Click on the Root node, and set {{keyname|Model}} to the name of the terrain mesh, in this case {{keyvalue|models/terrain/simpleterrain.obj}}.&lt;br /&gt;
* Press {{accelkey|enter}} to confirm the selection, and the terrain should appear in the 3D view.&lt;br /&gt;
&lt;br /&gt;
Be aware that your terrain model will probably appear bright orange or red.&lt;br /&gt;
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!&lt;br /&gt;
&lt;br /&gt;
=== Important note about nodes ===&lt;br /&gt;
When you are editing properties of nodes (names, numbers, texture sources etc.) always remember to hit {{accelkey|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 {{accelkey|enter}}, your changes may not be applied.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Create the first texture node ==&lt;br /&gt;
[[Image:simplemega_firstnode_diffuse.png|thumb|300px|The first texture node's diffuse texture properties]]&lt;br /&gt;
Now that the model is in place, you can start laying down the texture layers (or &amp;quot;nodes&amp;quot;) that will make up your MegaTexture.&lt;br /&gt;
&lt;br /&gt;
First you need to create a new Image Source node in the Terrain Editor.&lt;br /&gt;
* {{accelbtn|RMB}} on your &amp;quot;Root&amp;quot; node and choose ''New -&amp;gt; Image Source'' (or press {{accelkey|shift}}{{accelkey|i}})&lt;br /&gt;
* This will make a new node called &amp;quot;New Image Renderer&amp;quot;.&lt;br /&gt;
* You can rename this new node using the &amp;quot;Name&amp;quot; property field in the '''Object''' section.&lt;br /&gt;
* Rename the node &amp;quot;Dirt&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You will notice in the top right of the Terrain Editor, a section listing things like &amp;quot;Diffuse&amp;quot;, &amp;quot;Distribution&amp;quot;, &amp;quot;Distribution Pattern&amp;quot; etc. Selecting one of these will list all of the properties for that section of the current node.&lt;br /&gt;
The ones we need to worry about are as follows:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Diffuse ====&lt;br /&gt;
This is the colour map of the current node, and it should point to a tiling TGA texture.&lt;br /&gt;
* Make sure the Diffuse section is highlighted in the top right of the Terrain Editor.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to a generic tiling dirt texture. Remember to hit {{accelkey|enter}} afterwards!&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/dirt_02_d.tga}}&lt;br /&gt;
* The {{keyname|Scale}} field at the very bottom of the property list allows you to choose how much to tile the texture.&lt;br /&gt;
** 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!&lt;br /&gt;
** 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.&lt;br /&gt;
That's all you need to do for the Diffuse settings in this node.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Distribution ====&lt;br /&gt;
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''.&lt;br /&gt;
* Make sure the Distribution section is highlighted in the top right.&lt;br /&gt;
* Since this is our first node, we want to show over the whole terrain. This means the distribution map should be 100% white.&lt;br /&gt;
* You can either assign a pure white TGA texture, or change the {{keyname|Source Type}} to {{keyvalue|geometryBased}}.&lt;br /&gt;
** {{keyvalue|geometryBased}} will by default create a fully white map, so if you don't have a white TGA handy, this is faster.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Distribution Pattern ====&lt;br /&gt;
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.&lt;br /&gt;
* 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!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Local ====&lt;br /&gt;
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.&lt;br /&gt;
* Make sure the Local section is highlighted in the top right.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching normal map for your tiling dirt texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/dirt_02_local.tga}}&lt;br /&gt;
* The Local texture's tiling amount is automatically the same as the Diffuse texture.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Surface Type ====&lt;br /&gt;
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.&lt;br /&gt;
* Find the ''Surface Type Properties'' section of the property list.&lt;br /&gt;
* 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.&lt;br /&gt;
* Hit {{accelkey|enter}} to accept the surface type.&lt;br /&gt;
&lt;br /&gt;
Your dirt textures will now produce correct &amp;quot;dirt&amp;quot; effects when shot or collided with!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Previewing the result ====&lt;br /&gt;
[[Image:simplemega_firstnode_preview.jpg|thumb|300px|The Render mode preview of the first node]]&lt;br /&gt;
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]]&lt;br /&gt;
&lt;br /&gt;
* Notice the drop-down arrow on the right of the button. Click it, and select ''&amp;quot;Full&amp;quot;'' instead of ''&amp;quot;None&amp;quot;''.&lt;br /&gt;
* Your terrain should change colour to black. This means it's ready for a preview to be rendered onto it.&lt;br /&gt;
* Click the button itself now, instead of the drop-down. An &amp;quot;Active Tasks&amp;quot; window should pop up, and when it's done, you should see your dirt texture appear on your terrain model.&lt;br /&gt;
* You can switch the camera to Render mode too, which will show your terrain model's shading better.&lt;br /&gt;
* If you want a full-resolution preview of a small area, choose ''&amp;quot;Window&amp;quot;'' instead of ''&amp;quot;Full&amp;quot;'' from the drop-down menu.&lt;br /&gt;
** 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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
'''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.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
== Adding a second node ==&lt;br /&gt;
Now that the first layer of dirt is in place, we can try putting some grass on top of it!&lt;br /&gt;
* Again, {{accelbtn|RMB}} on your &amp;quot;Root&amp;quot; node and choose ''New -&amp;gt; Image Source'' (or press {{accelkey|shift}}{{accelkey|i}})&lt;br /&gt;
* This will make another new node below your &amp;quot;Dirt&amp;quot; node. &lt;br /&gt;
* Name this new node &amp;quot;Grass&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Again, the main map types need to be specified before the node can be rendered:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Diffuse ====&lt;br /&gt;
* Make sure the Diffuse section is highlighted in the top right of the Terrain Editor.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to a generic tiling grass texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/grass_04_d.tga}}&lt;br /&gt;
* 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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Distribution ====&lt;br /&gt;
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!&lt;br /&gt;
* Make sure the Distribution section is highlighted in the top right.&lt;br /&gt;
* Change the {{keyname|Source Type}} from {{keyvalue|texture}} to {{keyvalue|geometryBased}}.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Geometric Texture Distribution ====&lt;br /&gt;
[[Image:simplemega_geometric_distribution.png|thumb|300px|The geometric texture distribution settings of the second node]]&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
* ''Altitude Lower'' - Enabling this will limit the lower parts of the terrain from receiving this node's textures.&lt;br /&gt;
** {{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.&lt;br /&gt;
** {{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.&lt;br /&gt;
* ''Altitude Upper'' - Enabling this will limit the higher parts of the terrain from receiving this node's textures.&lt;br /&gt;
** {{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.&lt;br /&gt;
** {{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.&lt;br /&gt;
&lt;br /&gt;
* {{keyname|Clamp Distribution To Edge}} - Leave this on Default.&lt;br /&gt;
&lt;br /&gt;
* {{keyname|Resolution}} - The size in pixels of the resulting mask. The default value of {{keyvalue|256}} is fine for nearly any terrain model.&lt;br /&gt;
&lt;br /&gt;
* ''Slope Lower'' - Enabling this will limit shallower angles of the terrain model from receiving this node's textures.&lt;br /&gt;
** {{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.&lt;br /&gt;
** {{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.&lt;br /&gt;
* ''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.&lt;br /&gt;
** {{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.&lt;br /&gt;
** {{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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Distribution Pattern ====&lt;br /&gt;
[[Image:simplemega_dist_ramps.jpg|thumb|300px|The difference between using or not using a Distribution Pattern, and varying Ramp Widths]]&lt;br /&gt;
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!&lt;br /&gt;
So what we want here is a texture to identify the &amp;quot;height&amp;quot; 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.&lt;br /&gt;
&lt;br /&gt;
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!&lt;br /&gt;
&lt;br /&gt;
* Make sure {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching heightmap or mask for your tiling grass texture.&lt;br /&gt;
** This example is using {{filename|textures/megagen/temperate/grass_04_mask.tga}}&lt;br /&gt;
* 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 &amp;quot;Window&amp;quot; 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.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Local ====&lt;br /&gt;
Again we want the normal-map which matches the diffuse texture for the grass.&lt;br /&gt;
* Make sure the Local section is highlighted in the top right.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching normal map for your tiling grass texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/grass_04_local.tga}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Surface Type ====&lt;br /&gt;
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.&lt;br /&gt;
* Find the ''Surface Type Properties'' section of the property list.&lt;br /&gt;
* 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.&lt;br /&gt;
* Hit {{accelkey|enter}} to accept the surface type.&lt;br /&gt;
&lt;br /&gt;
Your grass textures should now produce correct &amp;quot;grass&amp;quot; effects when shot or collided with!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Preview again! ===&lt;br /&gt;
[[Image:simplemega_secondnode_preview.jpg|thumb|300px|The Render mode preview of the second node blended with the first node]]&lt;br /&gt;
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.&lt;br /&gt;
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.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
== Adding a third node ==&lt;br /&gt;
[[Image:simplemega_thirdnode_preview.jpg|thumb|300px|The Render mode preview of the third node blended with the other two nodes]]&lt;br /&gt;
Now that the grass and dirt are in place, we need some rocks to make the terrain look more natural.&lt;br /&gt;
* Add a new Image Renderer node below your &amp;quot;Grass&amp;quot; node and name it &amp;quot;Rock&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Again, the main map types need to be specified before the node can be rendered:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Diffuse ====&lt;br /&gt;
* Set the '''Diffuse''' texture and scale.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/rock_01_d.tga}} at a scale of {{keyvalue|32 32}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Distribution ====&lt;br /&gt;
Again we can use Geometric Texture Distribution to easily apply the rock textures only to the cliff-like angles.&lt;br /&gt;
* Make sure the Distribution section is highlighted in the top right.&lt;br /&gt;
* Change the {{keyname|Source Type}} to {{keyvalue|geometryBased}}.&lt;br /&gt;
* 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}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Distribution Pattern ====&lt;br /&gt;
Again this will control how the the rocks blend into the other nodes. Again, we want a texture to identify the &amp;quot;height&amp;quot; of the tiling rock texture.&lt;br /&gt;
&lt;br /&gt;
* Make sure the Distribution Pattern section is highlighted in the top right.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching heightmap or mask for your tiling rock texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/rock_01_h.tga}}&lt;br /&gt;
* 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 &amp;quot;Window&amp;quot; preview to see how the blending looks.&lt;br /&gt;
* Remember to set the {{keyname|Distribution Pattern Texture Scale}} to the same value as the Diffuse Scale, {{keyvalue|32 32}}.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Local ====&lt;br /&gt;
Again we want the normal-map which matches the diffuse texture for the rocks.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Local''' section, browse to the matching normal map for your tiling rock texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/rock_01_local.tga}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Surface Type ====&lt;br /&gt;
* Find the ''Surface Type Properties'' section of the property list.&lt;br /&gt;
* In the {{keyname|Type}} field, enter {{keyvalue|stone}}.&lt;br /&gt;
* Hit {{accelkey|enter}} to accept the surface type.&lt;br /&gt;
&lt;br /&gt;
Your rock textures should now produce correct &amp;quot;stone&amp;quot; effects when shot or collided with.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Preview again! ====&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Further tweaks ==&lt;br /&gt;
There are other simple changes that can be done in the Terrain Editor to make your MegaTexture look even better.&lt;br /&gt;
&lt;br /&gt;
==== Node order ====&lt;br /&gt;
[Image:simplemega_node_order.png|frame|Click and drag a node to change the order]]&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
* {{accelbtn|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.&lt;br /&gt;
* Release {{accelbtn|LMB}} when you have positioned the node in the correct place.&lt;br /&gt;
* 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!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Color changes ==== &lt;br /&gt;
Maybe your dirt texture is too bright? Or maybe your grass looks a little ''too'' green?&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Let's say you want to make the dirt texture darker and a bit more red. Here's how you'd do it:&lt;br /&gt;
* Select your Dirt node.&lt;br /&gt;
* 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).&lt;br /&gt;
* A color wheel and brightness slider will pop up in a new window. You can use this to darken and tint your texture.&lt;br /&gt;
* Choose a darker brightness, and a color slightly towards red. I used '''RGB Values''' of 225, 220, 220.&lt;br /&gt;
* Hit ''OK'' to accept the color.&lt;br /&gt;
* Re-render your MegaTexture preview. You should notice that the dirt layer looks darker now!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Texture rotation ====&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
An easy way to overcome this is to play with the {{keyvname|Rotation}} value in the Texture Properties section of the Terrain Editor's property list.&lt;br /&gt;
For each node, you should also set the {{keyvname|Distribution Pattern Texture Rotation}} to match the Rotation value if you want your distribution patterns to line up and work correctly.&lt;br /&gt;
&lt;br /&gt;
== Render the MegaTexture ==&lt;br /&gt;
=== Save the Surface Tree ===&lt;br /&gt;
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 &amp;quot;Save and Unload&amp;quot; button in the Terrain Editor, or save the whole map.&lt;br /&gt;
&lt;br /&gt;
=== Compile Only Entities ===&lt;br /&gt;
At this stage, your MegaTexture material is still technically &amp;quot;broken&amp;quot;, 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.&lt;br /&gt;
&lt;br /&gt;
However, we need to compile the map in order to tell the [[renderLight]] process which atmosphere to use when lighting the MegaTexture!&lt;br /&gt;
&lt;br /&gt;
So the solution is to do an '''Only Entities''' compile. You can find this in the menu ''Compile -&amp;gt; 2 - Only Entities'' in editWorld. This should be done in a few seconds, and compiles all the information that renderLight needs.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Run the SDK Launcher ===&lt;br /&gt;
Now that your ''.sft'' is saved, go through all the steps outlined in the [[Generate a MegaTexture]] tutorial.&lt;br /&gt;
&lt;br /&gt;
== That's it! ==&lt;br /&gt;
[[Image:simplemega_ingame.jpg|thumb|300px|The MegaTexture in-game!]]&lt;br /&gt;
You've now created your very own MegaTexture to use in your map!&lt;br /&gt;
&lt;br /&gt;
Before you even compile the map, you can get an accurate preview of how it will look in-game by pressing {{accelkey|F6}} to toggle &amp;quot;anim&amp;quot; mode while in editWorld's &amp;quot;RENDER&amp;quot; Camera view (toggled with {{accelkey|F3}}).&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
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:&lt;br /&gt;
* 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.&lt;br /&gt;
* 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 ''&amp;lt; &amp;quot;mapname&amp;quot; &amp;gt;'' part described in [[A Simple First Megatexture#Creating a MegaTexture material|this section]]), otherwise it will not be searching for the correct images.&lt;br /&gt;
* 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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
* [[An Advanced Terrain and Megatexture]] - an advanced guide for complete MegaTexture creation&lt;br /&gt;
* [[Generate a MegaTexture]] - steps for generating a MegaTexture from the SDK launcher.&lt;br /&gt;
* [http://community.enemyterritory.com/forums/showthread.php?t=19326 Forum Thread] - includes textures to download&lt;br /&gt;
&lt;br /&gt;
[[Category:Art]]&lt;br /&gt;
[[Category:Basic Level Design]]&lt;br /&gt;
[[Category:Tutorials]]&lt;/div&gt;</summary>
		<author><name>Ducks</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.splashdamage.com/index.php?title=A_Simple_First_Megatexture&amp;diff=4053</id>
		<title>A Simple First Megatexture</title>
		<link rel="alternate" type="text/html" href="https://wiki.splashdamage.com/index.php?title=A_Simple_First_Megatexture&amp;diff=4053"/>
		<updated>2007-12-17T15:08:04Z</updated>

		<summary type="html">&lt;p&gt;Ducks: /* That's it! */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Image:simplemega_ingame.jpg|right|thumb|500px|A simple MegaTexture, easily created with only 3 texture layers!]]&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
= Introduction =&lt;br /&gt;
'''For this tutorial you must:'''&lt;br /&gt;
* Have a terrain model UV-mapped in the 0-1 range (covered in the simple first terrain tutorial)&lt;br /&gt;
* Have access to some tiling textures.&lt;br /&gt;
* Have a little understanding the ETQW material system&lt;br /&gt;
&lt;br /&gt;
If you don't have any of the above things, you are not ready to do this tutorial!&lt;br /&gt;
&lt;br /&gt;
'''This tutorial covers:'''&lt;br /&gt;
* How to set up a MegaTexture material&lt;br /&gt;
* How to create a Surface Tree&lt;br /&gt;
* How to add texture nodes in the Terrain Editor&lt;br /&gt;
* How to render and compile a full MegaTexture&lt;br /&gt;
&lt;br /&gt;
'''This tutorial does not cover:'''&lt;br /&gt;
* How to use Blender/Maya/Lightwave/ZBrush/Mudbox/3DSMax/Photoshop&lt;br /&gt;
* How to create tiling textures or heightmaps&lt;br /&gt;
* Anything overly complicated&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Creating a MegaTexture material =&lt;br /&gt;
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:&lt;br /&gt;
 material megatextures/mapname		{ useTemplate megatextures/default_ambient&amp;lt; &amp;quot;mapname&amp;quot; &amp;gt; }&lt;br /&gt;
&lt;br /&gt;
This material would automatically search for a MegaTexture called {{filename|mapname.mega}} in the {{filename|/megatextures/}} folder. This example material uses the ''&amp;quot;default_ambient&amp;quot;'' 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]].&lt;br /&gt;
&lt;br /&gt;
Obviously you would want to use the actual name of your map instead of &amp;quot;mapname&amp;quot;, for consistency's sake and ease of reference.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Assigning the material ===&lt;br /&gt;
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).&lt;br /&gt;
Tips on this process can be found in the [[A Simple First Terrain|simple first terrain tutorial]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Creating the Surface Tree =&lt;br /&gt;
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 &amp;quot;Save and Unload&amp;quot; button in the Terrain Editor.&lt;br /&gt;
[[Image:simplemega_terrainmodel.png|thumb|300px|Root node set up to use the correct terrain mesh]]&lt;br /&gt;
&lt;br /&gt;
=== Add the terrain mesh ===&lt;br /&gt;
Here's how you bring the terrain mesh into the surface tree:&lt;br /&gt;
* {{accelbtn|RMB}} on the left-hand pane, and choose ''New -&amp;gt; Tree'' via the menu.&lt;br /&gt;
** If you already have a Root node, click the &amp;quot;Begin Editing&amp;quot; button instead.&lt;br /&gt;
* Click on the Root node, and set {{keyname|Model}} to the name of the terrain mesh, in this case {{keyvalue|models/terrain/simpleterrain.obj}}.&lt;br /&gt;
* Press {{accelkey|enter}} to confirm the selection, and the terrain should appear in the 3D view.&lt;br /&gt;
&lt;br /&gt;
Be aware that your terrain model will probably appear bright orange or red.&lt;br /&gt;
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!&lt;br /&gt;
&lt;br /&gt;
=== Important note about nodes ===&lt;br /&gt;
When you are editing properties of nodes (names, numbers, texture sources etc.) always remember to hit {{accelkey|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 {{accelkey|enter}}, your changes may not be applied.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Create the first texture node ==&lt;br /&gt;
[[Image:simplemega_firstnode_diffuse.png|thumb|300px|The first texture node's diffuse texture properties]]&lt;br /&gt;
Now that the model is in place, you can start laying down the texture layers (or &amp;quot;nodes&amp;quot;) that will make up your MegaTexture.&lt;br /&gt;
&lt;br /&gt;
First you need to create a new Image Source node in the Terrain Editor.&lt;br /&gt;
* {{accelbtn|RMB}} on your &amp;quot;Root&amp;quot; node and choose ''New -&amp;gt; Image Source'' (or press {{accelkey|shift}}{{accelkey|i}})&lt;br /&gt;
* This will make a new node called &amp;quot;New Image Renderer&amp;quot;.&lt;br /&gt;
* You can rename this new node using the &amp;quot;Name&amp;quot; property field in the '''Object''' section.&lt;br /&gt;
* Rename the node &amp;quot;Dirt&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You will notice in the top right of the Terrain Editor, a section listing things like &amp;quot;Diffuse&amp;quot;, &amp;quot;Distribution&amp;quot;, &amp;quot;Distribution Pattern&amp;quot; etc. Selecting one of these will list all of the properties for that section of the current node.&lt;br /&gt;
The ones we need to worry about are as follows:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Diffuse ====&lt;br /&gt;
This is the colour map of the current node, and it should point to a tiling TGA texture.&lt;br /&gt;
* Make sure the Diffuse section is highlighted in the top right of the Terrain Editor.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to a generic tiling dirt texture. Remember to hit {{accelkey|enter}} afterwards!&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/dirt_02_d.tga}}&lt;br /&gt;
* The {{keyname|Scale}} field at the very bottom of the property list allows you to choose how much to tile the texture.&lt;br /&gt;
** 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!&lt;br /&gt;
** 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.&lt;br /&gt;
That's all you need to do for the Diffuse settings in this node.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Distribution ====&lt;br /&gt;
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''.&lt;br /&gt;
* Make sure the Distribution section is highlighted in the top right.&lt;br /&gt;
* Since this is our first node, we want to show over the whole terrain. This means the distribution map should be 100% white.&lt;br /&gt;
* You can either assign a pure white TGA texture, or change the {{keyname|Source Type}} to {{keyvalue|geometryBased}}.&lt;br /&gt;
** {{keyvalue|geometryBased}} will by default create a fully white map, so if you don't have a white TGA handy, this is faster.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Distribution Pattern ====&lt;br /&gt;
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.&lt;br /&gt;
* 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!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Local ====&lt;br /&gt;
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.&lt;br /&gt;
* Make sure the Local section is highlighted in the top right.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching normal map for your tiling dirt texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/dirt_02_local.tga}}&lt;br /&gt;
* The Local texture's tiling amount is automatically the same as the Diffuse texture.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Surface Type ====&lt;br /&gt;
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.&lt;br /&gt;
* Find the ''Surface Type Properties'' section of the property list.&lt;br /&gt;
* 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.&lt;br /&gt;
* Hit {{accelkey|enter}} to accept the surface type.&lt;br /&gt;
&lt;br /&gt;
Your dirt textures will now produce correct &amp;quot;dirt&amp;quot; effects when shot or collided with!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Previewing the result ====&lt;br /&gt;
[[Image:simplemega_firstnode_preview.jpg|thumb|300px|The Render mode preview of the first node]]&lt;br /&gt;
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]]&lt;br /&gt;
&lt;br /&gt;
* Notice the drop-down arrow on the right of the button. Click it, and select ''&amp;quot;Full&amp;quot;'' instead of ''&amp;quot;None&amp;quot;''.&lt;br /&gt;
* Your terrain should change colour to black. This means it's ready for a preview to be rendered onto it.&lt;br /&gt;
* Click the button itself now, instead of the drop-down. An &amp;quot;Active Tasks&amp;quot; window should pop up, and when it's done, you should see your dirt texture appear on your terrain model.&lt;br /&gt;
* You can switch the camera to Render mode too, which will show your terrain model's shading better.&lt;br /&gt;
* If you want a full-resolution preview of a small area, choose ''&amp;quot;Window&amp;quot;'' instead of ''&amp;quot;Full&amp;quot;'' from the drop-down menu.&lt;br /&gt;
** 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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
'''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.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
== Adding a second node ==&lt;br /&gt;
Now that the first layer of dirt is in place, we can try putting some grass on top of it!&lt;br /&gt;
* Again, {{accelbtn|RMB}} on your &amp;quot;Root&amp;quot; node and choose ''New -&amp;gt; Image Source'' (or press {{accelkey|shift}}{{accelkey|i}})&lt;br /&gt;
* This will make another new node below your &amp;quot;Dirt&amp;quot; node. &lt;br /&gt;
* Name this new node &amp;quot;Grass&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Again, the main map types need to be specified before the node can be rendered:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Diffuse ====&lt;br /&gt;
* Make sure the Diffuse section is highlighted in the top right of the Terrain Editor.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to a generic tiling grass texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/grass_04_d.tga}}&lt;br /&gt;
* 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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Distribution ====&lt;br /&gt;
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!&lt;br /&gt;
* Make sure the Distribution section is highlighted in the top right.&lt;br /&gt;
* Change the {{keyname|Source Type}} from {{keyvalue|texture}} to {{keyvalue|geometryBased}}.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Geometric Texture Distribution ====&lt;br /&gt;
[[Image:simplemega_geometric_distribution.png|thumb|300px|The geometric texture distribution settings of the second node]]&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
* ''Altitude Lower'' - Enabling this will limit the lower parts of the terrain from receiving this node's textures.&lt;br /&gt;
** {{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.&lt;br /&gt;
** {{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.&lt;br /&gt;
* ''Altitude Upper'' - Enabling this will limit the higher parts of the terrain from receiving this node's textures.&lt;br /&gt;
** {{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.&lt;br /&gt;
** {{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.&lt;br /&gt;
&lt;br /&gt;
* {{keyname|Clamp Distribution To Edge}} - Leave this on Default.&lt;br /&gt;
&lt;br /&gt;
* {{keyname|Resolution}} - The size in pixels of the resulting mask. The default value of {{keyvalue|256}} is fine for nearly any terrain model.&lt;br /&gt;
&lt;br /&gt;
* ''Slope Lower'' - Enabling this will limit shallower angles of the terrain model from receiving this node's textures.&lt;br /&gt;
** {{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.&lt;br /&gt;
** {{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.&lt;br /&gt;
* ''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.&lt;br /&gt;
** {{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.&lt;br /&gt;
** {{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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Distribution Pattern ====&lt;br /&gt;
[[Image:simplemega_dist_ramps.jpg|thumb|300px|The difference between using or not using a Distribution Pattern, and varying Ramp Widths]]&lt;br /&gt;
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!&lt;br /&gt;
So what we want here is a texture to identify the &amp;quot;height&amp;quot; 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.&lt;br /&gt;
&lt;br /&gt;
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!&lt;br /&gt;
&lt;br /&gt;
* Make sure {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching heightmap or mask for your tiling grass texture.&lt;br /&gt;
** This example is using {{filename|textures/megagen/temperate/grass_04_mask.tga}}&lt;br /&gt;
* 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 &amp;quot;Window&amp;quot; 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.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Local ====&lt;br /&gt;
Again we want the normal-map which matches the diffuse texture for the grass.&lt;br /&gt;
* Make sure the Local section is highlighted in the top right.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching normal map for your tiling grass texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/grass_04_local.tga}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Surface Type ====&lt;br /&gt;
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.&lt;br /&gt;
* Find the ''Surface Type Properties'' section of the property list.&lt;br /&gt;
* 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.&lt;br /&gt;
* Hit {{accelkey|enter}} to accept the surface type.&lt;br /&gt;
&lt;br /&gt;
Your grass textures should now produce correct &amp;quot;grass&amp;quot; effects when shot or collided with!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Preview again! ===&lt;br /&gt;
[[Image:simplemega_secondnode_preview.jpg|thumb|300px|The Render mode preview of the second node blended with the first node]]&lt;br /&gt;
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.&lt;br /&gt;
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.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
== Adding a third node ==&lt;br /&gt;
[[Image:simplemega_thirdnode_preview.jpg|thumb|300px|The Render mode preview of the third node blended with the other two nodes]]&lt;br /&gt;
Now that the grass and dirt are in place, we need some rocks to make the terrain look more natural.&lt;br /&gt;
* Add a new Image Renderer node below your &amp;quot;Grass&amp;quot; node and name it &amp;quot;Rock&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Again, the main map types need to be specified before the node can be rendered:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Diffuse ====&lt;br /&gt;
* Set the '''Diffuse''' texture and scale.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/rock_01_d.tga}} at a scale of {{keyvalue|32 32}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Distribution ====&lt;br /&gt;
Again we can use Geometric Texture Distribution to easily apply the rock textures only to the cliff-like angles.&lt;br /&gt;
* Make sure the Distribution section is highlighted in the top right.&lt;br /&gt;
* Change the {{keyname|Source Type}} to {{keyvalue|geometryBased}}.&lt;br /&gt;
* 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}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Distribution Pattern ====&lt;br /&gt;
Again this will control how the the rocks blend into the other nodes. Again, we want a texture to identify the &amp;quot;height&amp;quot; of the tiling rock texture.&lt;br /&gt;
&lt;br /&gt;
* Make sure the Distribution Pattern section is highlighted in the top right.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching heightmap or mask for your tiling rock texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/rock_01_h.tga}}&lt;br /&gt;
* 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 &amp;quot;Window&amp;quot; preview to see how the blending looks.&lt;br /&gt;
* Remember to set the {{keyname|Distribution Pattern Texture Scale}} to the same value as the Diffuse Scale, {{keyvalue|32 32}}.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Local ====&lt;br /&gt;
Again we want the normal-map which matches the diffuse texture for the rocks.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Local''' section, browse to the matching normal map for your tiling rock texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/rock_01_local.tga}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Surface Type ====&lt;br /&gt;
* Find the ''Surface Type Properties'' section of the property list.&lt;br /&gt;
* In the {{keyname|Type}} field, enter {{keyvalue|stone}}.&lt;br /&gt;
* Hit {{accelkey|enter}} to accept the surface type.&lt;br /&gt;
&lt;br /&gt;
Your rock textures should now produce correct &amp;quot;stone&amp;quot; effects when shot or collided with.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Preview again! ====&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Further tweaks ==&lt;br /&gt;
There are other simple changes that can be done in the Terrain Editor to make your MegaTexture look even better.&lt;br /&gt;
&lt;br /&gt;
==== Node order ====&lt;br /&gt;
[Image:simplemega_node_order.png|frame|Click and drag a node to change the order]]&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
* {{accelbtn|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.&lt;br /&gt;
* Release {{accelbtn|LMB}} when you have positioned the node in the correct place.&lt;br /&gt;
* 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!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Color changes ==== &lt;br /&gt;
Maybe your dirt texture is too bright? Or maybe your grass looks a little ''too'' green?&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Let's say you want to make the dirt texture darker and a bit more red. Here's how you'd do it:&lt;br /&gt;
* Select your Dirt node.&lt;br /&gt;
* 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).&lt;br /&gt;
* A color wheel and brightness slider will pop up in a new window. You can use this to darken and tint your texture.&lt;br /&gt;
* Choose a darker brightness, and a color slightly towards red. I used '''RGB Values''' of 225, 220, 220.&lt;br /&gt;
* Hit ''OK'' to accept the color.&lt;br /&gt;
* Re-render your MegaTexture preview. You should notice that the dirt layer looks darker now!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Texture rotation ====&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
An easy way to overcome this is to play with the {{keyvname|Rotation}} value in the Texture Properties section of the Terrain Editor's property list.&lt;br /&gt;
For each node, you should also set the {{keyvname|Distribution Pattern Texture Rotation}} to match the Rotation value if you want your distribution patterns to line up and work correctly.&lt;br /&gt;
&lt;br /&gt;
== Render the MegaTexture ==&lt;br /&gt;
=== Save the Surface Tree ===&lt;br /&gt;
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 &amp;quot;Save and Unload&amp;quot; button in the Terrain Editor, or save the whole map.&lt;br /&gt;
&lt;br /&gt;
=== Compile Only Entities ===&lt;br /&gt;
At this stage, your MegaTexture material is still technically &amp;quot;broken&amp;quot;, 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.&lt;br /&gt;
&lt;br /&gt;
However, we need to compile the map in order to tell the [[renderLight]] process which atmosphere to use when lighting the MegaTexture!&lt;br /&gt;
&lt;br /&gt;
So the solution is to do an '''Only Entities''' compile. You can find this in the menu ''Compile -&amp;gt; 2 - Only Entities'' in editWorld. This should be done in a few seconds, and compiles all the information that renderLight needs.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Run the SDK Launcher ===&lt;br /&gt;
Now that your ''.sft'' is saved, go through all the steps outlined in the [[Generate a MegaTexture]] tutorial.&lt;br /&gt;
&lt;br /&gt;
== That's it! ==&lt;br /&gt;
[[Image:simplemega_ingame.jpg|thumb|300px|The MegaTexture in-game!]]&lt;br /&gt;
You've now created your very own MegaTexture to use in your map!&lt;br /&gt;
&lt;br /&gt;
Before you even compile the map, you can get an accurate preview of how it will look in-game by pressing {{accelkey|F6}} to toggle &amp;quot;anim&amp;quot; mode while in editWorld's &amp;quot;RENDER&amp;quot; Camera view (toggled with {{accelkey|F3}}).&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
= Troubleshooting =&lt;br /&gt;
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:&lt;br /&gt;
* 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.&lt;br /&gt;
* 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 ''&amp;lt; &amp;quot;mapname&amp;quot; &amp;gt;'' part described in [[A Simple First Megatexture#Creating a MegaTexture material|this section]]), otherwise it will not be searching for the correct images.&lt;br /&gt;
* 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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
= See Also =&lt;br /&gt;
* [[An Advanced Terrain and Megatexture]] - an advanced guide for complete MegaTexture creation&lt;br /&gt;
* [[Generate a MegaTexture]] - steps for generating a MegaTexture from the SDK launcher.&lt;br /&gt;
* [http://community.enemyterritory.com/forums/showthread.php?t=19326 Forum Thread] - includes textures to download&lt;br /&gt;
&lt;br /&gt;
[[Category:Art]]&lt;br /&gt;
[[Category:Basic Level Design]]&lt;br /&gt;
[[Category:Tutorials]]&lt;/div&gt;</summary>
		<author><name>Ducks</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.splashdamage.com/index.php?title=A_Simple_First_Megatexture&amp;diff=4052</id>
		<title>A Simple First Megatexture</title>
		<link rel="alternate" type="text/html" href="https://wiki.splashdamage.com/index.php?title=A_Simple_First_Megatexture&amp;diff=4052"/>
		<updated>2007-12-17T15:07:54Z</updated>

		<summary type="html">&lt;p&gt;Ducks: /* Render the MegaTexture */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Image:simplemega_ingame.jpg|right|thumb|500px|A simple MegaTexture, easily created with only 3 texture layers!]]&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
= Introduction =&lt;br /&gt;
'''For this tutorial you must:'''&lt;br /&gt;
* Have a terrain model UV-mapped in the 0-1 range (covered in the simple first terrain tutorial)&lt;br /&gt;
* Have access to some tiling textures.&lt;br /&gt;
* Have a little understanding the ETQW material system&lt;br /&gt;
&lt;br /&gt;
If you don't have any of the above things, you are not ready to do this tutorial!&lt;br /&gt;
&lt;br /&gt;
'''This tutorial covers:'''&lt;br /&gt;
* How to set up a MegaTexture material&lt;br /&gt;
* How to create a Surface Tree&lt;br /&gt;
* How to add texture nodes in the Terrain Editor&lt;br /&gt;
* How to render and compile a full MegaTexture&lt;br /&gt;
&lt;br /&gt;
'''This tutorial does not cover:'''&lt;br /&gt;
* How to use Blender/Maya/Lightwave/ZBrush/Mudbox/3DSMax/Photoshop&lt;br /&gt;
* How to create tiling textures or heightmaps&lt;br /&gt;
* Anything overly complicated&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Creating a MegaTexture material =&lt;br /&gt;
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:&lt;br /&gt;
 material megatextures/mapname		{ useTemplate megatextures/default_ambient&amp;lt; &amp;quot;mapname&amp;quot; &amp;gt; }&lt;br /&gt;
&lt;br /&gt;
This material would automatically search for a MegaTexture called {{filename|mapname.mega}} in the {{filename|/megatextures/}} folder. This example material uses the ''&amp;quot;default_ambient&amp;quot;'' 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]].&lt;br /&gt;
&lt;br /&gt;
Obviously you would want to use the actual name of your map instead of &amp;quot;mapname&amp;quot;, for consistency's sake and ease of reference.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Assigning the material ===&lt;br /&gt;
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).&lt;br /&gt;
Tips on this process can be found in the [[A Simple First Terrain|simple first terrain tutorial]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Creating the Surface Tree =&lt;br /&gt;
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 &amp;quot;Save and Unload&amp;quot; button in the Terrain Editor.&lt;br /&gt;
[[Image:simplemega_terrainmodel.png|thumb|300px|Root node set up to use the correct terrain mesh]]&lt;br /&gt;
&lt;br /&gt;
=== Add the terrain mesh ===&lt;br /&gt;
Here's how you bring the terrain mesh into the surface tree:&lt;br /&gt;
* {{accelbtn|RMB}} on the left-hand pane, and choose ''New -&amp;gt; Tree'' via the menu.&lt;br /&gt;
** If you already have a Root node, click the &amp;quot;Begin Editing&amp;quot; button instead.&lt;br /&gt;
* Click on the Root node, and set {{keyname|Model}} to the name of the terrain mesh, in this case {{keyvalue|models/terrain/simpleterrain.obj}}.&lt;br /&gt;
* Press {{accelkey|enter}} to confirm the selection, and the terrain should appear in the 3D view.&lt;br /&gt;
&lt;br /&gt;
Be aware that your terrain model will probably appear bright orange or red.&lt;br /&gt;
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!&lt;br /&gt;
&lt;br /&gt;
=== Important note about nodes ===&lt;br /&gt;
When you are editing properties of nodes (names, numbers, texture sources etc.) always remember to hit {{accelkey|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 {{accelkey|enter}}, your changes may not be applied.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Create the first texture node ==&lt;br /&gt;
[[Image:simplemega_firstnode_diffuse.png|thumb|300px|The first texture node's diffuse texture properties]]&lt;br /&gt;
Now that the model is in place, you can start laying down the texture layers (or &amp;quot;nodes&amp;quot;) that will make up your MegaTexture.&lt;br /&gt;
&lt;br /&gt;
First you need to create a new Image Source node in the Terrain Editor.&lt;br /&gt;
* {{accelbtn|RMB}} on your &amp;quot;Root&amp;quot; node and choose ''New -&amp;gt; Image Source'' (or press {{accelkey|shift}}{{accelkey|i}})&lt;br /&gt;
* This will make a new node called &amp;quot;New Image Renderer&amp;quot;.&lt;br /&gt;
* You can rename this new node using the &amp;quot;Name&amp;quot; property field in the '''Object''' section.&lt;br /&gt;
* Rename the node &amp;quot;Dirt&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You will notice in the top right of the Terrain Editor, a section listing things like &amp;quot;Diffuse&amp;quot;, &amp;quot;Distribution&amp;quot;, &amp;quot;Distribution Pattern&amp;quot; etc. Selecting one of these will list all of the properties for that section of the current node.&lt;br /&gt;
The ones we need to worry about are as follows:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Diffuse ====&lt;br /&gt;
This is the colour map of the current node, and it should point to a tiling TGA texture.&lt;br /&gt;
* Make sure the Diffuse section is highlighted in the top right of the Terrain Editor.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to a generic tiling dirt texture. Remember to hit {{accelkey|enter}} afterwards!&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/dirt_02_d.tga}}&lt;br /&gt;
* The {{keyname|Scale}} field at the very bottom of the property list allows you to choose how much to tile the texture.&lt;br /&gt;
** 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!&lt;br /&gt;
** 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.&lt;br /&gt;
That's all you need to do for the Diffuse settings in this node.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Distribution ====&lt;br /&gt;
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''.&lt;br /&gt;
* Make sure the Distribution section is highlighted in the top right.&lt;br /&gt;
* Since this is our first node, we want to show over the whole terrain. This means the distribution map should be 100% white.&lt;br /&gt;
* You can either assign a pure white TGA texture, or change the {{keyname|Source Type}} to {{keyvalue|geometryBased}}.&lt;br /&gt;
** {{keyvalue|geometryBased}} will by default create a fully white map, so if you don't have a white TGA handy, this is faster.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Distribution Pattern ====&lt;br /&gt;
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.&lt;br /&gt;
* 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!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Local ====&lt;br /&gt;
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.&lt;br /&gt;
* Make sure the Local section is highlighted in the top right.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching normal map for your tiling dirt texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/dirt_02_local.tga}}&lt;br /&gt;
* The Local texture's tiling amount is automatically the same as the Diffuse texture.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Surface Type ====&lt;br /&gt;
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.&lt;br /&gt;
* Find the ''Surface Type Properties'' section of the property list.&lt;br /&gt;
* 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.&lt;br /&gt;
* Hit {{accelkey|enter}} to accept the surface type.&lt;br /&gt;
&lt;br /&gt;
Your dirt textures will now produce correct &amp;quot;dirt&amp;quot; effects when shot or collided with!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Previewing the result ====&lt;br /&gt;
[[Image:simplemega_firstnode_preview.jpg|thumb|300px|The Render mode preview of the first node]]&lt;br /&gt;
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]]&lt;br /&gt;
&lt;br /&gt;
* Notice the drop-down arrow on the right of the button. Click it, and select ''&amp;quot;Full&amp;quot;'' instead of ''&amp;quot;None&amp;quot;''.&lt;br /&gt;
* Your terrain should change colour to black. This means it's ready for a preview to be rendered onto it.&lt;br /&gt;
* Click the button itself now, instead of the drop-down. An &amp;quot;Active Tasks&amp;quot; window should pop up, and when it's done, you should see your dirt texture appear on your terrain model.&lt;br /&gt;
* You can switch the camera to Render mode too, which will show your terrain model's shading better.&lt;br /&gt;
* If you want a full-resolution preview of a small area, choose ''&amp;quot;Window&amp;quot;'' instead of ''&amp;quot;Full&amp;quot;'' from the drop-down menu.&lt;br /&gt;
** 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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
'''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.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
== Adding a second node ==&lt;br /&gt;
Now that the first layer of dirt is in place, we can try putting some grass on top of it!&lt;br /&gt;
* Again, {{accelbtn|RMB}} on your &amp;quot;Root&amp;quot; node and choose ''New -&amp;gt; Image Source'' (or press {{accelkey|shift}}{{accelkey|i}})&lt;br /&gt;
* This will make another new node below your &amp;quot;Dirt&amp;quot; node. &lt;br /&gt;
* Name this new node &amp;quot;Grass&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Again, the main map types need to be specified before the node can be rendered:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Diffuse ====&lt;br /&gt;
* Make sure the Diffuse section is highlighted in the top right of the Terrain Editor.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to a generic tiling grass texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/grass_04_d.tga}}&lt;br /&gt;
* 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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Distribution ====&lt;br /&gt;
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!&lt;br /&gt;
* Make sure the Distribution section is highlighted in the top right.&lt;br /&gt;
* Change the {{keyname|Source Type}} from {{keyvalue|texture}} to {{keyvalue|geometryBased}}.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Geometric Texture Distribution ====&lt;br /&gt;
[[Image:simplemega_geometric_distribution.png|thumb|300px|The geometric texture distribution settings of the second node]]&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
* ''Altitude Lower'' - Enabling this will limit the lower parts of the terrain from receiving this node's textures.&lt;br /&gt;
** {{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.&lt;br /&gt;
** {{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.&lt;br /&gt;
* ''Altitude Upper'' - Enabling this will limit the higher parts of the terrain from receiving this node's textures.&lt;br /&gt;
** {{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.&lt;br /&gt;
** {{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.&lt;br /&gt;
&lt;br /&gt;
* {{keyname|Clamp Distribution To Edge}} - Leave this on Default.&lt;br /&gt;
&lt;br /&gt;
* {{keyname|Resolution}} - The size in pixels of the resulting mask. The default value of {{keyvalue|256}} is fine for nearly any terrain model.&lt;br /&gt;
&lt;br /&gt;
* ''Slope Lower'' - Enabling this will limit shallower angles of the terrain model from receiving this node's textures.&lt;br /&gt;
** {{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.&lt;br /&gt;
** {{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.&lt;br /&gt;
* ''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.&lt;br /&gt;
** {{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.&lt;br /&gt;
** {{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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Distribution Pattern ====&lt;br /&gt;
[[Image:simplemega_dist_ramps.jpg|thumb|300px|The difference between using or not using a Distribution Pattern, and varying Ramp Widths]]&lt;br /&gt;
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!&lt;br /&gt;
So what we want here is a texture to identify the &amp;quot;height&amp;quot; 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.&lt;br /&gt;
&lt;br /&gt;
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!&lt;br /&gt;
&lt;br /&gt;
* Make sure {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching heightmap or mask for your tiling grass texture.&lt;br /&gt;
** This example is using {{filename|textures/megagen/temperate/grass_04_mask.tga}}&lt;br /&gt;
* 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 &amp;quot;Window&amp;quot; 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.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Local ====&lt;br /&gt;
Again we want the normal-map which matches the diffuse texture for the grass.&lt;br /&gt;
* Make sure the Local section is highlighted in the top right.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching normal map for your tiling grass texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/grass_04_local.tga}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Surface Type ====&lt;br /&gt;
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.&lt;br /&gt;
* Find the ''Surface Type Properties'' section of the property list.&lt;br /&gt;
* 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.&lt;br /&gt;
* Hit {{accelkey|enter}} to accept the surface type.&lt;br /&gt;
&lt;br /&gt;
Your grass textures should now produce correct &amp;quot;grass&amp;quot; effects when shot or collided with!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Preview again! ===&lt;br /&gt;
[[Image:simplemega_secondnode_preview.jpg|thumb|300px|The Render mode preview of the second node blended with the first node]]&lt;br /&gt;
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.&lt;br /&gt;
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.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
== Adding a third node ==&lt;br /&gt;
[[Image:simplemega_thirdnode_preview.jpg|thumb|300px|The Render mode preview of the third node blended with the other two nodes]]&lt;br /&gt;
Now that the grass and dirt are in place, we need some rocks to make the terrain look more natural.&lt;br /&gt;
* Add a new Image Renderer node below your &amp;quot;Grass&amp;quot; node and name it &amp;quot;Rock&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Again, the main map types need to be specified before the node can be rendered:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Diffuse ====&lt;br /&gt;
* Set the '''Diffuse''' texture and scale.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/rock_01_d.tga}} at a scale of {{keyvalue|32 32}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Distribution ====&lt;br /&gt;
Again we can use Geometric Texture Distribution to easily apply the rock textures only to the cliff-like angles.&lt;br /&gt;
* Make sure the Distribution section is highlighted in the top right.&lt;br /&gt;
* Change the {{keyname|Source Type}} to {{keyvalue|geometryBased}}.&lt;br /&gt;
* 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}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Distribution Pattern ====&lt;br /&gt;
Again this will control how the the rocks blend into the other nodes. Again, we want a texture to identify the &amp;quot;height&amp;quot; of the tiling rock texture.&lt;br /&gt;
&lt;br /&gt;
* Make sure the Distribution Pattern section is highlighted in the top right.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching heightmap or mask for your tiling rock texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/rock_01_h.tga}}&lt;br /&gt;
* 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 &amp;quot;Window&amp;quot; preview to see how the blending looks.&lt;br /&gt;
* Remember to set the {{keyname|Distribution Pattern Texture Scale}} to the same value as the Diffuse Scale, {{keyvalue|32 32}}.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Local ====&lt;br /&gt;
Again we want the normal-map which matches the diffuse texture for the rocks.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Local''' section, browse to the matching normal map for your tiling rock texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/rock_01_local.tga}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Surface Type ====&lt;br /&gt;
* Find the ''Surface Type Properties'' section of the property list.&lt;br /&gt;
* In the {{keyname|Type}} field, enter {{keyvalue|stone}}.&lt;br /&gt;
* Hit {{accelkey|enter}} to accept the surface type.&lt;br /&gt;
&lt;br /&gt;
Your rock textures should now produce correct &amp;quot;stone&amp;quot; effects when shot or collided with.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Preview again! ====&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Further tweaks ==&lt;br /&gt;
There are other simple changes that can be done in the Terrain Editor to make your MegaTexture look even better.&lt;br /&gt;
&lt;br /&gt;
==== Node order ====&lt;br /&gt;
[Image:simplemega_node_order.png|frame|Click and drag a node to change the order]]&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
* {{accelbtn|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.&lt;br /&gt;
* Release {{accelbtn|LMB}} when you have positioned the node in the correct place.&lt;br /&gt;
* 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!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Color changes ==== &lt;br /&gt;
Maybe your dirt texture is too bright? Or maybe your grass looks a little ''too'' green?&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Let's say you want to make the dirt texture darker and a bit more red. Here's how you'd do it:&lt;br /&gt;
* Select your Dirt node.&lt;br /&gt;
* 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).&lt;br /&gt;
* A color wheel and brightness slider will pop up in a new window. You can use this to darken and tint your texture.&lt;br /&gt;
* Choose a darker brightness, and a color slightly towards red. I used '''RGB Values''' of 225, 220, 220.&lt;br /&gt;
* Hit ''OK'' to accept the color.&lt;br /&gt;
* Re-render your MegaTexture preview. You should notice that the dirt layer looks darker now!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Texture rotation ====&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
An easy way to overcome this is to play with the {{keyvname|Rotation}} value in the Texture Properties section of the Terrain Editor's property list.&lt;br /&gt;
For each node, you should also set the {{keyvname|Distribution Pattern Texture Rotation}} to match the Rotation value if you want your distribution patterns to line up and work correctly.&lt;br /&gt;
&lt;br /&gt;
== Render the MegaTexture ==&lt;br /&gt;
=== Save the Surface Tree ===&lt;br /&gt;
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 &amp;quot;Save and Unload&amp;quot; button in the Terrain Editor, or save the whole map.&lt;br /&gt;
&lt;br /&gt;
=== Compile Only Entities ===&lt;br /&gt;
At this stage, your MegaTexture material is still technically &amp;quot;broken&amp;quot;, 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.&lt;br /&gt;
&lt;br /&gt;
However, we need to compile the map in order to tell the [[renderLight]] process which atmosphere to use when lighting the MegaTexture!&lt;br /&gt;
&lt;br /&gt;
So the solution is to do an '''Only Entities''' compile. You can find this in the menu ''Compile -&amp;gt; 2 - Only Entities'' in editWorld. This should be done in a few seconds, and compiles all the information that renderLight needs.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Run the SDK Launcher ===&lt;br /&gt;
Now that your ''.sft'' is saved, go through all the steps outlined in the [[Generate a MegaTexture]] tutorial.&lt;br /&gt;
&lt;br /&gt;
= That's it! =&lt;br /&gt;
[[Image:simplemega_ingame.jpg|thumb|300px|The MegaTexture in-game!]]&lt;br /&gt;
You've now created your very own MegaTexture to use in your map!&lt;br /&gt;
&lt;br /&gt;
Before you even compile the map, you can get an accurate preview of how it will look in-game by pressing {{accelkey|F6}} to toggle &amp;quot;anim&amp;quot; mode while in editWorld's &amp;quot;RENDER&amp;quot; Camera view (toggled with {{accelkey|F3}}).&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
= Troubleshooting =&lt;br /&gt;
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:&lt;br /&gt;
* 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.&lt;br /&gt;
* 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 ''&amp;lt; &amp;quot;mapname&amp;quot; &amp;gt;'' part described in [[A Simple First Megatexture#Creating a MegaTexture material|this section]]), otherwise it will not be searching for the correct images.&lt;br /&gt;
* 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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
= See Also =&lt;br /&gt;
* [[An Advanced Terrain and Megatexture]] - an advanced guide for complete MegaTexture creation&lt;br /&gt;
* [[Generate a MegaTexture]] - steps for generating a MegaTexture from the SDK launcher.&lt;br /&gt;
* [http://community.enemyterritory.com/forums/showthread.php?t=19326 Forum Thread] - includes textures to download&lt;br /&gt;
&lt;br /&gt;
[[Category:Art]]&lt;br /&gt;
[[Category:Basic Level Design]]&lt;br /&gt;
[[Category:Tutorials]]&lt;/div&gt;</summary>
		<author><name>Ducks</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.splashdamage.com/index.php?title=A_Simple_First_Megatexture&amp;diff=4051</id>
		<title>A Simple First Megatexture</title>
		<link rel="alternate" type="text/html" href="https://wiki.splashdamage.com/index.php?title=A_Simple_First_Megatexture&amp;diff=4051"/>
		<updated>2007-12-17T15:07:45Z</updated>

		<summary type="html">&lt;p&gt;Ducks: /* Further tweaks */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Image:simplemega_ingame.jpg|right|thumb|500px|A simple MegaTexture, easily created with only 3 texture layers!]]&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
= Introduction =&lt;br /&gt;
'''For this tutorial you must:'''&lt;br /&gt;
* Have a terrain model UV-mapped in the 0-1 range (covered in the simple first terrain tutorial)&lt;br /&gt;
* Have access to some tiling textures.&lt;br /&gt;
* Have a little understanding the ETQW material system&lt;br /&gt;
&lt;br /&gt;
If you don't have any of the above things, you are not ready to do this tutorial!&lt;br /&gt;
&lt;br /&gt;
'''This tutorial covers:'''&lt;br /&gt;
* How to set up a MegaTexture material&lt;br /&gt;
* How to create a Surface Tree&lt;br /&gt;
* How to add texture nodes in the Terrain Editor&lt;br /&gt;
* How to render and compile a full MegaTexture&lt;br /&gt;
&lt;br /&gt;
'''This tutorial does not cover:'''&lt;br /&gt;
* How to use Blender/Maya/Lightwave/ZBrush/Mudbox/3DSMax/Photoshop&lt;br /&gt;
* How to create tiling textures or heightmaps&lt;br /&gt;
* Anything overly complicated&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Creating a MegaTexture material =&lt;br /&gt;
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:&lt;br /&gt;
 material megatextures/mapname		{ useTemplate megatextures/default_ambient&amp;lt; &amp;quot;mapname&amp;quot; &amp;gt; }&lt;br /&gt;
&lt;br /&gt;
This material would automatically search for a MegaTexture called {{filename|mapname.mega}} in the {{filename|/megatextures/}} folder. This example material uses the ''&amp;quot;default_ambient&amp;quot;'' 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]].&lt;br /&gt;
&lt;br /&gt;
Obviously you would want to use the actual name of your map instead of &amp;quot;mapname&amp;quot;, for consistency's sake and ease of reference.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Assigning the material ===&lt;br /&gt;
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).&lt;br /&gt;
Tips on this process can be found in the [[A Simple First Terrain|simple first terrain tutorial]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Creating the Surface Tree =&lt;br /&gt;
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 &amp;quot;Save and Unload&amp;quot; button in the Terrain Editor.&lt;br /&gt;
[[Image:simplemega_terrainmodel.png|thumb|300px|Root node set up to use the correct terrain mesh]]&lt;br /&gt;
&lt;br /&gt;
=== Add the terrain mesh ===&lt;br /&gt;
Here's how you bring the terrain mesh into the surface tree:&lt;br /&gt;
* {{accelbtn|RMB}} on the left-hand pane, and choose ''New -&amp;gt; Tree'' via the menu.&lt;br /&gt;
** If you already have a Root node, click the &amp;quot;Begin Editing&amp;quot; button instead.&lt;br /&gt;
* Click on the Root node, and set {{keyname|Model}} to the name of the terrain mesh, in this case {{keyvalue|models/terrain/simpleterrain.obj}}.&lt;br /&gt;
* Press {{accelkey|enter}} to confirm the selection, and the terrain should appear in the 3D view.&lt;br /&gt;
&lt;br /&gt;
Be aware that your terrain model will probably appear bright orange or red.&lt;br /&gt;
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!&lt;br /&gt;
&lt;br /&gt;
=== Important note about nodes ===&lt;br /&gt;
When you are editing properties of nodes (names, numbers, texture sources etc.) always remember to hit {{accelkey|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 {{accelkey|enter}}, your changes may not be applied.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Create the first texture node ==&lt;br /&gt;
[[Image:simplemega_firstnode_diffuse.png|thumb|300px|The first texture node's diffuse texture properties]]&lt;br /&gt;
Now that the model is in place, you can start laying down the texture layers (or &amp;quot;nodes&amp;quot;) that will make up your MegaTexture.&lt;br /&gt;
&lt;br /&gt;
First you need to create a new Image Source node in the Terrain Editor.&lt;br /&gt;
* {{accelbtn|RMB}} on your &amp;quot;Root&amp;quot; node and choose ''New -&amp;gt; Image Source'' (or press {{accelkey|shift}}{{accelkey|i}})&lt;br /&gt;
* This will make a new node called &amp;quot;New Image Renderer&amp;quot;.&lt;br /&gt;
* You can rename this new node using the &amp;quot;Name&amp;quot; property field in the '''Object''' section.&lt;br /&gt;
* Rename the node &amp;quot;Dirt&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You will notice in the top right of the Terrain Editor, a section listing things like &amp;quot;Diffuse&amp;quot;, &amp;quot;Distribution&amp;quot;, &amp;quot;Distribution Pattern&amp;quot; etc. Selecting one of these will list all of the properties for that section of the current node.&lt;br /&gt;
The ones we need to worry about are as follows:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Diffuse ====&lt;br /&gt;
This is the colour map of the current node, and it should point to a tiling TGA texture.&lt;br /&gt;
* Make sure the Diffuse section is highlighted in the top right of the Terrain Editor.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to a generic tiling dirt texture. Remember to hit {{accelkey|enter}} afterwards!&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/dirt_02_d.tga}}&lt;br /&gt;
* The {{keyname|Scale}} field at the very bottom of the property list allows you to choose how much to tile the texture.&lt;br /&gt;
** 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!&lt;br /&gt;
** 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.&lt;br /&gt;
That's all you need to do for the Diffuse settings in this node.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Distribution ====&lt;br /&gt;
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''.&lt;br /&gt;
* Make sure the Distribution section is highlighted in the top right.&lt;br /&gt;
* Since this is our first node, we want to show over the whole terrain. This means the distribution map should be 100% white.&lt;br /&gt;
* You can either assign a pure white TGA texture, or change the {{keyname|Source Type}} to {{keyvalue|geometryBased}}.&lt;br /&gt;
** {{keyvalue|geometryBased}} will by default create a fully white map, so if you don't have a white TGA handy, this is faster.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Distribution Pattern ====&lt;br /&gt;
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.&lt;br /&gt;
* 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!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Local ====&lt;br /&gt;
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.&lt;br /&gt;
* Make sure the Local section is highlighted in the top right.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching normal map for your tiling dirt texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/dirt_02_local.tga}}&lt;br /&gt;
* The Local texture's tiling amount is automatically the same as the Diffuse texture.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Surface Type ====&lt;br /&gt;
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.&lt;br /&gt;
* Find the ''Surface Type Properties'' section of the property list.&lt;br /&gt;
* 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.&lt;br /&gt;
* Hit {{accelkey|enter}} to accept the surface type.&lt;br /&gt;
&lt;br /&gt;
Your dirt textures will now produce correct &amp;quot;dirt&amp;quot; effects when shot or collided with!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Previewing the result ====&lt;br /&gt;
[[Image:simplemega_firstnode_preview.jpg|thumb|300px|The Render mode preview of the first node]]&lt;br /&gt;
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]]&lt;br /&gt;
&lt;br /&gt;
* Notice the drop-down arrow on the right of the button. Click it, and select ''&amp;quot;Full&amp;quot;'' instead of ''&amp;quot;None&amp;quot;''.&lt;br /&gt;
* Your terrain should change colour to black. This means it's ready for a preview to be rendered onto it.&lt;br /&gt;
* Click the button itself now, instead of the drop-down. An &amp;quot;Active Tasks&amp;quot; window should pop up, and when it's done, you should see your dirt texture appear on your terrain model.&lt;br /&gt;
* You can switch the camera to Render mode too, which will show your terrain model's shading better.&lt;br /&gt;
* If you want a full-resolution preview of a small area, choose ''&amp;quot;Window&amp;quot;'' instead of ''&amp;quot;Full&amp;quot;'' from the drop-down menu.&lt;br /&gt;
** 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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
'''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.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
== Adding a second node ==&lt;br /&gt;
Now that the first layer of dirt is in place, we can try putting some grass on top of it!&lt;br /&gt;
* Again, {{accelbtn|RMB}} on your &amp;quot;Root&amp;quot; node and choose ''New -&amp;gt; Image Source'' (or press {{accelkey|shift}}{{accelkey|i}})&lt;br /&gt;
* This will make another new node below your &amp;quot;Dirt&amp;quot; node. &lt;br /&gt;
* Name this new node &amp;quot;Grass&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Again, the main map types need to be specified before the node can be rendered:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Diffuse ====&lt;br /&gt;
* Make sure the Diffuse section is highlighted in the top right of the Terrain Editor.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to a generic tiling grass texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/grass_04_d.tga}}&lt;br /&gt;
* 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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Distribution ====&lt;br /&gt;
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!&lt;br /&gt;
* Make sure the Distribution section is highlighted in the top right.&lt;br /&gt;
* Change the {{keyname|Source Type}} from {{keyvalue|texture}} to {{keyvalue|geometryBased}}.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Geometric Texture Distribution ====&lt;br /&gt;
[[Image:simplemega_geometric_distribution.png|thumb|300px|The geometric texture distribution settings of the second node]]&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
* ''Altitude Lower'' - Enabling this will limit the lower parts of the terrain from receiving this node's textures.&lt;br /&gt;
** {{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.&lt;br /&gt;
** {{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.&lt;br /&gt;
* ''Altitude Upper'' - Enabling this will limit the higher parts of the terrain from receiving this node's textures.&lt;br /&gt;
** {{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.&lt;br /&gt;
** {{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.&lt;br /&gt;
&lt;br /&gt;
* {{keyname|Clamp Distribution To Edge}} - Leave this on Default.&lt;br /&gt;
&lt;br /&gt;
* {{keyname|Resolution}} - The size in pixels of the resulting mask. The default value of {{keyvalue|256}} is fine for nearly any terrain model.&lt;br /&gt;
&lt;br /&gt;
* ''Slope Lower'' - Enabling this will limit shallower angles of the terrain model from receiving this node's textures.&lt;br /&gt;
** {{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.&lt;br /&gt;
** {{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.&lt;br /&gt;
* ''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.&lt;br /&gt;
** {{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.&lt;br /&gt;
** {{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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Distribution Pattern ====&lt;br /&gt;
[[Image:simplemega_dist_ramps.jpg|thumb|300px|The difference between using or not using a Distribution Pattern, and varying Ramp Widths]]&lt;br /&gt;
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!&lt;br /&gt;
So what we want here is a texture to identify the &amp;quot;height&amp;quot; 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.&lt;br /&gt;
&lt;br /&gt;
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!&lt;br /&gt;
&lt;br /&gt;
* Make sure {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching heightmap or mask for your tiling grass texture.&lt;br /&gt;
** This example is using {{filename|textures/megagen/temperate/grass_04_mask.tga}}&lt;br /&gt;
* 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 &amp;quot;Window&amp;quot; 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.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Local ====&lt;br /&gt;
Again we want the normal-map which matches the diffuse texture for the grass.&lt;br /&gt;
* Make sure the Local section is highlighted in the top right.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching normal map for your tiling grass texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/grass_04_local.tga}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Surface Type ====&lt;br /&gt;
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.&lt;br /&gt;
* Find the ''Surface Type Properties'' section of the property list.&lt;br /&gt;
* 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.&lt;br /&gt;
* Hit {{accelkey|enter}} to accept the surface type.&lt;br /&gt;
&lt;br /&gt;
Your grass textures should now produce correct &amp;quot;grass&amp;quot; effects when shot or collided with!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Preview again! ===&lt;br /&gt;
[[Image:simplemega_secondnode_preview.jpg|thumb|300px|The Render mode preview of the second node blended with the first node]]&lt;br /&gt;
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.&lt;br /&gt;
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.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
== Adding a third node ==&lt;br /&gt;
[[Image:simplemega_thirdnode_preview.jpg|thumb|300px|The Render mode preview of the third node blended with the other two nodes]]&lt;br /&gt;
Now that the grass and dirt are in place, we need some rocks to make the terrain look more natural.&lt;br /&gt;
* Add a new Image Renderer node below your &amp;quot;Grass&amp;quot; node and name it &amp;quot;Rock&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Again, the main map types need to be specified before the node can be rendered:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Diffuse ====&lt;br /&gt;
* Set the '''Diffuse''' texture and scale.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/rock_01_d.tga}} at a scale of {{keyvalue|32 32}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Distribution ====&lt;br /&gt;
Again we can use Geometric Texture Distribution to easily apply the rock textures only to the cliff-like angles.&lt;br /&gt;
* Make sure the Distribution section is highlighted in the top right.&lt;br /&gt;
* Change the {{keyname|Source Type}} to {{keyvalue|geometryBased}}.&lt;br /&gt;
* 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}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Distribution Pattern ====&lt;br /&gt;
Again this will control how the the rocks blend into the other nodes. Again, we want a texture to identify the &amp;quot;height&amp;quot; of the tiling rock texture.&lt;br /&gt;
&lt;br /&gt;
* Make sure the Distribution Pattern section is highlighted in the top right.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching heightmap or mask for your tiling rock texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/rock_01_h.tga}}&lt;br /&gt;
* 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 &amp;quot;Window&amp;quot; preview to see how the blending looks.&lt;br /&gt;
* Remember to set the {{keyname|Distribution Pattern Texture Scale}} to the same value as the Diffuse Scale, {{keyvalue|32 32}}.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Local ====&lt;br /&gt;
Again we want the normal-map which matches the diffuse texture for the rocks.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Local''' section, browse to the matching normal map for your tiling rock texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/rock_01_local.tga}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Surface Type ====&lt;br /&gt;
* Find the ''Surface Type Properties'' section of the property list.&lt;br /&gt;
* In the {{keyname|Type}} field, enter {{keyvalue|stone}}.&lt;br /&gt;
* Hit {{accelkey|enter}} to accept the surface type.&lt;br /&gt;
&lt;br /&gt;
Your rock textures should now produce correct &amp;quot;stone&amp;quot; effects when shot or collided with.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Preview again! ====&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Further tweaks ==&lt;br /&gt;
There are other simple changes that can be done in the Terrain Editor to make your MegaTexture look even better.&lt;br /&gt;
&lt;br /&gt;
==== Node order ====&lt;br /&gt;
[Image:simplemega_node_order.png|frame|Click and drag a node to change the order]]&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
* {{accelbtn|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.&lt;br /&gt;
* Release {{accelbtn|LMB}} when you have positioned the node in the correct place.&lt;br /&gt;
* 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!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Color changes ==== &lt;br /&gt;
Maybe your dirt texture is too bright? Or maybe your grass looks a little ''too'' green?&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Let's say you want to make the dirt texture darker and a bit more red. Here's how you'd do it:&lt;br /&gt;
* Select your Dirt node.&lt;br /&gt;
* 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).&lt;br /&gt;
* A color wheel and brightness slider will pop up in a new window. You can use this to darken and tint your texture.&lt;br /&gt;
* Choose a darker brightness, and a color slightly towards red. I used '''RGB Values''' of 225, 220, 220.&lt;br /&gt;
* Hit ''OK'' to accept the color.&lt;br /&gt;
* Re-render your MegaTexture preview. You should notice that the dirt layer looks darker now!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Texture rotation ====&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
An easy way to overcome this is to play with the {{keyvname|Rotation}} value in the Texture Properties section of the Terrain Editor's property list.&lt;br /&gt;
For each node, you should also set the {{keyvname|Distribution Pattern Texture Rotation}} to match the Rotation value if you want your distribution patterns to line up and work correctly.&lt;br /&gt;
&lt;br /&gt;
= Render the MegaTexture =&lt;br /&gt;
=== Save the Surface Tree ===&lt;br /&gt;
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 &amp;quot;Save and Unload&amp;quot; button in the Terrain Editor, or save the whole map.&lt;br /&gt;
&lt;br /&gt;
=== Compile Only Entities ===&lt;br /&gt;
At this stage, your MegaTexture material is still technically &amp;quot;broken&amp;quot;, 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.&lt;br /&gt;
&lt;br /&gt;
However, we need to compile the map in order to tell the [[renderLight]] process which atmosphere to use when lighting the MegaTexture!&lt;br /&gt;
&lt;br /&gt;
So the solution is to do an '''Only Entities''' compile. You can find this in the menu ''Compile -&amp;gt; 2 - Only Entities'' in editWorld. This should be done in a few seconds, and compiles all the information that renderLight needs.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Run the SDK Launcher ===&lt;br /&gt;
Now that your ''.sft'' is saved, go through all the steps outlined in the [[Generate a MegaTexture]] tutorial.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= That's it! =&lt;br /&gt;
[[Image:simplemega_ingame.jpg|thumb|300px|The MegaTexture in-game!]]&lt;br /&gt;
You've now created your very own MegaTexture to use in your map!&lt;br /&gt;
&lt;br /&gt;
Before you even compile the map, you can get an accurate preview of how it will look in-game by pressing {{accelkey|F6}} to toggle &amp;quot;anim&amp;quot; mode while in editWorld's &amp;quot;RENDER&amp;quot; Camera view (toggled with {{accelkey|F3}}).&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
= Troubleshooting =&lt;br /&gt;
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:&lt;br /&gt;
* 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.&lt;br /&gt;
* 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 ''&amp;lt; &amp;quot;mapname&amp;quot; &amp;gt;'' part described in [[A Simple First Megatexture#Creating a MegaTexture material|this section]]), otherwise it will not be searching for the correct images.&lt;br /&gt;
* 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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
= See Also =&lt;br /&gt;
* [[An Advanced Terrain and Megatexture]] - an advanced guide for complete MegaTexture creation&lt;br /&gt;
* [[Generate a MegaTexture]] - steps for generating a MegaTexture from the SDK launcher.&lt;br /&gt;
* [http://community.enemyterritory.com/forums/showthread.php?t=19326 Forum Thread] - includes textures to download&lt;br /&gt;
&lt;br /&gt;
[[Category:Art]]&lt;br /&gt;
[[Category:Basic Level Design]]&lt;br /&gt;
[[Category:Tutorials]]&lt;/div&gt;</summary>
		<author><name>Ducks</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.splashdamage.com/index.php?title=A_Simple_First_Megatexture&amp;diff=4050</id>
		<title>A Simple First Megatexture</title>
		<link rel="alternate" type="text/html" href="https://wiki.splashdamage.com/index.php?title=A_Simple_First_Megatexture&amp;diff=4050"/>
		<updated>2007-12-17T15:07:19Z</updated>

		<summary type="html">&lt;p&gt;Ducks: /* Adding a third node */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Image:simplemega_ingame.jpg|right|thumb|500px|A simple MegaTexture, easily created with only 3 texture layers!]]&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
= Introduction =&lt;br /&gt;
'''For this tutorial you must:'''&lt;br /&gt;
* Have a terrain model UV-mapped in the 0-1 range (covered in the simple first terrain tutorial)&lt;br /&gt;
* Have access to some tiling textures.&lt;br /&gt;
* Have a little understanding the ETQW material system&lt;br /&gt;
&lt;br /&gt;
If you don't have any of the above things, you are not ready to do this tutorial!&lt;br /&gt;
&lt;br /&gt;
'''This tutorial covers:'''&lt;br /&gt;
* How to set up a MegaTexture material&lt;br /&gt;
* How to create a Surface Tree&lt;br /&gt;
* How to add texture nodes in the Terrain Editor&lt;br /&gt;
* How to render and compile a full MegaTexture&lt;br /&gt;
&lt;br /&gt;
'''This tutorial does not cover:'''&lt;br /&gt;
* How to use Blender/Maya/Lightwave/ZBrush/Mudbox/3DSMax/Photoshop&lt;br /&gt;
* How to create tiling textures or heightmaps&lt;br /&gt;
* Anything overly complicated&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Creating a MegaTexture material =&lt;br /&gt;
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:&lt;br /&gt;
 material megatextures/mapname		{ useTemplate megatextures/default_ambient&amp;lt; &amp;quot;mapname&amp;quot; &amp;gt; }&lt;br /&gt;
&lt;br /&gt;
This material would automatically search for a MegaTexture called {{filename|mapname.mega}} in the {{filename|/megatextures/}} folder. This example material uses the ''&amp;quot;default_ambient&amp;quot;'' 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]].&lt;br /&gt;
&lt;br /&gt;
Obviously you would want to use the actual name of your map instead of &amp;quot;mapname&amp;quot;, for consistency's sake and ease of reference.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Assigning the material ===&lt;br /&gt;
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).&lt;br /&gt;
Tips on this process can be found in the [[A Simple First Terrain|simple first terrain tutorial]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Creating the Surface Tree =&lt;br /&gt;
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 &amp;quot;Save and Unload&amp;quot; button in the Terrain Editor.&lt;br /&gt;
[[Image:simplemega_terrainmodel.png|thumb|300px|Root node set up to use the correct terrain mesh]]&lt;br /&gt;
&lt;br /&gt;
=== Add the terrain mesh ===&lt;br /&gt;
Here's how you bring the terrain mesh into the surface tree:&lt;br /&gt;
* {{accelbtn|RMB}} on the left-hand pane, and choose ''New -&amp;gt; Tree'' via the menu.&lt;br /&gt;
** If you already have a Root node, click the &amp;quot;Begin Editing&amp;quot; button instead.&lt;br /&gt;
* Click on the Root node, and set {{keyname|Model}} to the name of the terrain mesh, in this case {{keyvalue|models/terrain/simpleterrain.obj}}.&lt;br /&gt;
* Press {{accelkey|enter}} to confirm the selection, and the terrain should appear in the 3D view.&lt;br /&gt;
&lt;br /&gt;
Be aware that your terrain model will probably appear bright orange or red.&lt;br /&gt;
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!&lt;br /&gt;
&lt;br /&gt;
=== Important note about nodes ===&lt;br /&gt;
When you are editing properties of nodes (names, numbers, texture sources etc.) always remember to hit {{accelkey|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 {{accelkey|enter}}, your changes may not be applied.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Create the first texture node ==&lt;br /&gt;
[[Image:simplemega_firstnode_diffuse.png|thumb|300px|The first texture node's diffuse texture properties]]&lt;br /&gt;
Now that the model is in place, you can start laying down the texture layers (or &amp;quot;nodes&amp;quot;) that will make up your MegaTexture.&lt;br /&gt;
&lt;br /&gt;
First you need to create a new Image Source node in the Terrain Editor.&lt;br /&gt;
* {{accelbtn|RMB}} on your &amp;quot;Root&amp;quot; node and choose ''New -&amp;gt; Image Source'' (or press {{accelkey|shift}}{{accelkey|i}})&lt;br /&gt;
* This will make a new node called &amp;quot;New Image Renderer&amp;quot;.&lt;br /&gt;
* You can rename this new node using the &amp;quot;Name&amp;quot; property field in the '''Object''' section.&lt;br /&gt;
* Rename the node &amp;quot;Dirt&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You will notice in the top right of the Terrain Editor, a section listing things like &amp;quot;Diffuse&amp;quot;, &amp;quot;Distribution&amp;quot;, &amp;quot;Distribution Pattern&amp;quot; etc. Selecting one of these will list all of the properties for that section of the current node.&lt;br /&gt;
The ones we need to worry about are as follows:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Diffuse ====&lt;br /&gt;
This is the colour map of the current node, and it should point to a tiling TGA texture.&lt;br /&gt;
* Make sure the Diffuse section is highlighted in the top right of the Terrain Editor.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to a generic tiling dirt texture. Remember to hit {{accelkey|enter}} afterwards!&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/dirt_02_d.tga}}&lt;br /&gt;
* The {{keyname|Scale}} field at the very bottom of the property list allows you to choose how much to tile the texture.&lt;br /&gt;
** 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!&lt;br /&gt;
** 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.&lt;br /&gt;
That's all you need to do for the Diffuse settings in this node.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Distribution ====&lt;br /&gt;
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''.&lt;br /&gt;
* Make sure the Distribution section is highlighted in the top right.&lt;br /&gt;
* Since this is our first node, we want to show over the whole terrain. This means the distribution map should be 100% white.&lt;br /&gt;
* You can either assign a pure white TGA texture, or change the {{keyname|Source Type}} to {{keyvalue|geometryBased}}.&lt;br /&gt;
** {{keyvalue|geometryBased}} will by default create a fully white map, so if you don't have a white TGA handy, this is faster.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Distribution Pattern ====&lt;br /&gt;
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.&lt;br /&gt;
* 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!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Local ====&lt;br /&gt;
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.&lt;br /&gt;
* Make sure the Local section is highlighted in the top right.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching normal map for your tiling dirt texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/dirt_02_local.tga}}&lt;br /&gt;
* The Local texture's tiling amount is automatically the same as the Diffuse texture.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Surface Type ====&lt;br /&gt;
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.&lt;br /&gt;
* Find the ''Surface Type Properties'' section of the property list.&lt;br /&gt;
* 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.&lt;br /&gt;
* Hit {{accelkey|enter}} to accept the surface type.&lt;br /&gt;
&lt;br /&gt;
Your dirt textures will now produce correct &amp;quot;dirt&amp;quot; effects when shot or collided with!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Previewing the result ====&lt;br /&gt;
[[Image:simplemega_firstnode_preview.jpg|thumb|300px|The Render mode preview of the first node]]&lt;br /&gt;
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]]&lt;br /&gt;
&lt;br /&gt;
* Notice the drop-down arrow on the right of the button. Click it, and select ''&amp;quot;Full&amp;quot;'' instead of ''&amp;quot;None&amp;quot;''.&lt;br /&gt;
* Your terrain should change colour to black. This means it's ready for a preview to be rendered onto it.&lt;br /&gt;
* Click the button itself now, instead of the drop-down. An &amp;quot;Active Tasks&amp;quot; window should pop up, and when it's done, you should see your dirt texture appear on your terrain model.&lt;br /&gt;
* You can switch the camera to Render mode too, which will show your terrain model's shading better.&lt;br /&gt;
* If you want a full-resolution preview of a small area, choose ''&amp;quot;Window&amp;quot;'' instead of ''&amp;quot;Full&amp;quot;'' from the drop-down menu.&lt;br /&gt;
** 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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
'''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.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
== Adding a second node ==&lt;br /&gt;
Now that the first layer of dirt is in place, we can try putting some grass on top of it!&lt;br /&gt;
* Again, {{accelbtn|RMB}} on your &amp;quot;Root&amp;quot; node and choose ''New -&amp;gt; Image Source'' (or press {{accelkey|shift}}{{accelkey|i}})&lt;br /&gt;
* This will make another new node below your &amp;quot;Dirt&amp;quot; node. &lt;br /&gt;
* Name this new node &amp;quot;Grass&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Again, the main map types need to be specified before the node can be rendered:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Diffuse ====&lt;br /&gt;
* Make sure the Diffuse section is highlighted in the top right of the Terrain Editor.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to a generic tiling grass texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/grass_04_d.tga}}&lt;br /&gt;
* 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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Distribution ====&lt;br /&gt;
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!&lt;br /&gt;
* Make sure the Distribution section is highlighted in the top right.&lt;br /&gt;
* Change the {{keyname|Source Type}} from {{keyvalue|texture}} to {{keyvalue|geometryBased}}.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Geometric Texture Distribution ====&lt;br /&gt;
[[Image:simplemega_geometric_distribution.png|thumb|300px|The geometric texture distribution settings of the second node]]&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
* ''Altitude Lower'' - Enabling this will limit the lower parts of the terrain from receiving this node's textures.&lt;br /&gt;
** {{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.&lt;br /&gt;
** {{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.&lt;br /&gt;
* ''Altitude Upper'' - Enabling this will limit the higher parts of the terrain from receiving this node's textures.&lt;br /&gt;
** {{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.&lt;br /&gt;
** {{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.&lt;br /&gt;
&lt;br /&gt;
* {{keyname|Clamp Distribution To Edge}} - Leave this on Default.&lt;br /&gt;
&lt;br /&gt;
* {{keyname|Resolution}} - The size in pixels of the resulting mask. The default value of {{keyvalue|256}} is fine for nearly any terrain model.&lt;br /&gt;
&lt;br /&gt;
* ''Slope Lower'' - Enabling this will limit shallower angles of the terrain model from receiving this node's textures.&lt;br /&gt;
** {{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.&lt;br /&gt;
** {{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.&lt;br /&gt;
* ''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.&lt;br /&gt;
** {{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.&lt;br /&gt;
** {{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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Distribution Pattern ====&lt;br /&gt;
[[Image:simplemega_dist_ramps.jpg|thumb|300px|The difference between using or not using a Distribution Pattern, and varying Ramp Widths]]&lt;br /&gt;
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!&lt;br /&gt;
So what we want here is a texture to identify the &amp;quot;height&amp;quot; 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.&lt;br /&gt;
&lt;br /&gt;
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!&lt;br /&gt;
&lt;br /&gt;
* Make sure {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching heightmap or mask for your tiling grass texture.&lt;br /&gt;
** This example is using {{filename|textures/megagen/temperate/grass_04_mask.tga}}&lt;br /&gt;
* 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 &amp;quot;Window&amp;quot; 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.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Local ====&lt;br /&gt;
Again we want the normal-map which matches the diffuse texture for the grass.&lt;br /&gt;
* Make sure the Local section is highlighted in the top right.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching normal map for your tiling grass texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/grass_04_local.tga}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Surface Type ====&lt;br /&gt;
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.&lt;br /&gt;
* Find the ''Surface Type Properties'' section of the property list.&lt;br /&gt;
* 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.&lt;br /&gt;
* Hit {{accelkey|enter}} to accept the surface type.&lt;br /&gt;
&lt;br /&gt;
Your grass textures should now produce correct &amp;quot;grass&amp;quot; effects when shot or collided with!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Preview again! ===&lt;br /&gt;
[[Image:simplemega_secondnode_preview.jpg|thumb|300px|The Render mode preview of the second node blended with the first node]]&lt;br /&gt;
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.&lt;br /&gt;
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.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
== Adding a third node ==&lt;br /&gt;
[[Image:simplemega_thirdnode_preview.jpg|thumb|300px|The Render mode preview of the third node blended with the other two nodes]]&lt;br /&gt;
Now that the grass and dirt are in place, we need some rocks to make the terrain look more natural.&lt;br /&gt;
* Add a new Image Renderer node below your &amp;quot;Grass&amp;quot; node and name it &amp;quot;Rock&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Again, the main map types need to be specified before the node can be rendered:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Diffuse ====&lt;br /&gt;
* Set the '''Diffuse''' texture and scale.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/rock_01_d.tga}} at a scale of {{keyvalue|32 32}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Distribution ====&lt;br /&gt;
Again we can use Geometric Texture Distribution to easily apply the rock textures only to the cliff-like angles.&lt;br /&gt;
* Make sure the Distribution section is highlighted in the top right.&lt;br /&gt;
* Change the {{keyname|Source Type}} to {{keyvalue|geometryBased}}.&lt;br /&gt;
* 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}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Distribution Pattern ====&lt;br /&gt;
Again this will control how the the rocks blend into the other nodes. Again, we want a texture to identify the &amp;quot;height&amp;quot; of the tiling rock texture.&lt;br /&gt;
&lt;br /&gt;
* Make sure the Distribution Pattern section is highlighted in the top right.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching heightmap or mask for your tiling rock texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/rock_01_h.tga}}&lt;br /&gt;
* 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 &amp;quot;Window&amp;quot; preview to see how the blending looks.&lt;br /&gt;
* Remember to set the {{keyname|Distribution Pattern Texture Scale}} to the same value as the Diffuse Scale, {{keyvalue|32 32}}.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Local ====&lt;br /&gt;
Again we want the normal-map which matches the diffuse texture for the rocks.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Local''' section, browse to the matching normal map for your tiling rock texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/rock_01_local.tga}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Surface Type ====&lt;br /&gt;
* Find the ''Surface Type Properties'' section of the property list.&lt;br /&gt;
* In the {{keyname|Type}} field, enter {{keyvalue|stone}}.&lt;br /&gt;
* Hit {{accelkey|enter}} to accept the surface type.&lt;br /&gt;
&lt;br /&gt;
Your rock textures should now produce correct &amp;quot;stone&amp;quot; effects when shot or collided with.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Preview again! ====&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Further tweaks ==&lt;br /&gt;
There are other simple changes that can be done in the Terrain Editor to make your MegaTexture look even better.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Node order'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
[[Image:simplemega_node_order.png|frame|Click and drag a node to change the order]]&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
* {{accelbtn|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.&lt;br /&gt;
* Release {{accelbtn|LMB}} when you have positioned the node in the correct place.&lt;br /&gt;
* 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!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Color changes'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
Maybe your dirt texture is too bright? Or maybe your grass looks a little ''too'' green?&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Let's say you want to make the dirt texture darker and a bit more red. Here's how you'd do it:&lt;br /&gt;
* Select your Dirt node.&lt;br /&gt;
* 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).&lt;br /&gt;
* A color wheel and brightness slider will pop up in a new window. You can use this to darken and tint your texture.&lt;br /&gt;
* Choose a darker brightness, and a color slightly towards red. I used '''RGB Values''' of 225, 220, 220.&lt;br /&gt;
* Hit ''OK'' to accept the color.&lt;br /&gt;
* Re-render your MegaTexture preview. You should notice that the dirt layer looks darker now!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Texture rotation'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
An easy way to overcome this is to play with the {{keyvname|Rotation}} value in the Texture Properties section of the Terrain Editor's property list.&lt;br /&gt;
For each node, you should also set the {{keyvname|Distribution Pattern Texture Rotation}} to match the Rotation value if you want your distribution patterns to line up and work correctly.&lt;br /&gt;
&lt;br /&gt;
= Render the MegaTexture =&lt;br /&gt;
=== Save the Surface Tree ===&lt;br /&gt;
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 &amp;quot;Save and Unload&amp;quot; button in the Terrain Editor, or save the whole map.&lt;br /&gt;
&lt;br /&gt;
=== Compile Only Entities ===&lt;br /&gt;
At this stage, your MegaTexture material is still technically &amp;quot;broken&amp;quot;, 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.&lt;br /&gt;
&lt;br /&gt;
However, we need to compile the map in order to tell the [[renderLight]] process which atmosphere to use when lighting the MegaTexture!&lt;br /&gt;
&lt;br /&gt;
So the solution is to do an '''Only Entities''' compile. You can find this in the menu ''Compile -&amp;gt; 2 - Only Entities'' in editWorld. This should be done in a few seconds, and compiles all the information that renderLight needs.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Run the SDK Launcher ===&lt;br /&gt;
Now that your ''.sft'' is saved, go through all the steps outlined in the [[Generate a MegaTexture]] tutorial.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= That's it! =&lt;br /&gt;
[[Image:simplemega_ingame.jpg|thumb|300px|The MegaTexture in-game!]]&lt;br /&gt;
You've now created your very own MegaTexture to use in your map!&lt;br /&gt;
&lt;br /&gt;
Before you even compile the map, you can get an accurate preview of how it will look in-game by pressing {{accelkey|F6}} to toggle &amp;quot;anim&amp;quot; mode while in editWorld's &amp;quot;RENDER&amp;quot; Camera view (toggled with {{accelkey|F3}}).&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
= Troubleshooting =&lt;br /&gt;
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:&lt;br /&gt;
* 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.&lt;br /&gt;
* 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 ''&amp;lt; &amp;quot;mapname&amp;quot; &amp;gt;'' part described in [[A Simple First Megatexture#Creating a MegaTexture material|this section]]), otherwise it will not be searching for the correct images.&lt;br /&gt;
* 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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
= See Also =&lt;br /&gt;
* [[An Advanced Terrain and Megatexture]] - an advanced guide for complete MegaTexture creation&lt;br /&gt;
* [[Generate a MegaTexture]] - steps for generating a MegaTexture from the SDK launcher.&lt;br /&gt;
* [http://community.enemyterritory.com/forums/showthread.php?t=19326 Forum Thread] - includes textures to download&lt;br /&gt;
&lt;br /&gt;
[[Category:Art]]&lt;br /&gt;
[[Category:Basic Level Design]]&lt;br /&gt;
[[Category:Tutorials]]&lt;/div&gt;</summary>
		<author><name>Ducks</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.splashdamage.com/index.php?title=A_Simple_First_Megatexture&amp;diff=4049</id>
		<title>A Simple First Megatexture</title>
		<link rel="alternate" type="text/html" href="https://wiki.splashdamage.com/index.php?title=A_Simple_First_Megatexture&amp;diff=4049"/>
		<updated>2007-12-17T15:06:11Z</updated>

		<summary type="html">&lt;p&gt;Ducks: /* Create the first texture node */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Image:simplemega_ingame.jpg|right|thumb|500px|A simple MegaTexture, easily created with only 3 texture layers!]]&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
= Introduction =&lt;br /&gt;
'''For this tutorial you must:'''&lt;br /&gt;
* Have a terrain model UV-mapped in the 0-1 range (covered in the simple first terrain tutorial)&lt;br /&gt;
* Have access to some tiling textures.&lt;br /&gt;
* Have a little understanding the ETQW material system&lt;br /&gt;
&lt;br /&gt;
If you don't have any of the above things, you are not ready to do this tutorial!&lt;br /&gt;
&lt;br /&gt;
'''This tutorial covers:'''&lt;br /&gt;
* How to set up a MegaTexture material&lt;br /&gt;
* How to create a Surface Tree&lt;br /&gt;
* How to add texture nodes in the Terrain Editor&lt;br /&gt;
* How to render and compile a full MegaTexture&lt;br /&gt;
&lt;br /&gt;
'''This tutorial does not cover:'''&lt;br /&gt;
* How to use Blender/Maya/Lightwave/ZBrush/Mudbox/3DSMax/Photoshop&lt;br /&gt;
* How to create tiling textures or heightmaps&lt;br /&gt;
* Anything overly complicated&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Creating a MegaTexture material =&lt;br /&gt;
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:&lt;br /&gt;
 material megatextures/mapname		{ useTemplate megatextures/default_ambient&amp;lt; &amp;quot;mapname&amp;quot; &amp;gt; }&lt;br /&gt;
&lt;br /&gt;
This material would automatically search for a MegaTexture called {{filename|mapname.mega}} in the {{filename|/megatextures/}} folder. This example material uses the ''&amp;quot;default_ambient&amp;quot;'' 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]].&lt;br /&gt;
&lt;br /&gt;
Obviously you would want to use the actual name of your map instead of &amp;quot;mapname&amp;quot;, for consistency's sake and ease of reference.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Assigning the material ===&lt;br /&gt;
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).&lt;br /&gt;
Tips on this process can be found in the [[A Simple First Terrain|simple first terrain tutorial]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Creating the Surface Tree =&lt;br /&gt;
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 &amp;quot;Save and Unload&amp;quot; button in the Terrain Editor.&lt;br /&gt;
[[Image:simplemega_terrainmodel.png|thumb|300px|Root node set up to use the correct terrain mesh]]&lt;br /&gt;
&lt;br /&gt;
=== Add the terrain mesh ===&lt;br /&gt;
Here's how you bring the terrain mesh into the surface tree:&lt;br /&gt;
* {{accelbtn|RMB}} on the left-hand pane, and choose ''New -&amp;gt; Tree'' via the menu.&lt;br /&gt;
** If you already have a Root node, click the &amp;quot;Begin Editing&amp;quot; button instead.&lt;br /&gt;
* Click on the Root node, and set {{keyname|Model}} to the name of the terrain mesh, in this case {{keyvalue|models/terrain/simpleterrain.obj}}.&lt;br /&gt;
* Press {{accelkey|enter}} to confirm the selection, and the terrain should appear in the 3D view.&lt;br /&gt;
&lt;br /&gt;
Be aware that your terrain model will probably appear bright orange or red.&lt;br /&gt;
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!&lt;br /&gt;
&lt;br /&gt;
=== Important note about nodes ===&lt;br /&gt;
When you are editing properties of nodes (names, numbers, texture sources etc.) always remember to hit {{accelkey|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 {{accelkey|enter}}, your changes may not be applied.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Create the first texture node ==&lt;br /&gt;
[[Image:simplemega_firstnode_diffuse.png|thumb|300px|The first texture node's diffuse texture properties]]&lt;br /&gt;
Now that the model is in place, you can start laying down the texture layers (or &amp;quot;nodes&amp;quot;) that will make up your MegaTexture.&lt;br /&gt;
&lt;br /&gt;
First you need to create a new Image Source node in the Terrain Editor.&lt;br /&gt;
* {{accelbtn|RMB}} on your &amp;quot;Root&amp;quot; node and choose ''New -&amp;gt; Image Source'' (or press {{accelkey|shift}}{{accelkey|i}})&lt;br /&gt;
* This will make a new node called &amp;quot;New Image Renderer&amp;quot;.&lt;br /&gt;
* You can rename this new node using the &amp;quot;Name&amp;quot; property field in the '''Object''' section.&lt;br /&gt;
* Rename the node &amp;quot;Dirt&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You will notice in the top right of the Terrain Editor, a section listing things like &amp;quot;Diffuse&amp;quot;, &amp;quot;Distribution&amp;quot;, &amp;quot;Distribution Pattern&amp;quot; etc. Selecting one of these will list all of the properties for that section of the current node.&lt;br /&gt;
The ones we need to worry about are as follows:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Diffuse ====&lt;br /&gt;
This is the colour map of the current node, and it should point to a tiling TGA texture.&lt;br /&gt;
* Make sure the Diffuse section is highlighted in the top right of the Terrain Editor.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to a generic tiling dirt texture. Remember to hit {{accelkey|enter}} afterwards!&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/dirt_02_d.tga}}&lt;br /&gt;
* The {{keyname|Scale}} field at the very bottom of the property list allows you to choose how much to tile the texture.&lt;br /&gt;
** 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!&lt;br /&gt;
** 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.&lt;br /&gt;
That's all you need to do for the Diffuse settings in this node.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Distribution ====&lt;br /&gt;
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''.&lt;br /&gt;
* Make sure the Distribution section is highlighted in the top right.&lt;br /&gt;
* Since this is our first node, we want to show over the whole terrain. This means the distribution map should be 100% white.&lt;br /&gt;
* You can either assign a pure white TGA texture, or change the {{keyname|Source Type}} to {{keyvalue|geometryBased}}.&lt;br /&gt;
** {{keyvalue|geometryBased}} will by default create a fully white map, so if you don't have a white TGA handy, this is faster.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Distribution Pattern ====&lt;br /&gt;
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.&lt;br /&gt;
* 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!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Local ====&lt;br /&gt;
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.&lt;br /&gt;
* Make sure the Local section is highlighted in the top right.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching normal map for your tiling dirt texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/dirt_02_local.tga}}&lt;br /&gt;
* The Local texture's tiling amount is automatically the same as the Diffuse texture.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Surface Type ====&lt;br /&gt;
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.&lt;br /&gt;
* Find the ''Surface Type Properties'' section of the property list.&lt;br /&gt;
* 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.&lt;br /&gt;
* Hit {{accelkey|enter}} to accept the surface type.&lt;br /&gt;
&lt;br /&gt;
Your dirt textures will now produce correct &amp;quot;dirt&amp;quot; effects when shot or collided with!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Previewing the result ====&lt;br /&gt;
[[Image:simplemega_firstnode_preview.jpg|thumb|300px|The Render mode preview of the first node]]&lt;br /&gt;
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]]&lt;br /&gt;
&lt;br /&gt;
* Notice the drop-down arrow on the right of the button. Click it, and select ''&amp;quot;Full&amp;quot;'' instead of ''&amp;quot;None&amp;quot;''.&lt;br /&gt;
* Your terrain should change colour to black. This means it's ready for a preview to be rendered onto it.&lt;br /&gt;
* Click the button itself now, instead of the drop-down. An &amp;quot;Active Tasks&amp;quot; window should pop up, and when it's done, you should see your dirt texture appear on your terrain model.&lt;br /&gt;
* You can switch the camera to Render mode too, which will show your terrain model's shading better.&lt;br /&gt;
* If you want a full-resolution preview of a small area, choose ''&amp;quot;Window&amp;quot;'' instead of ''&amp;quot;Full&amp;quot;'' from the drop-down menu.&lt;br /&gt;
** 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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
'''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.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
== Adding a second node ==&lt;br /&gt;
Now that the first layer of dirt is in place, we can try putting some grass on top of it!&lt;br /&gt;
* Again, {{accelbtn|RMB}} on your &amp;quot;Root&amp;quot; node and choose ''New -&amp;gt; Image Source'' (or press {{accelkey|shift}}{{accelkey|i}})&lt;br /&gt;
* This will make another new node below your &amp;quot;Dirt&amp;quot; node. &lt;br /&gt;
* Name this new node &amp;quot;Grass&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Again, the main map types need to be specified before the node can be rendered:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Diffuse ====&lt;br /&gt;
* Make sure the Diffuse section is highlighted in the top right of the Terrain Editor.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to a generic tiling grass texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/grass_04_d.tga}}&lt;br /&gt;
* 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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Distribution ====&lt;br /&gt;
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!&lt;br /&gt;
* Make sure the Distribution section is highlighted in the top right.&lt;br /&gt;
* Change the {{keyname|Source Type}} from {{keyvalue|texture}} to {{keyvalue|geometryBased}}.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Geometric Texture Distribution ====&lt;br /&gt;
[[Image:simplemega_geometric_distribution.png|thumb|300px|The geometric texture distribution settings of the second node]]&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
* ''Altitude Lower'' - Enabling this will limit the lower parts of the terrain from receiving this node's textures.&lt;br /&gt;
** {{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.&lt;br /&gt;
** {{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.&lt;br /&gt;
* ''Altitude Upper'' - Enabling this will limit the higher parts of the terrain from receiving this node's textures.&lt;br /&gt;
** {{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.&lt;br /&gt;
** {{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.&lt;br /&gt;
&lt;br /&gt;
* {{keyname|Clamp Distribution To Edge}} - Leave this on Default.&lt;br /&gt;
&lt;br /&gt;
* {{keyname|Resolution}} - The size in pixels of the resulting mask. The default value of {{keyvalue|256}} is fine for nearly any terrain model.&lt;br /&gt;
&lt;br /&gt;
* ''Slope Lower'' - Enabling this will limit shallower angles of the terrain model from receiving this node's textures.&lt;br /&gt;
** {{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.&lt;br /&gt;
** {{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.&lt;br /&gt;
* ''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.&lt;br /&gt;
** {{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.&lt;br /&gt;
** {{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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Distribution Pattern ====&lt;br /&gt;
[[Image:simplemega_dist_ramps.jpg|thumb|300px|The difference between using or not using a Distribution Pattern, and varying Ramp Widths]]&lt;br /&gt;
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!&lt;br /&gt;
So what we want here is a texture to identify the &amp;quot;height&amp;quot; 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.&lt;br /&gt;
&lt;br /&gt;
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!&lt;br /&gt;
&lt;br /&gt;
* Make sure {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching heightmap or mask for your tiling grass texture.&lt;br /&gt;
** This example is using {{filename|textures/megagen/temperate/grass_04_mask.tga}}&lt;br /&gt;
* 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 &amp;quot;Window&amp;quot; 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.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Local ====&lt;br /&gt;
Again we want the normal-map which matches the diffuse texture for the grass.&lt;br /&gt;
* Make sure the Local section is highlighted in the top right.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching normal map for your tiling grass texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/grass_04_local.tga}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Surface Type ====&lt;br /&gt;
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.&lt;br /&gt;
* Find the ''Surface Type Properties'' section of the property list.&lt;br /&gt;
* 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.&lt;br /&gt;
* Hit {{accelkey|enter}} to accept the surface type.&lt;br /&gt;
&lt;br /&gt;
Your grass textures should now produce correct &amp;quot;grass&amp;quot; effects when shot or collided with!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Preview again! ===&lt;br /&gt;
[[Image:simplemega_secondnode_preview.jpg|thumb|300px|The Render mode preview of the second node blended with the first node]]&lt;br /&gt;
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.&lt;br /&gt;
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.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
== Adding a third node ==&lt;br /&gt;
[[Image:simplemega_thirdnode_preview.jpg|thumb|300px|The Render mode preview of the third node blended with the other two nodes]]&lt;br /&gt;
Now that the grass and dirt are in place, we need some rocks to make the terrain look more natural.&lt;br /&gt;
* Add a new Image Renderer node below your &amp;quot;Grass&amp;quot; node and name it &amp;quot;Rock&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Again, the main map types need to be specified before the node can be rendered:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Diffuse'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
* Set the '''Diffuse''' texture and scale.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/rock_01_d.tga}} at a scale of {{keyvalue|32 32}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Distribution'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
Again we can use Geometric Texture Distribution to easily apply the rock textures only to the cliff-like angles.&lt;br /&gt;
* Make sure the Distribution section is highlighted in the top right.&lt;br /&gt;
* Change the {{keyname|Source Type}} to {{keyvalue|geometryBased}}.&lt;br /&gt;
* 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}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Distribution Pattern'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
Again this will control how the the rocks blend into the other nodes. Again, we want a texture to identify the &amp;quot;height&amp;quot; of the tiling rock texture.&lt;br /&gt;
&lt;br /&gt;
* Make sure the Distribution Pattern section is highlighted in the top right.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching heightmap or mask for your tiling rock texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/rock_01_h.tga}}&lt;br /&gt;
* 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 &amp;quot;Window&amp;quot; preview to see how the blending looks.&lt;br /&gt;
* Remember to set the {{keyname|Distribution Pattern Texture Scale}} to the same value as the Diffuse Scale, {{keyvalue|32 32}}.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Local'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
Again we want the normal-map which matches the diffuse texture for the rocks.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Local''' section, browse to the matching normal map for your tiling rock texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/rock_01_local.tga}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Surface Type'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
* Find the ''Surface Type Properties'' section of the property list.&lt;br /&gt;
* In the {{keyname|Type}} field, enter {{keyvalue|stone}}.&lt;br /&gt;
* Hit {{accelkey|enter}} to accept the surface type.&lt;br /&gt;
&lt;br /&gt;
Your rock textures should now produce correct &amp;quot;stone&amp;quot; effects when shot or collided with.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Preview again!'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Further tweaks ==&lt;br /&gt;
There are other simple changes that can be done in the Terrain Editor to make your MegaTexture look even better.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Node order'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
[[Image:simplemega_node_order.png|frame|Click and drag a node to change the order]]&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
* {{accelbtn|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.&lt;br /&gt;
* Release {{accelbtn|LMB}} when you have positioned the node in the correct place.&lt;br /&gt;
* 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!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Color changes'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
Maybe your dirt texture is too bright? Or maybe your grass looks a little ''too'' green?&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Let's say you want to make the dirt texture darker and a bit more red. Here's how you'd do it:&lt;br /&gt;
* Select your Dirt node.&lt;br /&gt;
* 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).&lt;br /&gt;
* A color wheel and brightness slider will pop up in a new window. You can use this to darken and tint your texture.&lt;br /&gt;
* Choose a darker brightness, and a color slightly towards red. I used '''RGB Values''' of 225, 220, 220.&lt;br /&gt;
* Hit ''OK'' to accept the color.&lt;br /&gt;
* Re-render your MegaTexture preview. You should notice that the dirt layer looks darker now!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Texture rotation'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
An easy way to overcome this is to play with the {{keyvname|Rotation}} value in the Texture Properties section of the Terrain Editor's property list.&lt;br /&gt;
For each node, you should also set the {{keyvname|Distribution Pattern Texture Rotation}} to match the Rotation value if you want your distribution patterns to line up and work correctly.&lt;br /&gt;
&lt;br /&gt;
= Render the MegaTexture =&lt;br /&gt;
=== Save the Surface Tree ===&lt;br /&gt;
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 &amp;quot;Save and Unload&amp;quot; button in the Terrain Editor, or save the whole map.&lt;br /&gt;
&lt;br /&gt;
=== Compile Only Entities ===&lt;br /&gt;
At this stage, your MegaTexture material is still technically &amp;quot;broken&amp;quot;, 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.&lt;br /&gt;
&lt;br /&gt;
However, we need to compile the map in order to tell the [[renderLight]] process which atmosphere to use when lighting the MegaTexture!&lt;br /&gt;
&lt;br /&gt;
So the solution is to do an '''Only Entities''' compile. You can find this in the menu ''Compile -&amp;gt; 2 - Only Entities'' in editWorld. This should be done in a few seconds, and compiles all the information that renderLight needs.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Run the SDK Launcher ===&lt;br /&gt;
Now that your ''.sft'' is saved, go through all the steps outlined in the [[Generate a MegaTexture]] tutorial.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= That's it! =&lt;br /&gt;
[[Image:simplemega_ingame.jpg|thumb|300px|The MegaTexture in-game!]]&lt;br /&gt;
You've now created your very own MegaTexture to use in your map!&lt;br /&gt;
&lt;br /&gt;
Before you even compile the map, you can get an accurate preview of how it will look in-game by pressing {{accelkey|F6}} to toggle &amp;quot;anim&amp;quot; mode while in editWorld's &amp;quot;RENDER&amp;quot; Camera view (toggled with {{accelkey|F3}}).&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
= Troubleshooting =&lt;br /&gt;
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:&lt;br /&gt;
* 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.&lt;br /&gt;
* 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 ''&amp;lt; &amp;quot;mapname&amp;quot; &amp;gt;'' part described in [[A Simple First Megatexture#Creating a MegaTexture material|this section]]), otherwise it will not be searching for the correct images.&lt;br /&gt;
* 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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
= See Also =&lt;br /&gt;
* [[An Advanced Terrain and Megatexture]] - an advanced guide for complete MegaTexture creation&lt;br /&gt;
* [[Generate a MegaTexture]] - steps for generating a MegaTexture from the SDK launcher.&lt;br /&gt;
* [http://community.enemyterritory.com/forums/showthread.php?t=19326 Forum Thread] - includes textures to download&lt;br /&gt;
&lt;br /&gt;
[[Category:Art]]&lt;br /&gt;
[[Category:Basic Level Design]]&lt;br /&gt;
[[Category:Tutorials]]&lt;/div&gt;</summary>
		<author><name>Ducks</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.splashdamage.com/index.php?title=A_Simple_First_Megatexture&amp;diff=4048</id>
		<title>A Simple First Megatexture</title>
		<link rel="alternate" type="text/html" href="https://wiki.splashdamage.com/index.php?title=A_Simple_First_Megatexture&amp;diff=4048"/>
		<updated>2007-12-17T15:05:52Z</updated>

		<summary type="html">&lt;p&gt;Ducks: /* Adding a second node */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Image:simplemega_ingame.jpg|right|thumb|500px|A simple MegaTexture, easily created with only 3 texture layers!]]&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
= Introduction =&lt;br /&gt;
'''For this tutorial you must:'''&lt;br /&gt;
* Have a terrain model UV-mapped in the 0-1 range (covered in the simple first terrain tutorial)&lt;br /&gt;
* Have access to some tiling textures.&lt;br /&gt;
* Have a little understanding the ETQW material system&lt;br /&gt;
&lt;br /&gt;
If you don't have any of the above things, you are not ready to do this tutorial!&lt;br /&gt;
&lt;br /&gt;
'''This tutorial covers:'''&lt;br /&gt;
* How to set up a MegaTexture material&lt;br /&gt;
* How to create a Surface Tree&lt;br /&gt;
* How to add texture nodes in the Terrain Editor&lt;br /&gt;
* How to render and compile a full MegaTexture&lt;br /&gt;
&lt;br /&gt;
'''This tutorial does not cover:'''&lt;br /&gt;
* How to use Blender/Maya/Lightwave/ZBrush/Mudbox/3DSMax/Photoshop&lt;br /&gt;
* How to create tiling textures or heightmaps&lt;br /&gt;
* Anything overly complicated&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Creating a MegaTexture material =&lt;br /&gt;
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:&lt;br /&gt;
 material megatextures/mapname		{ useTemplate megatextures/default_ambient&amp;lt; &amp;quot;mapname&amp;quot; &amp;gt; }&lt;br /&gt;
&lt;br /&gt;
This material would automatically search for a MegaTexture called {{filename|mapname.mega}} in the {{filename|/megatextures/}} folder. This example material uses the ''&amp;quot;default_ambient&amp;quot;'' 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]].&lt;br /&gt;
&lt;br /&gt;
Obviously you would want to use the actual name of your map instead of &amp;quot;mapname&amp;quot;, for consistency's sake and ease of reference.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Assigning the material ===&lt;br /&gt;
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).&lt;br /&gt;
Tips on this process can be found in the [[A Simple First Terrain|simple first terrain tutorial]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Creating the Surface Tree =&lt;br /&gt;
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 &amp;quot;Save and Unload&amp;quot; button in the Terrain Editor.&lt;br /&gt;
[[Image:simplemega_terrainmodel.png|thumb|300px|Root node set up to use the correct terrain mesh]]&lt;br /&gt;
&lt;br /&gt;
=== Add the terrain mesh ===&lt;br /&gt;
Here's how you bring the terrain mesh into the surface tree:&lt;br /&gt;
* {{accelbtn|RMB}} on the left-hand pane, and choose ''New -&amp;gt; Tree'' via the menu.&lt;br /&gt;
** If you already have a Root node, click the &amp;quot;Begin Editing&amp;quot; button instead.&lt;br /&gt;
* Click on the Root node, and set {{keyname|Model}} to the name of the terrain mesh, in this case {{keyvalue|models/terrain/simpleterrain.obj}}.&lt;br /&gt;
* Press {{accelkey|enter}} to confirm the selection, and the terrain should appear in the 3D view.&lt;br /&gt;
&lt;br /&gt;
Be aware that your terrain model will probably appear bright orange or red.&lt;br /&gt;
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!&lt;br /&gt;
&lt;br /&gt;
=== Important note about nodes ===&lt;br /&gt;
When you are editing properties of nodes (names, numbers, texture sources etc.) always remember to hit {{accelkey|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 {{accelkey|enter}}, your changes may not be applied.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Create the first texture node ==&lt;br /&gt;
[[Image:simplemega_firstnode_diffuse.png|thumb|300px|The first texture node's diffuse texture properties]]&lt;br /&gt;
Now that the model is in place, you can start laying down the texture layers (or &amp;quot;nodes&amp;quot;) that will make up your MegaTexture.&lt;br /&gt;
&lt;br /&gt;
First you need to create a new Image Source node in the Terrain Editor.&lt;br /&gt;
* {{accelbtn|RMB}} on your &amp;quot;Root&amp;quot; node and choose ''New -&amp;gt; Image Source'' (or press {{accelkey|shift}}{{accelkey|i}})&lt;br /&gt;
* This will make a new node called &amp;quot;New Image Renderer&amp;quot;.&lt;br /&gt;
* You can rename this new node using the &amp;quot;Name&amp;quot; property field in the '''Object''' section.&lt;br /&gt;
* Rename the node &amp;quot;Dirt&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You will notice in the top right of the Terrain Editor, a section listing things like &amp;quot;Diffuse&amp;quot;, &amp;quot;Distribution&amp;quot;, &amp;quot;Distribution Pattern&amp;quot; etc. Selecting one of these will list all of the properties for that section of the current node.&lt;br /&gt;
The ones we need to worry about are as follows:&lt;br /&gt;
&lt;br /&gt;
==== Diffuse ====&lt;br /&gt;
This is the colour map of the current node, and it should point to a tiling TGA texture.&lt;br /&gt;
* Make sure the Diffuse section is highlighted in the top right of the Terrain Editor.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to a generic tiling dirt texture. Remember to hit {{accelkey|enter}} afterwards!&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/dirt_02_d.tga}}&lt;br /&gt;
* The {{keyname|Scale}} field at the very bottom of the property list allows you to choose how much to tile the texture.&lt;br /&gt;
** 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!&lt;br /&gt;
** 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.&lt;br /&gt;
That's all you need to do for the Diffuse settings in this node.&lt;br /&gt;
&lt;br /&gt;
==== Distribution ====&lt;br /&gt;
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''.&lt;br /&gt;
* Make sure the Distribution section is highlighted in the top right.&lt;br /&gt;
* Since this is our first node, we want to show over the whole terrain. This means the distribution map should be 100% white.&lt;br /&gt;
* You can either assign a pure white TGA texture, or change the {{keyname|Source Type}} to {{keyvalue|geometryBased}}.&lt;br /&gt;
** {{keyvalue|geometryBased}} will by default create a fully white map, so if you don't have a white TGA handy, this is faster.&lt;br /&gt;
&lt;br /&gt;
==== Distribution Pattern ====&lt;br /&gt;
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.&lt;br /&gt;
* 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!&lt;br /&gt;
&lt;br /&gt;
==== Local ====&lt;br /&gt;
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.&lt;br /&gt;
* Make sure the Local section is highlighted in the top right.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching normal map for your tiling dirt texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/dirt_02_local.tga}}&lt;br /&gt;
* The Local texture's tiling amount is automatically the same as the Diffuse texture.&lt;br /&gt;
&lt;br /&gt;
==== Surface Type ====&lt;br /&gt;
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.&lt;br /&gt;
* Find the ''Surface Type Properties'' section of the property list.&lt;br /&gt;
* 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.&lt;br /&gt;
* Hit {{accelkey|enter}} to accept the surface type.&lt;br /&gt;
&lt;br /&gt;
Your dirt textures will now produce correct &amp;quot;dirt&amp;quot; effects when shot or collided with!&lt;br /&gt;
&lt;br /&gt;
=== Previewing the result ===&lt;br /&gt;
[[Image:simplemega_firstnode_preview.jpg|thumb|300px|The Render mode preview of the first node]]&lt;br /&gt;
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]]&lt;br /&gt;
&lt;br /&gt;
* Notice the drop-down arrow on the right of the button. Click it, and select ''&amp;quot;Full&amp;quot;'' instead of ''&amp;quot;None&amp;quot;''.&lt;br /&gt;
* Your terrain should change colour to black. This means it's ready for a preview to be rendered onto it.&lt;br /&gt;
* Click the button itself now, instead of the drop-down. An &amp;quot;Active Tasks&amp;quot; window should pop up, and when it's done, you should see your dirt texture appear on your terrain model.&lt;br /&gt;
* You can switch the camera to Render mode too, which will show your terrain model's shading better.&lt;br /&gt;
* If you want a full-resolution preview of a small area, choose ''&amp;quot;Window&amp;quot;'' instead of ''&amp;quot;Full&amp;quot;'' from the drop-down menu.&lt;br /&gt;
** 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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
'''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.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
== Adding a second node ==&lt;br /&gt;
Now that the first layer of dirt is in place, we can try putting some grass on top of it!&lt;br /&gt;
* Again, {{accelbtn|RMB}} on your &amp;quot;Root&amp;quot; node and choose ''New -&amp;gt; Image Source'' (or press {{accelkey|shift}}{{accelkey|i}})&lt;br /&gt;
* This will make another new node below your &amp;quot;Dirt&amp;quot; node. &lt;br /&gt;
* Name this new node &amp;quot;Grass&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Again, the main map types need to be specified before the node can be rendered:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Diffuse ====&lt;br /&gt;
* Make sure the Diffuse section is highlighted in the top right of the Terrain Editor.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to a generic tiling grass texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/grass_04_d.tga}}&lt;br /&gt;
* 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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Distribution ====&lt;br /&gt;
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!&lt;br /&gt;
* Make sure the Distribution section is highlighted in the top right.&lt;br /&gt;
* Change the {{keyname|Source Type}} from {{keyvalue|texture}} to {{keyvalue|geometryBased}}.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Geometric Texture Distribution ====&lt;br /&gt;
[[Image:simplemega_geometric_distribution.png|thumb|300px|The geometric texture distribution settings of the second node]]&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
* ''Altitude Lower'' - Enabling this will limit the lower parts of the terrain from receiving this node's textures.&lt;br /&gt;
** {{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.&lt;br /&gt;
** {{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.&lt;br /&gt;
* ''Altitude Upper'' - Enabling this will limit the higher parts of the terrain from receiving this node's textures.&lt;br /&gt;
** {{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.&lt;br /&gt;
** {{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.&lt;br /&gt;
&lt;br /&gt;
* {{keyname|Clamp Distribution To Edge}} - Leave this on Default.&lt;br /&gt;
&lt;br /&gt;
* {{keyname|Resolution}} - The size in pixels of the resulting mask. The default value of {{keyvalue|256}} is fine for nearly any terrain model.&lt;br /&gt;
&lt;br /&gt;
* ''Slope Lower'' - Enabling this will limit shallower angles of the terrain model from receiving this node's textures.&lt;br /&gt;
** {{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.&lt;br /&gt;
** {{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.&lt;br /&gt;
* ''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.&lt;br /&gt;
** {{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.&lt;br /&gt;
** {{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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Distribution Pattern ====&lt;br /&gt;
[[Image:simplemega_dist_ramps.jpg|thumb|300px|The difference between using or not using a Distribution Pattern, and varying Ramp Widths]]&lt;br /&gt;
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!&lt;br /&gt;
So what we want here is a texture to identify the &amp;quot;height&amp;quot; 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.&lt;br /&gt;
&lt;br /&gt;
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!&lt;br /&gt;
&lt;br /&gt;
* Make sure {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching heightmap or mask for your tiling grass texture.&lt;br /&gt;
** This example is using {{filename|textures/megagen/temperate/grass_04_mask.tga}}&lt;br /&gt;
* 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 &amp;quot;Window&amp;quot; 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.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Local ====&lt;br /&gt;
Again we want the normal-map which matches the diffuse texture for the grass.&lt;br /&gt;
* Make sure the Local section is highlighted in the top right.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching normal map for your tiling grass texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/grass_04_local.tga}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Surface Type ====&lt;br /&gt;
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.&lt;br /&gt;
* Find the ''Surface Type Properties'' section of the property list.&lt;br /&gt;
* 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.&lt;br /&gt;
* Hit {{accelkey|enter}} to accept the surface type.&lt;br /&gt;
&lt;br /&gt;
Your grass textures should now produce correct &amp;quot;grass&amp;quot; effects when shot or collided with!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Preview again! ===&lt;br /&gt;
[[Image:simplemega_secondnode_preview.jpg|thumb|300px|The Render mode preview of the second node blended with the first node]]&lt;br /&gt;
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.&lt;br /&gt;
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.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
== Adding a third node ==&lt;br /&gt;
[[Image:simplemega_thirdnode_preview.jpg|thumb|300px|The Render mode preview of the third node blended with the other two nodes]]&lt;br /&gt;
Now that the grass and dirt are in place, we need some rocks to make the terrain look more natural.&lt;br /&gt;
* Add a new Image Renderer node below your &amp;quot;Grass&amp;quot; node and name it &amp;quot;Rock&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Again, the main map types need to be specified before the node can be rendered:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Diffuse'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
* Set the '''Diffuse''' texture and scale.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/rock_01_d.tga}} at a scale of {{keyvalue|32 32}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Distribution'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
Again we can use Geometric Texture Distribution to easily apply the rock textures only to the cliff-like angles.&lt;br /&gt;
* Make sure the Distribution section is highlighted in the top right.&lt;br /&gt;
* Change the {{keyname|Source Type}} to {{keyvalue|geometryBased}}.&lt;br /&gt;
* 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}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Distribution Pattern'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
Again this will control how the the rocks blend into the other nodes. Again, we want a texture to identify the &amp;quot;height&amp;quot; of the tiling rock texture.&lt;br /&gt;
&lt;br /&gt;
* Make sure the Distribution Pattern section is highlighted in the top right.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching heightmap or mask for your tiling rock texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/rock_01_h.tga}}&lt;br /&gt;
* 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 &amp;quot;Window&amp;quot; preview to see how the blending looks.&lt;br /&gt;
* Remember to set the {{keyname|Distribution Pattern Texture Scale}} to the same value as the Diffuse Scale, {{keyvalue|32 32}}.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Local'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
Again we want the normal-map which matches the diffuse texture for the rocks.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Local''' section, browse to the matching normal map for your tiling rock texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/rock_01_local.tga}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Surface Type'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
* Find the ''Surface Type Properties'' section of the property list.&lt;br /&gt;
* In the {{keyname|Type}} field, enter {{keyvalue|stone}}.&lt;br /&gt;
* Hit {{accelkey|enter}} to accept the surface type.&lt;br /&gt;
&lt;br /&gt;
Your rock textures should now produce correct &amp;quot;stone&amp;quot; effects when shot or collided with.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Preview again!'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Further tweaks ==&lt;br /&gt;
There are other simple changes that can be done in the Terrain Editor to make your MegaTexture look even better.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Node order'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
[[Image:simplemega_node_order.png|frame|Click and drag a node to change the order]]&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
* {{accelbtn|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.&lt;br /&gt;
* Release {{accelbtn|LMB}} when you have positioned the node in the correct place.&lt;br /&gt;
* 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!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Color changes'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
Maybe your dirt texture is too bright? Or maybe your grass looks a little ''too'' green?&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Let's say you want to make the dirt texture darker and a bit more red. Here's how you'd do it:&lt;br /&gt;
* Select your Dirt node.&lt;br /&gt;
* 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).&lt;br /&gt;
* A color wheel and brightness slider will pop up in a new window. You can use this to darken and tint your texture.&lt;br /&gt;
* Choose a darker brightness, and a color slightly towards red. I used '''RGB Values''' of 225, 220, 220.&lt;br /&gt;
* Hit ''OK'' to accept the color.&lt;br /&gt;
* Re-render your MegaTexture preview. You should notice that the dirt layer looks darker now!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Texture rotation'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
An easy way to overcome this is to play with the {{keyvname|Rotation}} value in the Texture Properties section of the Terrain Editor's property list.&lt;br /&gt;
For each node, you should also set the {{keyvname|Distribution Pattern Texture Rotation}} to match the Rotation value if you want your distribution patterns to line up and work correctly.&lt;br /&gt;
&lt;br /&gt;
= Render the MegaTexture =&lt;br /&gt;
=== Save the Surface Tree ===&lt;br /&gt;
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 &amp;quot;Save and Unload&amp;quot; button in the Terrain Editor, or save the whole map.&lt;br /&gt;
&lt;br /&gt;
=== Compile Only Entities ===&lt;br /&gt;
At this stage, your MegaTexture material is still technically &amp;quot;broken&amp;quot;, 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.&lt;br /&gt;
&lt;br /&gt;
However, we need to compile the map in order to tell the [[renderLight]] process which atmosphere to use when lighting the MegaTexture!&lt;br /&gt;
&lt;br /&gt;
So the solution is to do an '''Only Entities''' compile. You can find this in the menu ''Compile -&amp;gt; 2 - Only Entities'' in editWorld. This should be done in a few seconds, and compiles all the information that renderLight needs.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Run the SDK Launcher ===&lt;br /&gt;
Now that your ''.sft'' is saved, go through all the steps outlined in the [[Generate a MegaTexture]] tutorial.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= That's it! =&lt;br /&gt;
[[Image:simplemega_ingame.jpg|thumb|300px|The MegaTexture in-game!]]&lt;br /&gt;
You've now created your very own MegaTexture to use in your map!&lt;br /&gt;
&lt;br /&gt;
Before you even compile the map, you can get an accurate preview of how it will look in-game by pressing {{accelkey|F6}} to toggle &amp;quot;anim&amp;quot; mode while in editWorld's &amp;quot;RENDER&amp;quot; Camera view (toggled with {{accelkey|F3}}).&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
= Troubleshooting =&lt;br /&gt;
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:&lt;br /&gt;
* 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.&lt;br /&gt;
* 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 ''&amp;lt; &amp;quot;mapname&amp;quot; &amp;gt;'' part described in [[A Simple First Megatexture#Creating a MegaTexture material|this section]]), otherwise it will not be searching for the correct images.&lt;br /&gt;
* 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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
= See Also =&lt;br /&gt;
* [[An Advanced Terrain and Megatexture]] - an advanced guide for complete MegaTexture creation&lt;br /&gt;
* [[Generate a MegaTexture]] - steps for generating a MegaTexture from the SDK launcher.&lt;br /&gt;
* [http://community.enemyterritory.com/forums/showthread.php?t=19326 Forum Thread] - includes textures to download&lt;br /&gt;
&lt;br /&gt;
[[Category:Art]]&lt;br /&gt;
[[Category:Basic Level Design]]&lt;br /&gt;
[[Category:Tutorials]]&lt;/div&gt;</summary>
		<author><name>Ducks</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.splashdamage.com/index.php?title=A_Simple_First_Megatexture&amp;diff=4047</id>
		<title>A Simple First Megatexture</title>
		<link rel="alternate" type="text/html" href="https://wiki.splashdamage.com/index.php?title=A_Simple_First_Megatexture&amp;diff=4047"/>
		<updated>2007-12-17T15:05:31Z</updated>

		<summary type="html">&lt;p&gt;Ducks: /* Adding a second node */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Image:simplemega_ingame.jpg|right|thumb|500px|A simple MegaTexture, easily created with only 3 texture layers!]]&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
= Introduction =&lt;br /&gt;
'''For this tutorial you must:'''&lt;br /&gt;
* Have a terrain model UV-mapped in the 0-1 range (covered in the simple first terrain tutorial)&lt;br /&gt;
* Have access to some tiling textures.&lt;br /&gt;
* Have a little understanding the ETQW material system&lt;br /&gt;
&lt;br /&gt;
If you don't have any of the above things, you are not ready to do this tutorial!&lt;br /&gt;
&lt;br /&gt;
'''This tutorial covers:'''&lt;br /&gt;
* How to set up a MegaTexture material&lt;br /&gt;
* How to create a Surface Tree&lt;br /&gt;
* How to add texture nodes in the Terrain Editor&lt;br /&gt;
* How to render and compile a full MegaTexture&lt;br /&gt;
&lt;br /&gt;
'''This tutorial does not cover:'''&lt;br /&gt;
* How to use Blender/Maya/Lightwave/ZBrush/Mudbox/3DSMax/Photoshop&lt;br /&gt;
* How to create tiling textures or heightmaps&lt;br /&gt;
* Anything overly complicated&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Creating a MegaTexture material =&lt;br /&gt;
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:&lt;br /&gt;
 material megatextures/mapname		{ useTemplate megatextures/default_ambient&amp;lt; &amp;quot;mapname&amp;quot; &amp;gt; }&lt;br /&gt;
&lt;br /&gt;
This material would automatically search for a MegaTexture called {{filename|mapname.mega}} in the {{filename|/megatextures/}} folder. This example material uses the ''&amp;quot;default_ambient&amp;quot;'' 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]].&lt;br /&gt;
&lt;br /&gt;
Obviously you would want to use the actual name of your map instead of &amp;quot;mapname&amp;quot;, for consistency's sake and ease of reference.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Assigning the material ===&lt;br /&gt;
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).&lt;br /&gt;
Tips on this process can be found in the [[A Simple First Terrain|simple first terrain tutorial]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Creating the Surface Tree =&lt;br /&gt;
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 &amp;quot;Save and Unload&amp;quot; button in the Terrain Editor.&lt;br /&gt;
[[Image:simplemega_terrainmodel.png|thumb|300px|Root node set up to use the correct terrain mesh]]&lt;br /&gt;
&lt;br /&gt;
=== Add the terrain mesh ===&lt;br /&gt;
Here's how you bring the terrain mesh into the surface tree:&lt;br /&gt;
* {{accelbtn|RMB}} on the left-hand pane, and choose ''New -&amp;gt; Tree'' via the menu.&lt;br /&gt;
** If you already have a Root node, click the &amp;quot;Begin Editing&amp;quot; button instead.&lt;br /&gt;
* Click on the Root node, and set {{keyname|Model}} to the name of the terrain mesh, in this case {{keyvalue|models/terrain/simpleterrain.obj}}.&lt;br /&gt;
* Press {{accelkey|enter}} to confirm the selection, and the terrain should appear in the 3D view.&lt;br /&gt;
&lt;br /&gt;
Be aware that your terrain model will probably appear bright orange or red.&lt;br /&gt;
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!&lt;br /&gt;
&lt;br /&gt;
=== Important note about nodes ===&lt;br /&gt;
When you are editing properties of nodes (names, numbers, texture sources etc.) always remember to hit {{accelkey|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 {{accelkey|enter}}, your changes may not be applied.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Create the first texture node ==&lt;br /&gt;
[[Image:simplemega_firstnode_diffuse.png|thumb|300px|The first texture node's diffuse texture properties]]&lt;br /&gt;
Now that the model is in place, you can start laying down the texture layers (or &amp;quot;nodes&amp;quot;) that will make up your MegaTexture.&lt;br /&gt;
&lt;br /&gt;
First you need to create a new Image Source node in the Terrain Editor.&lt;br /&gt;
* {{accelbtn|RMB}} on your &amp;quot;Root&amp;quot; node and choose ''New -&amp;gt; Image Source'' (or press {{accelkey|shift}}{{accelkey|i}})&lt;br /&gt;
* This will make a new node called &amp;quot;New Image Renderer&amp;quot;.&lt;br /&gt;
* You can rename this new node using the &amp;quot;Name&amp;quot; property field in the '''Object''' section.&lt;br /&gt;
* Rename the node &amp;quot;Dirt&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You will notice in the top right of the Terrain Editor, a section listing things like &amp;quot;Diffuse&amp;quot;, &amp;quot;Distribution&amp;quot;, &amp;quot;Distribution Pattern&amp;quot; etc. Selecting one of these will list all of the properties for that section of the current node.&lt;br /&gt;
The ones we need to worry about are as follows:&lt;br /&gt;
&lt;br /&gt;
==== Diffuse ====&lt;br /&gt;
This is the colour map of the current node, and it should point to a tiling TGA texture.&lt;br /&gt;
* Make sure the Diffuse section is highlighted in the top right of the Terrain Editor.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to a generic tiling dirt texture. Remember to hit {{accelkey|enter}} afterwards!&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/dirt_02_d.tga}}&lt;br /&gt;
* The {{keyname|Scale}} field at the very bottom of the property list allows you to choose how much to tile the texture.&lt;br /&gt;
** 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!&lt;br /&gt;
** 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.&lt;br /&gt;
That's all you need to do for the Diffuse settings in this node.&lt;br /&gt;
&lt;br /&gt;
==== Distribution ====&lt;br /&gt;
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''.&lt;br /&gt;
* Make sure the Distribution section is highlighted in the top right.&lt;br /&gt;
* Since this is our first node, we want to show over the whole terrain. This means the distribution map should be 100% white.&lt;br /&gt;
* You can either assign a pure white TGA texture, or change the {{keyname|Source Type}} to {{keyvalue|geometryBased}}.&lt;br /&gt;
** {{keyvalue|geometryBased}} will by default create a fully white map, so if you don't have a white TGA handy, this is faster.&lt;br /&gt;
&lt;br /&gt;
==== Distribution Pattern ====&lt;br /&gt;
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.&lt;br /&gt;
* 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!&lt;br /&gt;
&lt;br /&gt;
==== Local ====&lt;br /&gt;
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.&lt;br /&gt;
* Make sure the Local section is highlighted in the top right.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching normal map for your tiling dirt texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/dirt_02_local.tga}}&lt;br /&gt;
* The Local texture's tiling amount is automatically the same as the Diffuse texture.&lt;br /&gt;
&lt;br /&gt;
==== Surface Type ====&lt;br /&gt;
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.&lt;br /&gt;
* Find the ''Surface Type Properties'' section of the property list.&lt;br /&gt;
* 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.&lt;br /&gt;
* Hit {{accelkey|enter}} to accept the surface type.&lt;br /&gt;
&lt;br /&gt;
Your dirt textures will now produce correct &amp;quot;dirt&amp;quot; effects when shot or collided with!&lt;br /&gt;
&lt;br /&gt;
=== Previewing the result ===&lt;br /&gt;
[[Image:simplemega_firstnode_preview.jpg|thumb|300px|The Render mode preview of the first node]]&lt;br /&gt;
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]]&lt;br /&gt;
&lt;br /&gt;
* Notice the drop-down arrow on the right of the button. Click it, and select ''&amp;quot;Full&amp;quot;'' instead of ''&amp;quot;None&amp;quot;''.&lt;br /&gt;
* Your terrain should change colour to black. This means it's ready for a preview to be rendered onto it.&lt;br /&gt;
* Click the button itself now, instead of the drop-down. An &amp;quot;Active Tasks&amp;quot; window should pop up, and when it's done, you should see your dirt texture appear on your terrain model.&lt;br /&gt;
* You can switch the camera to Render mode too, which will show your terrain model's shading better.&lt;br /&gt;
* If you want a full-resolution preview of a small area, choose ''&amp;quot;Window&amp;quot;'' instead of ''&amp;quot;Full&amp;quot;'' from the drop-down menu.&lt;br /&gt;
** 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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
'''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.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
== Adding a second node ==&lt;br /&gt;
Now that the first layer of dirt is in place, we can try putting some grass on top of it!&lt;br /&gt;
* Again, {{accelbtn|RMB}} on your &amp;quot;Root&amp;quot; node and choose ''New -&amp;gt; Image Source'' (or press {{accelkey|shift}}{{accelkey|i}})&lt;br /&gt;
* This will make another new node below your &amp;quot;Dirt&amp;quot; node. &lt;br /&gt;
* Name this new node &amp;quot;Grass&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Again, the main map types need to be specified before the node can be rendered:&lt;br /&gt;
&lt;br /&gt;
==== Diffuse ====&lt;br /&gt;
* Make sure the Diffuse section is highlighted in the top right of the Terrain Editor.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to a generic tiling grass texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/grass_04_d.tga}}&lt;br /&gt;
* 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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Distribution ====&lt;br /&gt;
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!&lt;br /&gt;
* Make sure the Distribution section is highlighted in the top right.&lt;br /&gt;
* Change the {{keyname|Source Type}} from {{keyvalue|texture}} to {{keyvalue|geometryBased}}.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Geometric Texture Distribution ====&lt;br /&gt;
[[Image:simplemega_geometric_distribution.png|thumb|300px|The geometric texture distribution settings of the second node]]&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
* ''Altitude Lower'' - Enabling this will limit the lower parts of the terrain from receiving this node's textures.&lt;br /&gt;
** {{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.&lt;br /&gt;
** {{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.&lt;br /&gt;
* ''Altitude Upper'' - Enabling this will limit the higher parts of the terrain from receiving this node's textures.&lt;br /&gt;
** {{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.&lt;br /&gt;
** {{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.&lt;br /&gt;
&lt;br /&gt;
* {{keyname|Clamp Distribution To Edge}} - Leave this on Default.&lt;br /&gt;
&lt;br /&gt;
* {{keyname|Resolution}} - The size in pixels of the resulting mask. The default value of {{keyvalue|256}} is fine for nearly any terrain model.&lt;br /&gt;
&lt;br /&gt;
* ''Slope Lower'' - Enabling this will limit shallower angles of the terrain model from receiving this node's textures.&lt;br /&gt;
** {{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.&lt;br /&gt;
** {{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.&lt;br /&gt;
* ''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.&lt;br /&gt;
** {{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.&lt;br /&gt;
** {{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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Distribution Pattern ====&lt;br /&gt;
[[Image:simplemega_dist_ramps.jpg|thumb|300px|The difference between using or not using a Distribution Pattern, and varying Ramp Widths]]&lt;br /&gt;
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!&lt;br /&gt;
So what we want here is a texture to identify the &amp;quot;height&amp;quot; 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.&lt;br /&gt;
&lt;br /&gt;
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!&lt;br /&gt;
&lt;br /&gt;
* Make sure {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching heightmap or mask for your tiling grass texture.&lt;br /&gt;
** This example is using {{filename|textures/megagen/temperate/grass_04_mask.tga}}&lt;br /&gt;
* 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 &amp;quot;Window&amp;quot; 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.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Local ====&lt;br /&gt;
Again we want the normal-map which matches the diffuse texture for the grass.&lt;br /&gt;
* Make sure the Local section is highlighted in the top right.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching normal map for your tiling grass texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/grass_04_local.tga}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Surface Type ====&lt;br /&gt;
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.&lt;br /&gt;
* Find the ''Surface Type Properties'' section of the property list.&lt;br /&gt;
* 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.&lt;br /&gt;
* Hit {{accelkey|enter}} to accept the surface type.&lt;br /&gt;
&lt;br /&gt;
Your grass textures should now produce correct &amp;quot;grass&amp;quot; effects when shot or collided with!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Preview again! ===&lt;br /&gt;
[[Image:simplemega_secondnode_preview.jpg|thumb|300px|The Render mode preview of the second node blended with the first node]]&lt;br /&gt;
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.&lt;br /&gt;
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.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
== Adding a third node ==&lt;br /&gt;
[[Image:simplemega_thirdnode_preview.jpg|thumb|300px|The Render mode preview of the third node blended with the other two nodes]]&lt;br /&gt;
Now that the grass and dirt are in place, we need some rocks to make the terrain look more natural.&lt;br /&gt;
* Add a new Image Renderer node below your &amp;quot;Grass&amp;quot; node and name it &amp;quot;Rock&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Again, the main map types need to be specified before the node can be rendered:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Diffuse'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
* Set the '''Diffuse''' texture and scale.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/rock_01_d.tga}} at a scale of {{keyvalue|32 32}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Distribution'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
Again we can use Geometric Texture Distribution to easily apply the rock textures only to the cliff-like angles.&lt;br /&gt;
* Make sure the Distribution section is highlighted in the top right.&lt;br /&gt;
* Change the {{keyname|Source Type}} to {{keyvalue|geometryBased}}.&lt;br /&gt;
* 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}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Distribution Pattern'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
Again this will control how the the rocks blend into the other nodes. Again, we want a texture to identify the &amp;quot;height&amp;quot; of the tiling rock texture.&lt;br /&gt;
&lt;br /&gt;
* Make sure the Distribution Pattern section is highlighted in the top right.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching heightmap or mask for your tiling rock texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/rock_01_h.tga}}&lt;br /&gt;
* 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 &amp;quot;Window&amp;quot; preview to see how the blending looks.&lt;br /&gt;
* Remember to set the {{keyname|Distribution Pattern Texture Scale}} to the same value as the Diffuse Scale, {{keyvalue|32 32}}.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Local'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
Again we want the normal-map which matches the diffuse texture for the rocks.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Local''' section, browse to the matching normal map for your tiling rock texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/rock_01_local.tga}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Surface Type'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
* Find the ''Surface Type Properties'' section of the property list.&lt;br /&gt;
* In the {{keyname|Type}} field, enter {{keyvalue|stone}}.&lt;br /&gt;
* Hit {{accelkey|enter}} to accept the surface type.&lt;br /&gt;
&lt;br /&gt;
Your rock textures should now produce correct &amp;quot;stone&amp;quot; effects when shot or collided with.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Preview again!'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Further tweaks ==&lt;br /&gt;
There are other simple changes that can be done in the Terrain Editor to make your MegaTexture look even better.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Node order'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
[[Image:simplemega_node_order.png|frame|Click and drag a node to change the order]]&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
* {{accelbtn|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.&lt;br /&gt;
* Release {{accelbtn|LMB}} when you have positioned the node in the correct place.&lt;br /&gt;
* 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!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Color changes'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
Maybe your dirt texture is too bright? Or maybe your grass looks a little ''too'' green?&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Let's say you want to make the dirt texture darker and a bit more red. Here's how you'd do it:&lt;br /&gt;
* Select your Dirt node.&lt;br /&gt;
* 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).&lt;br /&gt;
* A color wheel and brightness slider will pop up in a new window. You can use this to darken and tint your texture.&lt;br /&gt;
* Choose a darker brightness, and a color slightly towards red. I used '''RGB Values''' of 225, 220, 220.&lt;br /&gt;
* Hit ''OK'' to accept the color.&lt;br /&gt;
* Re-render your MegaTexture preview. You should notice that the dirt layer looks darker now!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Texture rotation'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
An easy way to overcome this is to play with the {{keyvname|Rotation}} value in the Texture Properties section of the Terrain Editor's property list.&lt;br /&gt;
For each node, you should also set the {{keyvname|Distribution Pattern Texture Rotation}} to match the Rotation value if you want your distribution patterns to line up and work correctly.&lt;br /&gt;
&lt;br /&gt;
= Render the MegaTexture =&lt;br /&gt;
=== Save the Surface Tree ===&lt;br /&gt;
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 &amp;quot;Save and Unload&amp;quot; button in the Terrain Editor, or save the whole map.&lt;br /&gt;
&lt;br /&gt;
=== Compile Only Entities ===&lt;br /&gt;
At this stage, your MegaTexture material is still technically &amp;quot;broken&amp;quot;, 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.&lt;br /&gt;
&lt;br /&gt;
However, we need to compile the map in order to tell the [[renderLight]] process which atmosphere to use when lighting the MegaTexture!&lt;br /&gt;
&lt;br /&gt;
So the solution is to do an '''Only Entities''' compile. You can find this in the menu ''Compile -&amp;gt; 2 - Only Entities'' in editWorld. This should be done in a few seconds, and compiles all the information that renderLight needs.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Run the SDK Launcher ===&lt;br /&gt;
Now that your ''.sft'' is saved, go through all the steps outlined in the [[Generate a MegaTexture]] tutorial.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= That's it! =&lt;br /&gt;
[[Image:simplemega_ingame.jpg|thumb|300px|The MegaTexture in-game!]]&lt;br /&gt;
You've now created your very own MegaTexture to use in your map!&lt;br /&gt;
&lt;br /&gt;
Before you even compile the map, you can get an accurate preview of how it will look in-game by pressing {{accelkey|F6}} to toggle &amp;quot;anim&amp;quot; mode while in editWorld's &amp;quot;RENDER&amp;quot; Camera view (toggled with {{accelkey|F3}}).&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
= Troubleshooting =&lt;br /&gt;
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:&lt;br /&gt;
* 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.&lt;br /&gt;
* 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 ''&amp;lt; &amp;quot;mapname&amp;quot; &amp;gt;'' part described in [[A Simple First Megatexture#Creating a MegaTexture material|this section]]), otherwise it will not be searching for the correct images.&lt;br /&gt;
* 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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
= See Also =&lt;br /&gt;
* [[An Advanced Terrain and Megatexture]] - an advanced guide for complete MegaTexture creation&lt;br /&gt;
* [[Generate a MegaTexture]] - steps for generating a MegaTexture from the SDK launcher.&lt;br /&gt;
* [http://community.enemyterritory.com/forums/showthread.php?t=19326 Forum Thread] - includes textures to download&lt;br /&gt;
&lt;br /&gt;
[[Category:Art]]&lt;br /&gt;
[[Category:Basic Level Design]]&lt;br /&gt;
[[Category:Tutorials]]&lt;/div&gt;</summary>
		<author><name>Ducks</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.splashdamage.com/index.php?title=A_Simple_First_Megatexture&amp;diff=4046</id>
		<title>A Simple First Megatexture</title>
		<link rel="alternate" type="text/html" href="https://wiki.splashdamage.com/index.php?title=A_Simple_First_Megatexture&amp;diff=4046"/>
		<updated>2007-12-17T15:04:25Z</updated>

		<summary type="html">&lt;p&gt;Ducks: /* Create the first texture node */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Image:simplemega_ingame.jpg|right|thumb|500px|A simple MegaTexture, easily created with only 3 texture layers!]]&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
= Introduction =&lt;br /&gt;
'''For this tutorial you must:'''&lt;br /&gt;
* Have a terrain model UV-mapped in the 0-1 range (covered in the simple first terrain tutorial)&lt;br /&gt;
* Have access to some tiling textures.&lt;br /&gt;
* Have a little understanding the ETQW material system&lt;br /&gt;
&lt;br /&gt;
If you don't have any of the above things, you are not ready to do this tutorial!&lt;br /&gt;
&lt;br /&gt;
'''This tutorial covers:'''&lt;br /&gt;
* How to set up a MegaTexture material&lt;br /&gt;
* How to create a Surface Tree&lt;br /&gt;
* How to add texture nodes in the Terrain Editor&lt;br /&gt;
* How to render and compile a full MegaTexture&lt;br /&gt;
&lt;br /&gt;
'''This tutorial does not cover:'''&lt;br /&gt;
* How to use Blender/Maya/Lightwave/ZBrush/Mudbox/3DSMax/Photoshop&lt;br /&gt;
* How to create tiling textures or heightmaps&lt;br /&gt;
* Anything overly complicated&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Creating a MegaTexture material =&lt;br /&gt;
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:&lt;br /&gt;
 material megatextures/mapname		{ useTemplate megatextures/default_ambient&amp;lt; &amp;quot;mapname&amp;quot; &amp;gt; }&lt;br /&gt;
&lt;br /&gt;
This material would automatically search for a MegaTexture called {{filename|mapname.mega}} in the {{filename|/megatextures/}} folder. This example material uses the ''&amp;quot;default_ambient&amp;quot;'' 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]].&lt;br /&gt;
&lt;br /&gt;
Obviously you would want to use the actual name of your map instead of &amp;quot;mapname&amp;quot;, for consistency's sake and ease of reference.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Assigning the material ===&lt;br /&gt;
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).&lt;br /&gt;
Tips on this process can be found in the [[A Simple First Terrain|simple first terrain tutorial]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Creating the Surface Tree =&lt;br /&gt;
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 &amp;quot;Save and Unload&amp;quot; button in the Terrain Editor.&lt;br /&gt;
[[Image:simplemega_terrainmodel.png|thumb|300px|Root node set up to use the correct terrain mesh]]&lt;br /&gt;
&lt;br /&gt;
=== Add the terrain mesh ===&lt;br /&gt;
Here's how you bring the terrain mesh into the surface tree:&lt;br /&gt;
* {{accelbtn|RMB}} on the left-hand pane, and choose ''New -&amp;gt; Tree'' via the menu.&lt;br /&gt;
** If you already have a Root node, click the &amp;quot;Begin Editing&amp;quot; button instead.&lt;br /&gt;
* Click on the Root node, and set {{keyname|Model}} to the name of the terrain mesh, in this case {{keyvalue|models/terrain/simpleterrain.obj}}.&lt;br /&gt;
* Press {{accelkey|enter}} to confirm the selection, and the terrain should appear in the 3D view.&lt;br /&gt;
&lt;br /&gt;
Be aware that your terrain model will probably appear bright orange or red.&lt;br /&gt;
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!&lt;br /&gt;
&lt;br /&gt;
=== Important note about nodes ===&lt;br /&gt;
When you are editing properties of nodes (names, numbers, texture sources etc.) always remember to hit {{accelkey|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 {{accelkey|enter}}, your changes may not be applied.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Create the first texture node ==&lt;br /&gt;
[[Image:simplemega_firstnode_diffuse.png|thumb|300px|The first texture node's diffuse texture properties]]&lt;br /&gt;
Now that the model is in place, you can start laying down the texture layers (or &amp;quot;nodes&amp;quot;) that will make up your MegaTexture.&lt;br /&gt;
&lt;br /&gt;
First you need to create a new Image Source node in the Terrain Editor.&lt;br /&gt;
* {{accelbtn|RMB}} on your &amp;quot;Root&amp;quot; node and choose ''New -&amp;gt; Image Source'' (or press {{accelkey|shift}}{{accelkey|i}})&lt;br /&gt;
* This will make a new node called &amp;quot;New Image Renderer&amp;quot;.&lt;br /&gt;
* You can rename this new node using the &amp;quot;Name&amp;quot; property field in the '''Object''' section.&lt;br /&gt;
* Rename the node &amp;quot;Dirt&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You will notice in the top right of the Terrain Editor, a section listing things like &amp;quot;Diffuse&amp;quot;, &amp;quot;Distribution&amp;quot;, &amp;quot;Distribution Pattern&amp;quot; etc. Selecting one of these will list all of the properties for that section of the current node.&lt;br /&gt;
The ones we need to worry about are as follows:&lt;br /&gt;
&lt;br /&gt;
==== Diffuse ====&lt;br /&gt;
This is the colour map of the current node, and it should point to a tiling TGA texture.&lt;br /&gt;
* Make sure the Diffuse section is highlighted in the top right of the Terrain Editor.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to a generic tiling dirt texture. Remember to hit {{accelkey|enter}} afterwards!&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/dirt_02_d.tga}}&lt;br /&gt;
* The {{keyname|Scale}} field at the very bottom of the property list allows you to choose how much to tile the texture.&lt;br /&gt;
** 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!&lt;br /&gt;
** 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.&lt;br /&gt;
That's all you need to do for the Diffuse settings in this node.&lt;br /&gt;
&lt;br /&gt;
==== Distribution ====&lt;br /&gt;
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''.&lt;br /&gt;
* Make sure the Distribution section is highlighted in the top right.&lt;br /&gt;
* Since this is our first node, we want to show over the whole terrain. This means the distribution map should be 100% white.&lt;br /&gt;
* You can either assign a pure white TGA texture, or change the {{keyname|Source Type}} to {{keyvalue|geometryBased}}.&lt;br /&gt;
** {{keyvalue|geometryBased}} will by default create a fully white map, so if you don't have a white TGA handy, this is faster.&lt;br /&gt;
&lt;br /&gt;
==== Distribution Pattern ====&lt;br /&gt;
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.&lt;br /&gt;
* 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!&lt;br /&gt;
&lt;br /&gt;
==== Local ====&lt;br /&gt;
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.&lt;br /&gt;
* Make sure the Local section is highlighted in the top right.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching normal map for your tiling dirt texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/dirt_02_local.tga}}&lt;br /&gt;
* The Local texture's tiling amount is automatically the same as the Diffuse texture.&lt;br /&gt;
&lt;br /&gt;
==== Surface Type ====&lt;br /&gt;
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.&lt;br /&gt;
* Find the ''Surface Type Properties'' section of the property list.&lt;br /&gt;
* 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.&lt;br /&gt;
* Hit {{accelkey|enter}} to accept the surface type.&lt;br /&gt;
&lt;br /&gt;
Your dirt textures will now produce correct &amp;quot;dirt&amp;quot; effects when shot or collided with!&lt;br /&gt;
&lt;br /&gt;
=== Previewing the result ===&lt;br /&gt;
[[Image:simplemega_firstnode_preview.jpg|thumb|300px|The Render mode preview of the first node]]&lt;br /&gt;
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]]&lt;br /&gt;
&lt;br /&gt;
* Notice the drop-down arrow on the right of the button. Click it, and select ''&amp;quot;Full&amp;quot;'' instead of ''&amp;quot;None&amp;quot;''.&lt;br /&gt;
* Your terrain should change colour to black. This means it's ready for a preview to be rendered onto it.&lt;br /&gt;
* Click the button itself now, instead of the drop-down. An &amp;quot;Active Tasks&amp;quot; window should pop up, and when it's done, you should see your dirt texture appear on your terrain model.&lt;br /&gt;
* You can switch the camera to Render mode too, which will show your terrain model's shading better.&lt;br /&gt;
* If you want a full-resolution preview of a small area, choose ''&amp;quot;Window&amp;quot;'' instead of ''&amp;quot;Full&amp;quot;'' from the drop-down menu.&lt;br /&gt;
** 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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
'''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.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
== Adding a second node ==&lt;br /&gt;
Now that the first layer of dirt is in place, we can try putting some grass on top of it!&lt;br /&gt;
* Again, {{accelbtn|RMB}} on your &amp;quot;Root&amp;quot; node and choose ''New -&amp;gt; Image Source'' (or press {{accelkey|shift}}{{accelkey|i}})&lt;br /&gt;
* This will make another new node below your &amp;quot;Dirt&amp;quot; node. &lt;br /&gt;
* Name this new node &amp;quot;Grass&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Again, the main map types need to be specified before the node can be rendered:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Diffuse'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
* Make sure the Diffuse section is highlighted in the top right of the Terrain Editor.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to a generic tiling grass texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/grass_04_d.tga}}&lt;br /&gt;
* 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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Distribution'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
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!&lt;br /&gt;
* Make sure the Distribution section is highlighted in the top right.&lt;br /&gt;
* Change the {{keyname|Source Type}} from {{keyvalue|texture}} to {{keyvalue|geometryBased}}.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Geometric Texture Distribution'''&lt;br /&gt;
----&lt;br /&gt;
[[Image:simplemega_geometric_distribution.png|thumb|300px|The geometric texture distribution settings of the second node]]&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
* ''Altitude Lower'' - Enabling this will limit the lower parts of the terrain from receiving this node's textures.&lt;br /&gt;
** {{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.&lt;br /&gt;
** {{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.&lt;br /&gt;
* ''Altitude Upper'' - Enabling this will limit the higher parts of the terrain from receiving this node's textures.&lt;br /&gt;
** {{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.&lt;br /&gt;
** {{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.&lt;br /&gt;
&lt;br /&gt;
* {{keyname|Clamp Distribution To Edge}} - Leave this on Default.&lt;br /&gt;
&lt;br /&gt;
* {{keyname|Resolution}} - The size in pixels of the resulting mask. The default value of {{keyvalue|256}} is fine for nearly any terrain model.&lt;br /&gt;
&lt;br /&gt;
* ''Slope Lower'' - Enabling this will limit shallower angles of the terrain model from receiving this node's textures.&lt;br /&gt;
** {{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.&lt;br /&gt;
** {{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.&lt;br /&gt;
* ''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.&lt;br /&gt;
** {{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.&lt;br /&gt;
** {{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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Distribution Pattern'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
[[Image:simplemega_dist_ramps.jpg|thumb|300px|The difference between using or not using a Distribution Pattern, and varying Ramp Widths]]&lt;br /&gt;
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!&lt;br /&gt;
So what we want here is a texture to identify the &amp;quot;height&amp;quot; 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.&lt;br /&gt;
&lt;br /&gt;
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!&lt;br /&gt;
&lt;br /&gt;
* Make sure {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching heightmap or mask for your tiling grass texture.&lt;br /&gt;
** This example is using {{filename|textures/megagen/temperate/grass_04_mask.tga}}&lt;br /&gt;
* 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 &amp;quot;Window&amp;quot; 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.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Local'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
Again we want the normal-map which matches the diffuse texture for the grass.&lt;br /&gt;
* Make sure the Local section is highlighted in the top right.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching normal map for your tiling grass texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/grass_04_local.tga}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Surface Type'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
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.&lt;br /&gt;
* Find the ''Surface Type Properties'' section of the property list.&lt;br /&gt;
* 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.&lt;br /&gt;
* Hit {{accelkey|enter}} to accept the surface type.&lt;br /&gt;
&lt;br /&gt;
Your grass textures should now produce correct &amp;quot;grass&amp;quot; effects when shot or collided with!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Preview again!'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
[[Image:simplemega_secondnode_preview.jpg|thumb|300px|The Render mode preview of the second node blended with the first node]]&lt;br /&gt;
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.&lt;br /&gt;
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.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
== Adding a third node ==&lt;br /&gt;
[[Image:simplemega_thirdnode_preview.jpg|thumb|300px|The Render mode preview of the third node blended with the other two nodes]]&lt;br /&gt;
Now that the grass and dirt are in place, we need some rocks to make the terrain look more natural.&lt;br /&gt;
* Add a new Image Renderer node below your &amp;quot;Grass&amp;quot; node and name it &amp;quot;Rock&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Again, the main map types need to be specified before the node can be rendered:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Diffuse'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
* Set the '''Diffuse''' texture and scale.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/rock_01_d.tga}} at a scale of {{keyvalue|32 32}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Distribution'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
Again we can use Geometric Texture Distribution to easily apply the rock textures only to the cliff-like angles.&lt;br /&gt;
* Make sure the Distribution section is highlighted in the top right.&lt;br /&gt;
* Change the {{keyname|Source Type}} to {{keyvalue|geometryBased}}.&lt;br /&gt;
* 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}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Distribution Pattern'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
Again this will control how the the rocks blend into the other nodes. Again, we want a texture to identify the &amp;quot;height&amp;quot; of the tiling rock texture.&lt;br /&gt;
&lt;br /&gt;
* Make sure the Distribution Pattern section is highlighted in the top right.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching heightmap or mask for your tiling rock texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/rock_01_h.tga}}&lt;br /&gt;
* 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 &amp;quot;Window&amp;quot; preview to see how the blending looks.&lt;br /&gt;
* Remember to set the {{keyname|Distribution Pattern Texture Scale}} to the same value as the Diffuse Scale, {{keyvalue|32 32}}.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Local'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
Again we want the normal-map which matches the diffuse texture for the rocks.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Local''' section, browse to the matching normal map for your tiling rock texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/rock_01_local.tga}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Surface Type'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
* Find the ''Surface Type Properties'' section of the property list.&lt;br /&gt;
* In the {{keyname|Type}} field, enter {{keyvalue|stone}}.&lt;br /&gt;
* Hit {{accelkey|enter}} to accept the surface type.&lt;br /&gt;
&lt;br /&gt;
Your rock textures should now produce correct &amp;quot;stone&amp;quot; effects when shot or collided with.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Preview again!'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Further tweaks ==&lt;br /&gt;
There are other simple changes that can be done in the Terrain Editor to make your MegaTexture look even better.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Node order'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
[[Image:simplemega_node_order.png|frame|Click and drag a node to change the order]]&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
* {{accelbtn|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.&lt;br /&gt;
* Release {{accelbtn|LMB}} when you have positioned the node in the correct place.&lt;br /&gt;
* 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!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Color changes'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
Maybe your dirt texture is too bright? Or maybe your grass looks a little ''too'' green?&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Let's say you want to make the dirt texture darker and a bit more red. Here's how you'd do it:&lt;br /&gt;
* Select your Dirt node.&lt;br /&gt;
* 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).&lt;br /&gt;
* A color wheel and brightness slider will pop up in a new window. You can use this to darken and tint your texture.&lt;br /&gt;
* Choose a darker brightness, and a color slightly towards red. I used '''RGB Values''' of 225, 220, 220.&lt;br /&gt;
* Hit ''OK'' to accept the color.&lt;br /&gt;
* Re-render your MegaTexture preview. You should notice that the dirt layer looks darker now!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Texture rotation'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
An easy way to overcome this is to play with the {{keyvname|Rotation}} value in the Texture Properties section of the Terrain Editor's property list.&lt;br /&gt;
For each node, you should also set the {{keyvname|Distribution Pattern Texture Rotation}} to match the Rotation value if you want your distribution patterns to line up and work correctly.&lt;br /&gt;
&lt;br /&gt;
= Render the MegaTexture =&lt;br /&gt;
=== Save the Surface Tree ===&lt;br /&gt;
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 &amp;quot;Save and Unload&amp;quot; button in the Terrain Editor, or save the whole map.&lt;br /&gt;
&lt;br /&gt;
=== Compile Only Entities ===&lt;br /&gt;
At this stage, your MegaTexture material is still technically &amp;quot;broken&amp;quot;, 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.&lt;br /&gt;
&lt;br /&gt;
However, we need to compile the map in order to tell the [[renderLight]] process which atmosphere to use when lighting the MegaTexture!&lt;br /&gt;
&lt;br /&gt;
So the solution is to do an '''Only Entities''' compile. You can find this in the menu ''Compile -&amp;gt; 2 - Only Entities'' in editWorld. This should be done in a few seconds, and compiles all the information that renderLight needs.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Run the SDK Launcher ===&lt;br /&gt;
Now that your ''.sft'' is saved, go through all the steps outlined in the [[Generate a MegaTexture]] tutorial.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= That's it! =&lt;br /&gt;
[[Image:simplemega_ingame.jpg|thumb|300px|The MegaTexture in-game!]]&lt;br /&gt;
You've now created your very own MegaTexture to use in your map!&lt;br /&gt;
&lt;br /&gt;
Before you even compile the map, you can get an accurate preview of how it will look in-game by pressing {{accelkey|F6}} to toggle &amp;quot;anim&amp;quot; mode while in editWorld's &amp;quot;RENDER&amp;quot; Camera view (toggled with {{accelkey|F3}}).&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
= Troubleshooting =&lt;br /&gt;
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:&lt;br /&gt;
* 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.&lt;br /&gt;
* 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 ''&amp;lt; &amp;quot;mapname&amp;quot; &amp;gt;'' part described in [[A Simple First Megatexture#Creating a MegaTexture material|this section]]), otherwise it will not be searching for the correct images.&lt;br /&gt;
* 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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
= See Also =&lt;br /&gt;
* [[An Advanced Terrain and Megatexture]] - an advanced guide for complete MegaTexture creation&lt;br /&gt;
* [[Generate a MegaTexture]] - steps for generating a MegaTexture from the SDK launcher.&lt;br /&gt;
* [http://community.enemyterritory.com/forums/showthread.php?t=19326 Forum Thread] - includes textures to download&lt;br /&gt;
&lt;br /&gt;
[[Category:Art]]&lt;br /&gt;
[[Category:Basic Level Design]]&lt;br /&gt;
[[Category:Tutorials]]&lt;/div&gt;</summary>
		<author><name>Ducks</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.splashdamage.com/index.php?title=A_Simple_First_Megatexture&amp;diff=4045</id>
		<title>A Simple First Megatexture</title>
		<link rel="alternate" type="text/html" href="https://wiki.splashdamage.com/index.php?title=A_Simple_First_Megatexture&amp;diff=4045"/>
		<updated>2007-12-17T15:04:05Z</updated>

		<summary type="html">&lt;p&gt;Ducks: /* Create the first texture node */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Image:simplemega_ingame.jpg|right|thumb|500px|A simple MegaTexture, easily created with only 3 texture layers!]]&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
= Introduction =&lt;br /&gt;
'''For this tutorial you must:'''&lt;br /&gt;
* Have a terrain model UV-mapped in the 0-1 range (covered in the simple first terrain tutorial)&lt;br /&gt;
* Have access to some tiling textures.&lt;br /&gt;
* Have a little understanding the ETQW material system&lt;br /&gt;
&lt;br /&gt;
If you don't have any of the above things, you are not ready to do this tutorial!&lt;br /&gt;
&lt;br /&gt;
'''This tutorial covers:'''&lt;br /&gt;
* How to set up a MegaTexture material&lt;br /&gt;
* How to create a Surface Tree&lt;br /&gt;
* How to add texture nodes in the Terrain Editor&lt;br /&gt;
* How to render and compile a full MegaTexture&lt;br /&gt;
&lt;br /&gt;
'''This tutorial does not cover:'''&lt;br /&gt;
* How to use Blender/Maya/Lightwave/ZBrush/Mudbox/3DSMax/Photoshop&lt;br /&gt;
* How to create tiling textures or heightmaps&lt;br /&gt;
* Anything overly complicated&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Creating a MegaTexture material =&lt;br /&gt;
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:&lt;br /&gt;
 material megatextures/mapname		{ useTemplate megatextures/default_ambient&amp;lt; &amp;quot;mapname&amp;quot; &amp;gt; }&lt;br /&gt;
&lt;br /&gt;
This material would automatically search for a MegaTexture called {{filename|mapname.mega}} in the {{filename|/megatextures/}} folder. This example material uses the ''&amp;quot;default_ambient&amp;quot;'' 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]].&lt;br /&gt;
&lt;br /&gt;
Obviously you would want to use the actual name of your map instead of &amp;quot;mapname&amp;quot;, for consistency's sake and ease of reference.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Assigning the material ===&lt;br /&gt;
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).&lt;br /&gt;
Tips on this process can be found in the [[A Simple First Terrain|simple first terrain tutorial]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Creating the Surface Tree =&lt;br /&gt;
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 &amp;quot;Save and Unload&amp;quot; button in the Terrain Editor.&lt;br /&gt;
[[Image:simplemega_terrainmodel.png|thumb|300px|Root node set up to use the correct terrain mesh]]&lt;br /&gt;
&lt;br /&gt;
=== Add the terrain mesh ===&lt;br /&gt;
Here's how you bring the terrain mesh into the surface tree:&lt;br /&gt;
* {{accelbtn|RMB}} on the left-hand pane, and choose ''New -&amp;gt; Tree'' via the menu.&lt;br /&gt;
** If you already have a Root node, click the &amp;quot;Begin Editing&amp;quot; button instead.&lt;br /&gt;
* Click on the Root node, and set {{keyname|Model}} to the name of the terrain mesh, in this case {{keyvalue|models/terrain/simpleterrain.obj}}.&lt;br /&gt;
* Press {{accelkey|enter}} to confirm the selection, and the terrain should appear in the 3D view.&lt;br /&gt;
&lt;br /&gt;
Be aware that your terrain model will probably appear bright orange or red.&lt;br /&gt;
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!&lt;br /&gt;
&lt;br /&gt;
=== Important note about nodes ===&lt;br /&gt;
When you are editing properties of nodes (names, numbers, texture sources etc.) always remember to hit {{accelkey|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 {{accelkey|enter}}, your changes may not be applied.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Create the first texture node ==&lt;br /&gt;
[[Image:simplemega_firstnode_diffuse.png|thumb|300px|The first texture node's diffuse texture properties]]&lt;br /&gt;
Now that the model is in place, you can start laying down the texture layers (or &amp;quot;nodes&amp;quot;) that will make up your MegaTexture.&lt;br /&gt;
&lt;br /&gt;
First you need to create a new Image Source node in the Terrain Editor.&lt;br /&gt;
* {{accelbtn|RMB}} on your &amp;quot;Root&amp;quot; node and choose ''New -&amp;gt; Image Source'' (or press {{accelkey|shift}}{{accelkey|i}})&lt;br /&gt;
* This will make a new node called &amp;quot;New Image Renderer&amp;quot;.&lt;br /&gt;
* You can rename this new node using the &amp;quot;Name&amp;quot; property field in the '''Object''' section.&lt;br /&gt;
* Rename the node &amp;quot;Dirt&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You will notice in the top right of the Terrain Editor, a section listing things like &amp;quot;Diffuse&amp;quot;, &amp;quot;Distribution&amp;quot;, &amp;quot;Distribution Pattern&amp;quot; etc. Selecting one of these will list all of the properties for that section of the current node.&lt;br /&gt;
The ones we need to worry about are as follows:&lt;br /&gt;
&lt;br /&gt;
==== Diffuse ====&lt;br /&gt;
This is the colour map of the current node, and it should point to a tiling TGA texture.&lt;br /&gt;
* Make sure the Diffuse section is highlighted in the top right of the Terrain Editor.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to a generic tiling dirt texture. Remember to hit {{accelkey|enter}} afterwards!&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/dirt_02_d.tga}}&lt;br /&gt;
* The {{keyname|Scale}} field at the very bottom of the property list allows you to choose how much to tile the texture.&lt;br /&gt;
** 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!&lt;br /&gt;
** 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.&lt;br /&gt;
That's all you need to do for the Diffuse settings in this node.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Distribution ====&lt;br /&gt;
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''.&lt;br /&gt;
* Make sure the Distribution section is highlighted in the top right.&lt;br /&gt;
* Since this is our first node, we want to show over the whole terrain. This means the distribution map should be 100% white.&lt;br /&gt;
* You can either assign a pure white TGA texture, or change the {{keyname|Source Type}} to {{keyvalue|geometryBased}}.&lt;br /&gt;
** {{keyvalue|geometryBased}} will by default create a fully white map, so if you don't have a white TGA handy, this is faster.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Distribution Pattern ====&lt;br /&gt;
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.&lt;br /&gt;
* 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!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Local ====&lt;br /&gt;
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.&lt;br /&gt;
* Make sure the Local section is highlighted in the top right.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching normal map for your tiling dirt texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/dirt_02_local.tga}}&lt;br /&gt;
* The Local texture's tiling amount is automatically the same as the Diffuse texture.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Surface Type ====&lt;br /&gt;
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.&lt;br /&gt;
* Find the ''Surface Type Properties'' section of the property list.&lt;br /&gt;
* 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.&lt;br /&gt;
* Hit {{accelkey|enter}} to accept the surface type.&lt;br /&gt;
&lt;br /&gt;
Your dirt textures will now produce correct &amp;quot;dirt&amp;quot; effects when shot or collided with!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Previewing the result ===&lt;br /&gt;
[[Image:simplemega_firstnode_preview.jpg|thumb|300px|The Render mode preview of the first node]]&lt;br /&gt;
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]]&lt;br /&gt;
&lt;br /&gt;
* Notice the drop-down arrow on the right of the button. Click it, and select ''&amp;quot;Full&amp;quot;'' instead of ''&amp;quot;None&amp;quot;''.&lt;br /&gt;
* Your terrain should change colour to black. This means it's ready for a preview to be rendered onto it.&lt;br /&gt;
* Click the button itself now, instead of the drop-down. An &amp;quot;Active Tasks&amp;quot; window should pop up, and when it's done, you should see your dirt texture appear on your terrain model.&lt;br /&gt;
* You can switch the camera to Render mode too, which will show your terrain model's shading better.&lt;br /&gt;
* If you want a full-resolution preview of a small area, choose ''&amp;quot;Window&amp;quot;'' instead of ''&amp;quot;Full&amp;quot;'' from the drop-down menu.&lt;br /&gt;
** 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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
'''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.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
== Adding a second node ==&lt;br /&gt;
Now that the first layer of dirt is in place, we can try putting some grass on top of it!&lt;br /&gt;
* Again, {{accelbtn|RMB}} on your &amp;quot;Root&amp;quot; node and choose ''New -&amp;gt; Image Source'' (or press {{accelkey|shift}}{{accelkey|i}})&lt;br /&gt;
* This will make another new node below your &amp;quot;Dirt&amp;quot; node. &lt;br /&gt;
* Name this new node &amp;quot;Grass&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Again, the main map types need to be specified before the node can be rendered:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Diffuse'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
* Make sure the Diffuse section is highlighted in the top right of the Terrain Editor.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to a generic tiling grass texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/grass_04_d.tga}}&lt;br /&gt;
* 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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Distribution'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
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!&lt;br /&gt;
* Make sure the Distribution section is highlighted in the top right.&lt;br /&gt;
* Change the {{keyname|Source Type}} from {{keyvalue|texture}} to {{keyvalue|geometryBased}}.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Geometric Texture Distribution'''&lt;br /&gt;
----&lt;br /&gt;
[[Image:simplemega_geometric_distribution.png|thumb|300px|The geometric texture distribution settings of the second node]]&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
* ''Altitude Lower'' - Enabling this will limit the lower parts of the terrain from receiving this node's textures.&lt;br /&gt;
** {{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.&lt;br /&gt;
** {{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.&lt;br /&gt;
* ''Altitude Upper'' - Enabling this will limit the higher parts of the terrain from receiving this node's textures.&lt;br /&gt;
** {{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.&lt;br /&gt;
** {{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.&lt;br /&gt;
&lt;br /&gt;
* {{keyname|Clamp Distribution To Edge}} - Leave this on Default.&lt;br /&gt;
&lt;br /&gt;
* {{keyname|Resolution}} - The size in pixels of the resulting mask. The default value of {{keyvalue|256}} is fine for nearly any terrain model.&lt;br /&gt;
&lt;br /&gt;
* ''Slope Lower'' - Enabling this will limit shallower angles of the terrain model from receiving this node's textures.&lt;br /&gt;
** {{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.&lt;br /&gt;
** {{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.&lt;br /&gt;
* ''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.&lt;br /&gt;
** {{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.&lt;br /&gt;
** {{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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Distribution Pattern'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
[[Image:simplemega_dist_ramps.jpg|thumb|300px|The difference between using or not using a Distribution Pattern, and varying Ramp Widths]]&lt;br /&gt;
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!&lt;br /&gt;
So what we want here is a texture to identify the &amp;quot;height&amp;quot; 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.&lt;br /&gt;
&lt;br /&gt;
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!&lt;br /&gt;
&lt;br /&gt;
* Make sure {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching heightmap or mask for your tiling grass texture.&lt;br /&gt;
** This example is using {{filename|textures/megagen/temperate/grass_04_mask.tga}}&lt;br /&gt;
* 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 &amp;quot;Window&amp;quot; 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.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Local'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
Again we want the normal-map which matches the diffuse texture for the grass.&lt;br /&gt;
* Make sure the Local section is highlighted in the top right.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching normal map for your tiling grass texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/grass_04_local.tga}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Surface Type'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
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.&lt;br /&gt;
* Find the ''Surface Type Properties'' section of the property list.&lt;br /&gt;
* 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.&lt;br /&gt;
* Hit {{accelkey|enter}} to accept the surface type.&lt;br /&gt;
&lt;br /&gt;
Your grass textures should now produce correct &amp;quot;grass&amp;quot; effects when shot or collided with!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Preview again!'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
[[Image:simplemega_secondnode_preview.jpg|thumb|300px|The Render mode preview of the second node blended with the first node]]&lt;br /&gt;
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.&lt;br /&gt;
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.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
== Adding a third node ==&lt;br /&gt;
[[Image:simplemega_thirdnode_preview.jpg|thumb|300px|The Render mode preview of the third node blended with the other two nodes]]&lt;br /&gt;
Now that the grass and dirt are in place, we need some rocks to make the terrain look more natural.&lt;br /&gt;
* Add a new Image Renderer node below your &amp;quot;Grass&amp;quot; node and name it &amp;quot;Rock&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Again, the main map types need to be specified before the node can be rendered:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Diffuse'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
* Set the '''Diffuse''' texture and scale.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/rock_01_d.tga}} at a scale of {{keyvalue|32 32}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Distribution'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
Again we can use Geometric Texture Distribution to easily apply the rock textures only to the cliff-like angles.&lt;br /&gt;
* Make sure the Distribution section is highlighted in the top right.&lt;br /&gt;
* Change the {{keyname|Source Type}} to {{keyvalue|geometryBased}}.&lt;br /&gt;
* 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}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Distribution Pattern'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
Again this will control how the the rocks blend into the other nodes. Again, we want a texture to identify the &amp;quot;height&amp;quot; of the tiling rock texture.&lt;br /&gt;
&lt;br /&gt;
* Make sure the Distribution Pattern section is highlighted in the top right.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching heightmap or mask for your tiling rock texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/rock_01_h.tga}}&lt;br /&gt;
* 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 &amp;quot;Window&amp;quot; preview to see how the blending looks.&lt;br /&gt;
* Remember to set the {{keyname|Distribution Pattern Texture Scale}} to the same value as the Diffuse Scale, {{keyvalue|32 32}}.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Local'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
Again we want the normal-map which matches the diffuse texture for the rocks.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Local''' section, browse to the matching normal map for your tiling rock texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/rock_01_local.tga}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Surface Type'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
* Find the ''Surface Type Properties'' section of the property list.&lt;br /&gt;
* In the {{keyname|Type}} field, enter {{keyvalue|stone}}.&lt;br /&gt;
* Hit {{accelkey|enter}} to accept the surface type.&lt;br /&gt;
&lt;br /&gt;
Your rock textures should now produce correct &amp;quot;stone&amp;quot; effects when shot or collided with.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Preview again!'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Further tweaks ==&lt;br /&gt;
There are other simple changes that can be done in the Terrain Editor to make your MegaTexture look even better.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Node order'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
[[Image:simplemega_node_order.png|frame|Click and drag a node to change the order]]&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
* {{accelbtn|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.&lt;br /&gt;
* Release {{accelbtn|LMB}} when you have positioned the node in the correct place.&lt;br /&gt;
* 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!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Color changes'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
Maybe your dirt texture is too bright? Or maybe your grass looks a little ''too'' green?&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Let's say you want to make the dirt texture darker and a bit more red. Here's how you'd do it:&lt;br /&gt;
* Select your Dirt node.&lt;br /&gt;
* 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).&lt;br /&gt;
* A color wheel and brightness slider will pop up in a new window. You can use this to darken and tint your texture.&lt;br /&gt;
* Choose a darker brightness, and a color slightly towards red. I used '''RGB Values''' of 225, 220, 220.&lt;br /&gt;
* Hit ''OK'' to accept the color.&lt;br /&gt;
* Re-render your MegaTexture preview. You should notice that the dirt layer looks darker now!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Texture rotation'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
An easy way to overcome this is to play with the {{keyvname|Rotation}} value in the Texture Properties section of the Terrain Editor's property list.&lt;br /&gt;
For each node, you should also set the {{keyvname|Distribution Pattern Texture Rotation}} to match the Rotation value if you want your distribution patterns to line up and work correctly.&lt;br /&gt;
&lt;br /&gt;
= Render the MegaTexture =&lt;br /&gt;
=== Save the Surface Tree ===&lt;br /&gt;
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 &amp;quot;Save and Unload&amp;quot; button in the Terrain Editor, or save the whole map.&lt;br /&gt;
&lt;br /&gt;
=== Compile Only Entities ===&lt;br /&gt;
At this stage, your MegaTexture material is still technically &amp;quot;broken&amp;quot;, 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.&lt;br /&gt;
&lt;br /&gt;
However, we need to compile the map in order to tell the [[renderLight]] process which atmosphere to use when lighting the MegaTexture!&lt;br /&gt;
&lt;br /&gt;
So the solution is to do an '''Only Entities''' compile. You can find this in the menu ''Compile -&amp;gt; 2 - Only Entities'' in editWorld. This should be done in a few seconds, and compiles all the information that renderLight needs.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Run the SDK Launcher ===&lt;br /&gt;
Now that your ''.sft'' is saved, go through all the steps outlined in the [[Generate a MegaTexture]] tutorial.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= That's it! =&lt;br /&gt;
[[Image:simplemega_ingame.jpg|thumb|300px|The MegaTexture in-game!]]&lt;br /&gt;
You've now created your very own MegaTexture to use in your map!&lt;br /&gt;
&lt;br /&gt;
Before you even compile the map, you can get an accurate preview of how it will look in-game by pressing {{accelkey|F6}} to toggle &amp;quot;anim&amp;quot; mode while in editWorld's &amp;quot;RENDER&amp;quot; Camera view (toggled with {{accelkey|F3}}).&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
= Troubleshooting =&lt;br /&gt;
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:&lt;br /&gt;
* 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.&lt;br /&gt;
* 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 ''&amp;lt; &amp;quot;mapname&amp;quot; &amp;gt;'' part described in [[A Simple First Megatexture#Creating a MegaTexture material|this section]]), otherwise it will not be searching for the correct images.&lt;br /&gt;
* 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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
= See Also =&lt;br /&gt;
* [[An Advanced Terrain and Megatexture]] - an advanced guide for complete MegaTexture creation&lt;br /&gt;
* [[Generate a MegaTexture]] - steps for generating a MegaTexture from the SDK launcher.&lt;br /&gt;
* [http://community.enemyterritory.com/forums/showthread.php?t=19326 Forum Thread] - includes textures to download&lt;br /&gt;
&lt;br /&gt;
[[Category:Art]]&lt;br /&gt;
[[Category:Basic Level Design]]&lt;br /&gt;
[[Category:Tutorials]]&lt;/div&gt;</summary>
		<author><name>Ducks</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.splashdamage.com/index.php?title=A_Simple_First_Megatexture&amp;diff=4044</id>
		<title>A Simple First Megatexture</title>
		<link rel="alternate" type="text/html" href="https://wiki.splashdamage.com/index.php?title=A_Simple_First_Megatexture&amp;diff=4044"/>
		<updated>2007-12-17T15:03:04Z</updated>

		<summary type="html">&lt;p&gt;Ducks: /* Adding a third node */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Image:simplemega_ingame.jpg|right|thumb|500px|A simple MegaTexture, easily created with only 3 texture layers!]]&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
= Introduction =&lt;br /&gt;
'''For this tutorial you must:'''&lt;br /&gt;
* Have a terrain model UV-mapped in the 0-1 range (covered in the simple first terrain tutorial)&lt;br /&gt;
* Have access to some tiling textures.&lt;br /&gt;
* Have a little understanding the ETQW material system&lt;br /&gt;
&lt;br /&gt;
If you don't have any of the above things, you are not ready to do this tutorial!&lt;br /&gt;
&lt;br /&gt;
'''This tutorial covers:'''&lt;br /&gt;
* How to set up a MegaTexture material&lt;br /&gt;
* How to create a Surface Tree&lt;br /&gt;
* How to add texture nodes in the Terrain Editor&lt;br /&gt;
* How to render and compile a full MegaTexture&lt;br /&gt;
&lt;br /&gt;
'''This tutorial does not cover:'''&lt;br /&gt;
* How to use Blender/Maya/Lightwave/ZBrush/Mudbox/3DSMax/Photoshop&lt;br /&gt;
* How to create tiling textures or heightmaps&lt;br /&gt;
* Anything overly complicated&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Creating a MegaTexture material =&lt;br /&gt;
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:&lt;br /&gt;
 material megatextures/mapname		{ useTemplate megatextures/default_ambient&amp;lt; &amp;quot;mapname&amp;quot; &amp;gt; }&lt;br /&gt;
&lt;br /&gt;
This material would automatically search for a MegaTexture called {{filename|mapname.mega}} in the {{filename|/megatextures/}} folder. This example material uses the ''&amp;quot;default_ambient&amp;quot;'' 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]].&lt;br /&gt;
&lt;br /&gt;
Obviously you would want to use the actual name of your map instead of &amp;quot;mapname&amp;quot;, for consistency's sake and ease of reference.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Assigning the material ===&lt;br /&gt;
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).&lt;br /&gt;
Tips on this process can be found in the [[A Simple First Terrain|simple first terrain tutorial]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Creating the Surface Tree =&lt;br /&gt;
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 &amp;quot;Save and Unload&amp;quot; button in the Terrain Editor.&lt;br /&gt;
[[Image:simplemega_terrainmodel.png|thumb|300px|Root node set up to use the correct terrain mesh]]&lt;br /&gt;
&lt;br /&gt;
=== Add the terrain mesh ===&lt;br /&gt;
Here's how you bring the terrain mesh into the surface tree:&lt;br /&gt;
* {{accelbtn|RMB}} on the left-hand pane, and choose ''New -&amp;gt; Tree'' via the menu.&lt;br /&gt;
** If you already have a Root node, click the &amp;quot;Begin Editing&amp;quot; button instead.&lt;br /&gt;
* Click on the Root node, and set {{keyname|Model}} to the name of the terrain mesh, in this case {{keyvalue|models/terrain/simpleterrain.obj}}.&lt;br /&gt;
* Press {{accelkey|enter}} to confirm the selection, and the terrain should appear in the 3D view.&lt;br /&gt;
&lt;br /&gt;
Be aware that your terrain model will probably appear bright orange or red.&lt;br /&gt;
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!&lt;br /&gt;
&lt;br /&gt;
=== Important note about nodes ===&lt;br /&gt;
When you are editing properties of nodes (names, numbers, texture sources etc.) always remember to hit {{accelkey|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 {{accelkey|enter}}, your changes may not be applied.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Create the first texture node ==&lt;br /&gt;
[[Image:simplemega_firstnode_diffuse.png|thumb|300px|The first texture node's diffuse texture properties]]&lt;br /&gt;
Now that the model is in place, you can start laying down the texture layers (or &amp;quot;nodes&amp;quot;) that will make up your MegaTexture.&lt;br /&gt;
&lt;br /&gt;
First you need to create a new Image Source node in the Terrain Editor.&lt;br /&gt;
* {{accelbtn|RMB}} on your &amp;quot;Root&amp;quot; node and choose ''New -&amp;gt; Image Source'' (or press {{accelkey|shift}}{{accelkey|i}})&lt;br /&gt;
* This will make a new node called &amp;quot;New Image Renderer&amp;quot;.&lt;br /&gt;
* You can rename this new node using the &amp;quot;Name&amp;quot; property field in the '''Object''' section.&lt;br /&gt;
* Rename the node &amp;quot;Dirt&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You will notice in the top right of the Terrain Editor, a section listing things like &amp;quot;Diffuse&amp;quot;, &amp;quot;Distribution&amp;quot;, &amp;quot;Distribution Pattern&amp;quot; etc. Selecting one of these will list all of the properties for that section of the current node.&lt;br /&gt;
The ones we need to worry about are as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Diffuse'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
This is the colour map of the current node, and it should point to a tiling TGA texture.&lt;br /&gt;
* Make sure the Diffuse section is highlighted in the top right of the Terrain Editor.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to a generic tiling dirt texture. Remember to hit {{accelkey|enter}} afterwards!&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/dirt_02_d.tga}}&lt;br /&gt;
* The {{keyname|Scale}} field at the very bottom of the property list allows you to choose how much to tile the texture.&lt;br /&gt;
** 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!&lt;br /&gt;
** 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.&lt;br /&gt;
That's all you need to do for the Diffuse settings in this node.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Distribution'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
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''.&lt;br /&gt;
* Make sure the Distribution section is highlighted in the top right.&lt;br /&gt;
* Since this is our first node, we want to show over the whole terrain. This means the distribution map should be 100% white.&lt;br /&gt;
* You can either assign a pure white TGA texture, or change the {{keyname|Source Type}} to {{keyvalue|geometryBased}}.&lt;br /&gt;
** {{keyvalue|geometryBased}} will by default create a fully white map, so if you don't have a white TGA handy, this is faster.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Distribution Pattern'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
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.&lt;br /&gt;
* 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!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Local'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
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.&lt;br /&gt;
* Make sure the Local section is highlighted in the top right.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching normal map for your tiling dirt texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/dirt_02_local.tga}}&lt;br /&gt;
* The Local texture's tiling amount is automatically the same as the Diffuse texture.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Surface Type'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
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.&lt;br /&gt;
* Find the ''Surface Type Properties'' section of the property list.&lt;br /&gt;
* 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.&lt;br /&gt;
* Hit {{accelkey|enter}} to accept the surface type.&lt;br /&gt;
&lt;br /&gt;
Your dirt textures will now produce correct &amp;quot;dirt&amp;quot; effects when shot or collided with!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Previewing the result'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
[[Image:simplemega_firstnode_preview.jpg|thumb|300px|The Render mode preview of the first node]]&lt;br /&gt;
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]]&lt;br /&gt;
&lt;br /&gt;
* Notice the drop-down arrow on the right of the button. Click it, and select ''&amp;quot;Full&amp;quot;'' instead of ''&amp;quot;None&amp;quot;''.&lt;br /&gt;
* Your terrain should change colour to black. This means it's ready for a preview to be rendered onto it.&lt;br /&gt;
* Click the button itself now, instead of the drop-down. An &amp;quot;Active Tasks&amp;quot; window should pop up, and when it's done, you should see your dirt texture appear on your terrain model.&lt;br /&gt;
* You can switch the camera to Render mode too, which will show your terrain model's shading better.&lt;br /&gt;
* If you want a full-resolution preview of a small area, choose ''&amp;quot;Window&amp;quot;'' instead of ''&amp;quot;Full&amp;quot;'' from the drop-down menu.&lt;br /&gt;
** 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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
'''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.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
== Adding a second node ==&lt;br /&gt;
Now that the first layer of dirt is in place, we can try putting some grass on top of it!&lt;br /&gt;
* Again, {{accelbtn|RMB}} on your &amp;quot;Root&amp;quot; node and choose ''New -&amp;gt; Image Source'' (or press {{accelkey|shift}}{{accelkey|i}})&lt;br /&gt;
* This will make another new node below your &amp;quot;Dirt&amp;quot; node. &lt;br /&gt;
* Name this new node &amp;quot;Grass&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Again, the main map types need to be specified before the node can be rendered:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Diffuse'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
* Make sure the Diffuse section is highlighted in the top right of the Terrain Editor.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to a generic tiling grass texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/grass_04_d.tga}}&lt;br /&gt;
* 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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Distribution'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
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!&lt;br /&gt;
* Make sure the Distribution section is highlighted in the top right.&lt;br /&gt;
* Change the {{keyname|Source Type}} from {{keyvalue|texture}} to {{keyvalue|geometryBased}}.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Geometric Texture Distribution'''&lt;br /&gt;
----&lt;br /&gt;
[[Image:simplemega_geometric_distribution.png|thumb|300px|The geometric texture distribution settings of the second node]]&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
* ''Altitude Lower'' - Enabling this will limit the lower parts of the terrain from receiving this node's textures.&lt;br /&gt;
** {{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.&lt;br /&gt;
** {{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.&lt;br /&gt;
* ''Altitude Upper'' - Enabling this will limit the higher parts of the terrain from receiving this node's textures.&lt;br /&gt;
** {{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.&lt;br /&gt;
** {{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.&lt;br /&gt;
&lt;br /&gt;
* {{keyname|Clamp Distribution To Edge}} - Leave this on Default.&lt;br /&gt;
&lt;br /&gt;
* {{keyname|Resolution}} - The size in pixels of the resulting mask. The default value of {{keyvalue|256}} is fine for nearly any terrain model.&lt;br /&gt;
&lt;br /&gt;
* ''Slope Lower'' - Enabling this will limit shallower angles of the terrain model from receiving this node's textures.&lt;br /&gt;
** {{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.&lt;br /&gt;
** {{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.&lt;br /&gt;
* ''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.&lt;br /&gt;
** {{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.&lt;br /&gt;
** {{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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Distribution Pattern'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
[[Image:simplemega_dist_ramps.jpg|thumb|300px|The difference between using or not using a Distribution Pattern, and varying Ramp Widths]]&lt;br /&gt;
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!&lt;br /&gt;
So what we want here is a texture to identify the &amp;quot;height&amp;quot; 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.&lt;br /&gt;
&lt;br /&gt;
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!&lt;br /&gt;
&lt;br /&gt;
* Make sure {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching heightmap or mask for your tiling grass texture.&lt;br /&gt;
** This example is using {{filename|textures/megagen/temperate/grass_04_mask.tga}}&lt;br /&gt;
* 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 &amp;quot;Window&amp;quot; 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.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Local'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
Again we want the normal-map which matches the diffuse texture for the grass.&lt;br /&gt;
* Make sure the Local section is highlighted in the top right.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching normal map for your tiling grass texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/grass_04_local.tga}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Surface Type'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
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.&lt;br /&gt;
* Find the ''Surface Type Properties'' section of the property list.&lt;br /&gt;
* 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.&lt;br /&gt;
* Hit {{accelkey|enter}} to accept the surface type.&lt;br /&gt;
&lt;br /&gt;
Your grass textures should now produce correct &amp;quot;grass&amp;quot; effects when shot or collided with!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Preview again!'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
[[Image:simplemega_secondnode_preview.jpg|thumb|300px|The Render mode preview of the second node blended with the first node]]&lt;br /&gt;
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.&lt;br /&gt;
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.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
== Adding a third node ==&lt;br /&gt;
[[Image:simplemega_thirdnode_preview.jpg|thumb|300px|The Render mode preview of the third node blended with the other two nodes]]&lt;br /&gt;
Now that the grass and dirt are in place, we need some rocks to make the terrain look more natural.&lt;br /&gt;
* Add a new Image Renderer node below your &amp;quot;Grass&amp;quot; node and name it &amp;quot;Rock&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Again, the main map types need to be specified before the node can be rendered:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Diffuse'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
* Set the '''Diffuse''' texture and scale.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/rock_01_d.tga}} at a scale of {{keyvalue|32 32}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Distribution'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
Again we can use Geometric Texture Distribution to easily apply the rock textures only to the cliff-like angles.&lt;br /&gt;
* Make sure the Distribution section is highlighted in the top right.&lt;br /&gt;
* Change the {{keyname|Source Type}} to {{keyvalue|geometryBased}}.&lt;br /&gt;
* 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}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Distribution Pattern'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
Again this will control how the the rocks blend into the other nodes. Again, we want a texture to identify the &amp;quot;height&amp;quot; of the tiling rock texture.&lt;br /&gt;
&lt;br /&gt;
* Make sure the Distribution Pattern section is highlighted in the top right.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching heightmap or mask for your tiling rock texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/rock_01_h.tga}}&lt;br /&gt;
* 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 &amp;quot;Window&amp;quot; preview to see how the blending looks.&lt;br /&gt;
* Remember to set the {{keyname|Distribution Pattern Texture Scale}} to the same value as the Diffuse Scale, {{keyvalue|32 32}}.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Local'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
Again we want the normal-map which matches the diffuse texture for the rocks.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Local''' section, browse to the matching normal map for your tiling rock texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/rock_01_local.tga}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Surface Type'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
* Find the ''Surface Type Properties'' section of the property list.&lt;br /&gt;
* In the {{keyname|Type}} field, enter {{keyvalue|stone}}.&lt;br /&gt;
* Hit {{accelkey|enter}} to accept the surface type.&lt;br /&gt;
&lt;br /&gt;
Your rock textures should now produce correct &amp;quot;stone&amp;quot; effects when shot or collided with.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Preview again!'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Further tweaks ==&lt;br /&gt;
There are other simple changes that can be done in the Terrain Editor to make your MegaTexture look even better.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Node order'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
[[Image:simplemega_node_order.png|frame|Click and drag a node to change the order]]&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
* {{accelbtn|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.&lt;br /&gt;
* Release {{accelbtn|LMB}} when you have positioned the node in the correct place.&lt;br /&gt;
* 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!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Color changes'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
Maybe your dirt texture is too bright? Or maybe your grass looks a little ''too'' green?&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Let's say you want to make the dirt texture darker and a bit more red. Here's how you'd do it:&lt;br /&gt;
* Select your Dirt node.&lt;br /&gt;
* 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).&lt;br /&gt;
* A color wheel and brightness slider will pop up in a new window. You can use this to darken and tint your texture.&lt;br /&gt;
* Choose a darker brightness, and a color slightly towards red. I used '''RGB Values''' of 225, 220, 220.&lt;br /&gt;
* Hit ''OK'' to accept the color.&lt;br /&gt;
* Re-render your MegaTexture preview. You should notice that the dirt layer looks darker now!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Texture rotation'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
An easy way to overcome this is to play with the {{keyvname|Rotation}} value in the Texture Properties section of the Terrain Editor's property list.&lt;br /&gt;
For each node, you should also set the {{keyvname|Distribution Pattern Texture Rotation}} to match the Rotation value if you want your distribution patterns to line up and work correctly.&lt;br /&gt;
&lt;br /&gt;
= Render the MegaTexture =&lt;br /&gt;
=== Save the Surface Tree ===&lt;br /&gt;
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 &amp;quot;Save and Unload&amp;quot; button in the Terrain Editor, or save the whole map.&lt;br /&gt;
&lt;br /&gt;
=== Compile Only Entities ===&lt;br /&gt;
At this stage, your MegaTexture material is still technically &amp;quot;broken&amp;quot;, 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.&lt;br /&gt;
&lt;br /&gt;
However, we need to compile the map in order to tell the [[renderLight]] process which atmosphere to use when lighting the MegaTexture!&lt;br /&gt;
&lt;br /&gt;
So the solution is to do an '''Only Entities''' compile. You can find this in the menu ''Compile -&amp;gt; 2 - Only Entities'' in editWorld. This should be done in a few seconds, and compiles all the information that renderLight needs.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Run the SDK Launcher ===&lt;br /&gt;
Now that your ''.sft'' is saved, go through all the steps outlined in the [[Generate a MegaTexture]] tutorial.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= That's it! =&lt;br /&gt;
[[Image:simplemega_ingame.jpg|thumb|300px|The MegaTexture in-game!]]&lt;br /&gt;
You've now created your very own MegaTexture to use in your map!&lt;br /&gt;
&lt;br /&gt;
Before you even compile the map, you can get an accurate preview of how it will look in-game by pressing {{accelkey|F6}} to toggle &amp;quot;anim&amp;quot; mode while in editWorld's &amp;quot;RENDER&amp;quot; Camera view (toggled with {{accelkey|F3}}).&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
= Troubleshooting =&lt;br /&gt;
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:&lt;br /&gt;
* 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.&lt;br /&gt;
* 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 ''&amp;lt; &amp;quot;mapname&amp;quot; &amp;gt;'' part described in [[A Simple First Megatexture#Creating a MegaTexture material|this section]]), otherwise it will not be searching for the correct images.&lt;br /&gt;
* 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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
= See Also =&lt;br /&gt;
* [[An Advanced Terrain and Megatexture]] - an advanced guide for complete MegaTexture creation&lt;br /&gt;
* [[Generate a MegaTexture]] - steps for generating a MegaTexture from the SDK launcher.&lt;br /&gt;
* [http://community.enemyterritory.com/forums/showthread.php?t=19326 Forum Thread] - includes textures to download&lt;br /&gt;
&lt;br /&gt;
[[Category:Art]]&lt;br /&gt;
[[Category:Basic Level Design]]&lt;br /&gt;
[[Category:Tutorials]]&lt;/div&gt;</summary>
		<author><name>Ducks</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.splashdamage.com/index.php?title=A_Simple_First_Megatexture&amp;diff=4043</id>
		<title>A Simple First Megatexture</title>
		<link rel="alternate" type="text/html" href="https://wiki.splashdamage.com/index.php?title=A_Simple_First_Megatexture&amp;diff=4043"/>
		<updated>2007-12-17T15:02:34Z</updated>

		<summary type="html">&lt;p&gt;Ducks: /* Adding a second node */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Image:simplemega_ingame.jpg|right|thumb|500px|A simple MegaTexture, easily created with only 3 texture layers!]]&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
= Introduction =&lt;br /&gt;
'''For this tutorial you must:'''&lt;br /&gt;
* Have a terrain model UV-mapped in the 0-1 range (covered in the simple first terrain tutorial)&lt;br /&gt;
* Have access to some tiling textures.&lt;br /&gt;
* Have a little understanding the ETQW material system&lt;br /&gt;
&lt;br /&gt;
If you don't have any of the above things, you are not ready to do this tutorial!&lt;br /&gt;
&lt;br /&gt;
'''This tutorial covers:'''&lt;br /&gt;
* How to set up a MegaTexture material&lt;br /&gt;
* How to create a Surface Tree&lt;br /&gt;
* How to add texture nodes in the Terrain Editor&lt;br /&gt;
* How to render and compile a full MegaTexture&lt;br /&gt;
&lt;br /&gt;
'''This tutorial does not cover:'''&lt;br /&gt;
* How to use Blender/Maya/Lightwave/ZBrush/Mudbox/3DSMax/Photoshop&lt;br /&gt;
* How to create tiling textures or heightmaps&lt;br /&gt;
* Anything overly complicated&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Creating a MegaTexture material =&lt;br /&gt;
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:&lt;br /&gt;
 material megatextures/mapname		{ useTemplate megatextures/default_ambient&amp;lt; &amp;quot;mapname&amp;quot; &amp;gt; }&lt;br /&gt;
&lt;br /&gt;
This material would automatically search for a MegaTexture called {{filename|mapname.mega}} in the {{filename|/megatextures/}} folder. This example material uses the ''&amp;quot;default_ambient&amp;quot;'' 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]].&lt;br /&gt;
&lt;br /&gt;
Obviously you would want to use the actual name of your map instead of &amp;quot;mapname&amp;quot;, for consistency's sake and ease of reference.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Assigning the material ===&lt;br /&gt;
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).&lt;br /&gt;
Tips on this process can be found in the [[A Simple First Terrain|simple first terrain tutorial]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Creating the Surface Tree =&lt;br /&gt;
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 &amp;quot;Save and Unload&amp;quot; button in the Terrain Editor.&lt;br /&gt;
[[Image:simplemega_terrainmodel.png|thumb|300px|Root node set up to use the correct terrain mesh]]&lt;br /&gt;
&lt;br /&gt;
=== Add the terrain mesh ===&lt;br /&gt;
Here's how you bring the terrain mesh into the surface tree:&lt;br /&gt;
* {{accelbtn|RMB}} on the left-hand pane, and choose ''New -&amp;gt; Tree'' via the menu.&lt;br /&gt;
** If you already have a Root node, click the &amp;quot;Begin Editing&amp;quot; button instead.&lt;br /&gt;
* Click on the Root node, and set {{keyname|Model}} to the name of the terrain mesh, in this case {{keyvalue|models/terrain/simpleterrain.obj}}.&lt;br /&gt;
* Press {{accelkey|enter}} to confirm the selection, and the terrain should appear in the 3D view.&lt;br /&gt;
&lt;br /&gt;
Be aware that your terrain model will probably appear bright orange or red.&lt;br /&gt;
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!&lt;br /&gt;
&lt;br /&gt;
=== Important note about nodes ===&lt;br /&gt;
When you are editing properties of nodes (names, numbers, texture sources etc.) always remember to hit {{accelkey|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 {{accelkey|enter}}, your changes may not be applied.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Create the first texture node ==&lt;br /&gt;
[[Image:simplemega_firstnode_diffuse.png|thumb|300px|The first texture node's diffuse texture properties]]&lt;br /&gt;
Now that the model is in place, you can start laying down the texture layers (or &amp;quot;nodes&amp;quot;) that will make up your MegaTexture.&lt;br /&gt;
&lt;br /&gt;
First you need to create a new Image Source node in the Terrain Editor.&lt;br /&gt;
* {{accelbtn|RMB}} on your &amp;quot;Root&amp;quot; node and choose ''New -&amp;gt; Image Source'' (or press {{accelkey|shift}}{{accelkey|i}})&lt;br /&gt;
* This will make a new node called &amp;quot;New Image Renderer&amp;quot;.&lt;br /&gt;
* You can rename this new node using the &amp;quot;Name&amp;quot; property field in the '''Object''' section.&lt;br /&gt;
* Rename the node &amp;quot;Dirt&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You will notice in the top right of the Terrain Editor, a section listing things like &amp;quot;Diffuse&amp;quot;, &amp;quot;Distribution&amp;quot;, &amp;quot;Distribution Pattern&amp;quot; etc. Selecting one of these will list all of the properties for that section of the current node.&lt;br /&gt;
The ones we need to worry about are as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Diffuse'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
This is the colour map of the current node, and it should point to a tiling TGA texture.&lt;br /&gt;
* Make sure the Diffuse section is highlighted in the top right of the Terrain Editor.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to a generic tiling dirt texture. Remember to hit {{accelkey|enter}} afterwards!&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/dirt_02_d.tga}}&lt;br /&gt;
* The {{keyname|Scale}} field at the very bottom of the property list allows you to choose how much to tile the texture.&lt;br /&gt;
** 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!&lt;br /&gt;
** 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.&lt;br /&gt;
That's all you need to do for the Diffuse settings in this node.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Distribution'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
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''.&lt;br /&gt;
* Make sure the Distribution section is highlighted in the top right.&lt;br /&gt;
* Since this is our first node, we want to show over the whole terrain. This means the distribution map should be 100% white.&lt;br /&gt;
* You can either assign a pure white TGA texture, or change the {{keyname|Source Type}} to {{keyvalue|geometryBased}}.&lt;br /&gt;
** {{keyvalue|geometryBased}} will by default create a fully white map, so if you don't have a white TGA handy, this is faster.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Distribution Pattern'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
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.&lt;br /&gt;
* 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!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Local'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
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.&lt;br /&gt;
* Make sure the Local section is highlighted in the top right.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching normal map for your tiling dirt texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/dirt_02_local.tga}}&lt;br /&gt;
* The Local texture's tiling amount is automatically the same as the Diffuse texture.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Surface Type'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
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.&lt;br /&gt;
* Find the ''Surface Type Properties'' section of the property list.&lt;br /&gt;
* 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.&lt;br /&gt;
* Hit {{accelkey|enter}} to accept the surface type.&lt;br /&gt;
&lt;br /&gt;
Your dirt textures will now produce correct &amp;quot;dirt&amp;quot; effects when shot or collided with!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Previewing the result'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
[[Image:simplemega_firstnode_preview.jpg|thumb|300px|The Render mode preview of the first node]]&lt;br /&gt;
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]]&lt;br /&gt;
&lt;br /&gt;
* Notice the drop-down arrow on the right of the button. Click it, and select ''&amp;quot;Full&amp;quot;'' instead of ''&amp;quot;None&amp;quot;''.&lt;br /&gt;
* Your terrain should change colour to black. This means it's ready for a preview to be rendered onto it.&lt;br /&gt;
* Click the button itself now, instead of the drop-down. An &amp;quot;Active Tasks&amp;quot; window should pop up, and when it's done, you should see your dirt texture appear on your terrain model.&lt;br /&gt;
* You can switch the camera to Render mode too, which will show your terrain model's shading better.&lt;br /&gt;
* If you want a full-resolution preview of a small area, choose ''&amp;quot;Window&amp;quot;'' instead of ''&amp;quot;Full&amp;quot;'' from the drop-down menu.&lt;br /&gt;
** 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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
'''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.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
== Adding a second node ==&lt;br /&gt;
Now that the first layer of dirt is in place, we can try putting some grass on top of it!&lt;br /&gt;
* Again, {{accelbtn|RMB}} on your &amp;quot;Root&amp;quot; node and choose ''New -&amp;gt; Image Source'' (or press {{accelkey|shift}}{{accelkey|i}})&lt;br /&gt;
* This will make another new node below your &amp;quot;Dirt&amp;quot; node. &lt;br /&gt;
* Name this new node &amp;quot;Grass&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Again, the main map types need to be specified before the node can be rendered:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Diffuse'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
* Make sure the Diffuse section is highlighted in the top right of the Terrain Editor.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to a generic tiling grass texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/grass_04_d.tga}}&lt;br /&gt;
* 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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Distribution'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
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!&lt;br /&gt;
* Make sure the Distribution section is highlighted in the top right.&lt;br /&gt;
* Change the {{keyname|Source Type}} from {{keyvalue|texture}} to {{keyvalue|geometryBased}}.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Geometric Texture Distribution'''&lt;br /&gt;
----&lt;br /&gt;
[[Image:simplemega_geometric_distribution.png|thumb|300px|The geometric texture distribution settings of the second node]]&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
* ''Altitude Lower'' - Enabling this will limit the lower parts of the terrain from receiving this node's textures.&lt;br /&gt;
** {{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.&lt;br /&gt;
** {{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.&lt;br /&gt;
* ''Altitude Upper'' - Enabling this will limit the higher parts of the terrain from receiving this node's textures.&lt;br /&gt;
** {{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.&lt;br /&gt;
** {{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.&lt;br /&gt;
&lt;br /&gt;
* {{keyname|Clamp Distribution To Edge}} - Leave this on Default.&lt;br /&gt;
&lt;br /&gt;
* {{keyname|Resolution}} - The size in pixels of the resulting mask. The default value of {{keyvalue|256}} is fine for nearly any terrain model.&lt;br /&gt;
&lt;br /&gt;
* ''Slope Lower'' - Enabling this will limit shallower angles of the terrain model from receiving this node's textures.&lt;br /&gt;
** {{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.&lt;br /&gt;
** {{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.&lt;br /&gt;
* ''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.&lt;br /&gt;
** {{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.&lt;br /&gt;
** {{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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Distribution Pattern'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
[[Image:simplemega_dist_ramps.jpg|thumb|300px|The difference between using or not using a Distribution Pattern, and varying Ramp Widths]]&lt;br /&gt;
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!&lt;br /&gt;
So what we want here is a texture to identify the &amp;quot;height&amp;quot; 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.&lt;br /&gt;
&lt;br /&gt;
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!&lt;br /&gt;
&lt;br /&gt;
* Make sure {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching heightmap or mask for your tiling grass texture.&lt;br /&gt;
** This example is using {{filename|textures/megagen/temperate/grass_04_mask.tga}}&lt;br /&gt;
* 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 &amp;quot;Window&amp;quot; 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.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Local'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
Again we want the normal-map which matches the diffuse texture for the grass.&lt;br /&gt;
* Make sure the Local section is highlighted in the top right.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching normal map for your tiling grass texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/grass_04_local.tga}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Surface Type'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
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.&lt;br /&gt;
* Find the ''Surface Type Properties'' section of the property list.&lt;br /&gt;
* 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.&lt;br /&gt;
* Hit {{accelkey|enter}} to accept the surface type.&lt;br /&gt;
&lt;br /&gt;
Your grass textures should now produce correct &amp;quot;grass&amp;quot; effects when shot or collided with!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Preview again!'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
[[Image:simplemega_secondnode_preview.jpg|thumb|300px|The Render mode preview of the second node blended with the first node]]&lt;br /&gt;
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.&lt;br /&gt;
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.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
== Adding a third node ==&lt;br /&gt;
[[Image:simplemega_thirdnode_preview.jpg|thumb|300px|The Render mode preview of the third node blended with the other two nodes]]&lt;br /&gt;
Now that the grass and dirt are in place, we need some rocks to make the terrain look more natural.&lt;br /&gt;
* Add a new Image Renderer node below your &amp;quot;Grass&amp;quot; node and name it &amp;quot;Rock&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Again, the main map types need to be specified before the node can be rendered:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Diffuse'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
* Set the '''Diffuse''' texture and scale.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/rock_01_d.tga}} at a scale of {{keyvalue|32 32}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Distribution'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
Again we can use Geometric Texture Distribution to easily apply the rock textures only to the cliff-like angles.&lt;br /&gt;
* Make sure the Distribution section is highlighted in the top right.&lt;br /&gt;
* Change the {{keyname|Source Type}} to {{keyvalue|geometryBased}}.&lt;br /&gt;
* 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}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Distribution Pattern'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
Again this will control how the the rocks blend into the other nodes. Again, we want a texture to identify the &amp;quot;height&amp;quot; of the tiling rock texture.&lt;br /&gt;
&lt;br /&gt;
* Make sure the Distribution Pattern section is highlighted in the top right.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching heightmap or mask for your tiling rock texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/rock_01_h.tga}}&lt;br /&gt;
* 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 &amp;quot;Window&amp;quot; preview to see how the blending looks.&lt;br /&gt;
* Remember to set the {{keyname|Distribution Pattern Texture Scale}} to the same value as the Diffuse Scale, {{keyvalue|32 32}}.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Local'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
Again we want the normal-map which matches the diffuse texture for the rocks.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Local''' section, browse to the matching normal map for your tiling rock texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/rock_01_local.tga}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Surface Type'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
* Find the {{keyname|Surface Type Properties}} section of the property list.&lt;br /&gt;
* In the {{keyname|Type}} field, enter {{keyvalue|stone}}.&lt;br /&gt;
* Hit {{accelkey|enter}} to accept the surface type.&lt;br /&gt;
&lt;br /&gt;
Your rock textures should now produce correct &amp;quot;stone&amp;quot; effects when shot or collided with.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Preview again!'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Further tweaks ==&lt;br /&gt;
There are other simple changes that can be done in the Terrain Editor to make your MegaTexture look even better.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Node order'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
[[Image:simplemega_node_order.png|frame|Click and drag a node to change the order]]&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
* {{accelbtn|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.&lt;br /&gt;
* Release {{accelbtn|LMB}} when you have positioned the node in the correct place.&lt;br /&gt;
* 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!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Color changes'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
Maybe your dirt texture is too bright? Or maybe your grass looks a little ''too'' green?&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Let's say you want to make the dirt texture darker and a bit more red. Here's how you'd do it:&lt;br /&gt;
* Select your Dirt node.&lt;br /&gt;
* 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).&lt;br /&gt;
* A color wheel and brightness slider will pop up in a new window. You can use this to darken and tint your texture.&lt;br /&gt;
* Choose a darker brightness, and a color slightly towards red. I used '''RGB Values''' of 225, 220, 220.&lt;br /&gt;
* Hit ''OK'' to accept the color.&lt;br /&gt;
* Re-render your MegaTexture preview. You should notice that the dirt layer looks darker now!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Texture rotation'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
An easy way to overcome this is to play with the {{keyvname|Rotation}} value in the Texture Properties section of the Terrain Editor's property list.&lt;br /&gt;
For each node, you should also set the {{keyvname|Distribution Pattern Texture Rotation}} to match the Rotation value if you want your distribution patterns to line up and work correctly.&lt;br /&gt;
&lt;br /&gt;
= Render the MegaTexture =&lt;br /&gt;
=== Save the Surface Tree ===&lt;br /&gt;
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 &amp;quot;Save and Unload&amp;quot; button in the Terrain Editor, or save the whole map.&lt;br /&gt;
&lt;br /&gt;
=== Compile Only Entities ===&lt;br /&gt;
At this stage, your MegaTexture material is still technically &amp;quot;broken&amp;quot;, 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.&lt;br /&gt;
&lt;br /&gt;
However, we need to compile the map in order to tell the [[renderLight]] process which atmosphere to use when lighting the MegaTexture!&lt;br /&gt;
&lt;br /&gt;
So the solution is to do an '''Only Entities''' compile. You can find this in the menu ''Compile -&amp;gt; 2 - Only Entities'' in editWorld. This should be done in a few seconds, and compiles all the information that renderLight needs.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Run the SDK Launcher ===&lt;br /&gt;
Now that your ''.sft'' is saved, go through all the steps outlined in the [[Generate a MegaTexture]] tutorial.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= That's it! =&lt;br /&gt;
[[Image:simplemega_ingame.jpg|thumb|300px|The MegaTexture in-game!]]&lt;br /&gt;
You've now created your very own MegaTexture to use in your map!&lt;br /&gt;
&lt;br /&gt;
Before you even compile the map, you can get an accurate preview of how it will look in-game by pressing {{accelkey|F6}} to toggle &amp;quot;anim&amp;quot; mode while in editWorld's &amp;quot;RENDER&amp;quot; Camera view (toggled with {{accelkey|F3}}).&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
= Troubleshooting =&lt;br /&gt;
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:&lt;br /&gt;
* 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.&lt;br /&gt;
* 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 ''&amp;lt; &amp;quot;mapname&amp;quot; &amp;gt;'' part described in [[A Simple First Megatexture#Creating a MegaTexture material|this section]]), otherwise it will not be searching for the correct images.&lt;br /&gt;
* 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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
= See Also =&lt;br /&gt;
* [[An Advanced Terrain and Megatexture]] - an advanced guide for complete MegaTexture creation&lt;br /&gt;
* [[Generate a MegaTexture]] - steps for generating a MegaTexture from the SDK launcher.&lt;br /&gt;
* [http://community.enemyterritory.com/forums/showthread.php?t=19326 Forum Thread] - includes textures to download&lt;br /&gt;
&lt;br /&gt;
[[Category:Art]]&lt;br /&gt;
[[Category:Basic Level Design]]&lt;br /&gt;
[[Category:Tutorials]]&lt;/div&gt;</summary>
		<author><name>Ducks</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.splashdamage.com/index.php?title=A_Simple_First_Megatexture&amp;diff=4042</id>
		<title>A Simple First Megatexture</title>
		<link rel="alternate" type="text/html" href="https://wiki.splashdamage.com/index.php?title=A_Simple_First_Megatexture&amp;diff=4042"/>
		<updated>2007-12-17T15:01:48Z</updated>

		<summary type="html">&lt;p&gt;Ducks: /* Adding a second node */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Image:simplemega_ingame.jpg|right|thumb|500px|A simple MegaTexture, easily created with only 3 texture layers!]]&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
= Introduction =&lt;br /&gt;
'''For this tutorial you must:'''&lt;br /&gt;
* Have a terrain model UV-mapped in the 0-1 range (covered in the simple first terrain tutorial)&lt;br /&gt;
* Have access to some tiling textures.&lt;br /&gt;
* Have a little understanding the ETQW material system&lt;br /&gt;
&lt;br /&gt;
If you don't have any of the above things, you are not ready to do this tutorial!&lt;br /&gt;
&lt;br /&gt;
'''This tutorial covers:'''&lt;br /&gt;
* How to set up a MegaTexture material&lt;br /&gt;
* How to create a Surface Tree&lt;br /&gt;
* How to add texture nodes in the Terrain Editor&lt;br /&gt;
* How to render and compile a full MegaTexture&lt;br /&gt;
&lt;br /&gt;
'''This tutorial does not cover:'''&lt;br /&gt;
* How to use Blender/Maya/Lightwave/ZBrush/Mudbox/3DSMax/Photoshop&lt;br /&gt;
* How to create tiling textures or heightmaps&lt;br /&gt;
* Anything overly complicated&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Creating a MegaTexture material =&lt;br /&gt;
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:&lt;br /&gt;
 material megatextures/mapname		{ useTemplate megatextures/default_ambient&amp;lt; &amp;quot;mapname&amp;quot; &amp;gt; }&lt;br /&gt;
&lt;br /&gt;
This material would automatically search for a MegaTexture called {{filename|mapname.mega}} in the {{filename|/megatextures/}} folder. This example material uses the ''&amp;quot;default_ambient&amp;quot;'' 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]].&lt;br /&gt;
&lt;br /&gt;
Obviously you would want to use the actual name of your map instead of &amp;quot;mapname&amp;quot;, for consistency's sake and ease of reference.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Assigning the material ===&lt;br /&gt;
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).&lt;br /&gt;
Tips on this process can be found in the [[A Simple First Terrain|simple first terrain tutorial]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Creating the Surface Tree =&lt;br /&gt;
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 &amp;quot;Save and Unload&amp;quot; button in the Terrain Editor.&lt;br /&gt;
[[Image:simplemega_terrainmodel.png|thumb|300px|Root node set up to use the correct terrain mesh]]&lt;br /&gt;
&lt;br /&gt;
=== Add the terrain mesh ===&lt;br /&gt;
Here's how you bring the terrain mesh into the surface tree:&lt;br /&gt;
* {{accelbtn|RMB}} on the left-hand pane, and choose ''New -&amp;gt; Tree'' via the menu.&lt;br /&gt;
** If you already have a Root node, click the &amp;quot;Begin Editing&amp;quot; button instead.&lt;br /&gt;
* Click on the Root node, and set {{keyname|Model}} to the name of the terrain mesh, in this case {{keyvalue|models/terrain/simpleterrain.obj}}.&lt;br /&gt;
* Press {{accelkey|enter}} to confirm the selection, and the terrain should appear in the 3D view.&lt;br /&gt;
&lt;br /&gt;
Be aware that your terrain model will probably appear bright orange or red.&lt;br /&gt;
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!&lt;br /&gt;
&lt;br /&gt;
=== Important note about nodes ===&lt;br /&gt;
When you are editing properties of nodes (names, numbers, texture sources etc.) always remember to hit {{accelkey|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 {{accelkey|enter}}, your changes may not be applied.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Create the first texture node ==&lt;br /&gt;
[[Image:simplemega_firstnode_diffuse.png|thumb|300px|The first texture node's diffuse texture properties]]&lt;br /&gt;
Now that the model is in place, you can start laying down the texture layers (or &amp;quot;nodes&amp;quot;) that will make up your MegaTexture.&lt;br /&gt;
&lt;br /&gt;
First you need to create a new Image Source node in the Terrain Editor.&lt;br /&gt;
* {{accelbtn|RMB}} on your &amp;quot;Root&amp;quot; node and choose ''New -&amp;gt; Image Source'' (or press {{accelkey|shift}}{{accelkey|i}})&lt;br /&gt;
* This will make a new node called &amp;quot;New Image Renderer&amp;quot;.&lt;br /&gt;
* You can rename this new node using the &amp;quot;Name&amp;quot; property field in the '''Object''' section.&lt;br /&gt;
* Rename the node &amp;quot;Dirt&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You will notice in the top right of the Terrain Editor, a section listing things like &amp;quot;Diffuse&amp;quot;, &amp;quot;Distribution&amp;quot;, &amp;quot;Distribution Pattern&amp;quot; etc. Selecting one of these will list all of the properties for that section of the current node.&lt;br /&gt;
The ones we need to worry about are as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Diffuse'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
This is the colour map of the current node, and it should point to a tiling TGA texture.&lt;br /&gt;
* Make sure the Diffuse section is highlighted in the top right of the Terrain Editor.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to a generic tiling dirt texture. Remember to hit {{accelkey|enter}} afterwards!&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/dirt_02_d.tga}}&lt;br /&gt;
* The {{keyname|Scale}} field at the very bottom of the property list allows you to choose how much to tile the texture.&lt;br /&gt;
** 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!&lt;br /&gt;
** 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.&lt;br /&gt;
That's all you need to do for the Diffuse settings in this node.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Distribution'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
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''.&lt;br /&gt;
* Make sure the Distribution section is highlighted in the top right.&lt;br /&gt;
* Since this is our first node, we want to show over the whole terrain. This means the distribution map should be 100% white.&lt;br /&gt;
* You can either assign a pure white TGA texture, or change the {{keyname|Source Type}} to {{keyvalue|geometryBased}}.&lt;br /&gt;
** {{keyvalue|geometryBased}} will by default create a fully white map, so if you don't have a white TGA handy, this is faster.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Distribution Pattern'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
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.&lt;br /&gt;
* 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!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Local'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
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.&lt;br /&gt;
* Make sure the Local section is highlighted in the top right.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching normal map for your tiling dirt texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/dirt_02_local.tga}}&lt;br /&gt;
* The Local texture's tiling amount is automatically the same as the Diffuse texture.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Surface Type'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
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.&lt;br /&gt;
* Find the ''Surface Type Properties'' section of the property list.&lt;br /&gt;
* 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.&lt;br /&gt;
* Hit {{accelkey|enter}} to accept the surface type.&lt;br /&gt;
&lt;br /&gt;
Your dirt textures will now produce correct &amp;quot;dirt&amp;quot; effects when shot or collided with!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Previewing the result'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
[[Image:simplemega_firstnode_preview.jpg|thumb|300px|The Render mode preview of the first node]]&lt;br /&gt;
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]]&lt;br /&gt;
&lt;br /&gt;
* Notice the drop-down arrow on the right of the button. Click it, and select ''&amp;quot;Full&amp;quot;'' instead of ''&amp;quot;None&amp;quot;''.&lt;br /&gt;
* Your terrain should change colour to black. This means it's ready for a preview to be rendered onto it.&lt;br /&gt;
* Click the button itself now, instead of the drop-down. An &amp;quot;Active Tasks&amp;quot; window should pop up, and when it's done, you should see your dirt texture appear on your terrain model.&lt;br /&gt;
* You can switch the camera to Render mode too, which will show your terrain model's shading better.&lt;br /&gt;
* If you want a full-resolution preview of a small area, choose ''&amp;quot;Window&amp;quot;'' instead of ''&amp;quot;Full&amp;quot;'' from the drop-down menu.&lt;br /&gt;
** 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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
'''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.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
== Adding a second node ==&lt;br /&gt;
Now that the first layer of dirt is in place, we can try putting some grass on top of it!&lt;br /&gt;
* Again, {{accelbtn|RMB}} on your &amp;quot;Root&amp;quot; node and choose ''New -&amp;gt; Image Source'' (or press {{accelkey|shift}}{{accelkey|i}})&lt;br /&gt;
* This will make another new node below your &amp;quot;Dirt&amp;quot; node. &lt;br /&gt;
* Name this new node &amp;quot;Grass&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Again, the main map types need to be specified before the node can be rendered:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Diffuse'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
* Make sure the Diffuse section is highlighted in the top right of the Terrain Editor.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to a generic tiling grass texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/grass_04_d.tga}}&lt;br /&gt;
* 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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Distribution'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
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!&lt;br /&gt;
* Make sure the Distribution section is highlighted in the top right.&lt;br /&gt;
* Change the {{keyname|Source Type}} from {{keyvalue|texture}} to {{keyvalue|geometryBased}}.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Geometric Texture Distribution'''&lt;br /&gt;
----&lt;br /&gt;
[[Image:simplemega_geometric_distribution.png|thumb|300px|The geometric texture distribution settings of the second node]]&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
* ''keyname|Altitude Lower'' - Enabling this will limit the lower parts of the terrain from receiving this node's textures.&lt;br /&gt;
** {{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.&lt;br /&gt;
** {{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.&lt;br /&gt;
* ''keyname|Altitude Upper'' - Enabling this will limit the higher parts of the terrain from receiving this node's textures.&lt;br /&gt;
** {{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.&lt;br /&gt;
** {{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.&lt;br /&gt;
&lt;br /&gt;
* {{keyname|Clamp Distribution To Edge}} - Leave this on Default.&lt;br /&gt;
&lt;br /&gt;
* {{keyname|Resolution}} - The size in pixels of the resulting mask. The default value of {{keyvalue|256}} is fine for nearly any terrain model.&lt;br /&gt;
&lt;br /&gt;
* ''keyname|Slope Lower'' - Enabling this will limit shallower angles of the terrain model from receiving this node's textures.&lt;br /&gt;
** {{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.&lt;br /&gt;
** {{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.&lt;br /&gt;
* ''keyname|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.&lt;br /&gt;
** {{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.&lt;br /&gt;
** {{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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Distribution Pattern'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
[[Image:simplemega_dist_ramps.jpg|thumb|300px|The difference between using or not using a Distribution Pattern, and varying Ramp Widths]]&lt;br /&gt;
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!&lt;br /&gt;
So what we want here is a texture to identify the &amp;quot;height&amp;quot; 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.&lt;br /&gt;
&lt;br /&gt;
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!&lt;br /&gt;
&lt;br /&gt;
* Make sure {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching heightmap or mask for your tiling grass texture.&lt;br /&gt;
** This example is using {{filename|textures/megagen/temperate/grass_04_mask.tga}}&lt;br /&gt;
* 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 &amp;quot;Window&amp;quot; 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.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Local'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
Again we want the normal-map which matches the diffuse texture for the grass.&lt;br /&gt;
* Make sure the Local section is highlighted in the top right.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching normal map for your tiling grass texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/grass_04_local.tga}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Surface Type'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
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.&lt;br /&gt;
* Find the ''Surface Type Properties'' section of the property list.&lt;br /&gt;
* 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.&lt;br /&gt;
* Hit {{accelkey|enter}} to accept the surface type.&lt;br /&gt;
&lt;br /&gt;
Your grass textures should now produce correct &amp;quot;grass&amp;quot; effects when shot or collided with!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Preview again!'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
[[Image:simplemega_secondnode_preview.jpg|thumb|300px|The Render mode preview of the second node blended with the first node]]&lt;br /&gt;
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.&lt;br /&gt;
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.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
== Adding a third node ==&lt;br /&gt;
[[Image:simplemega_thirdnode_preview.jpg|thumb|300px|The Render mode preview of the third node blended with the other two nodes]]&lt;br /&gt;
Now that the grass and dirt are in place, we need some rocks to make the terrain look more natural.&lt;br /&gt;
* Add a new Image Renderer node below your &amp;quot;Grass&amp;quot; node and name it &amp;quot;Rock&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Again, the main map types need to be specified before the node can be rendered:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Diffuse'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
* Set the '''Diffuse''' texture and scale.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/rock_01_d.tga}} at a scale of {{keyvalue|32 32}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Distribution'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
Again we can use Geometric Texture Distribution to easily apply the rock textures only to the cliff-like angles.&lt;br /&gt;
* Make sure the Distribution section is highlighted in the top right.&lt;br /&gt;
* Change the {{keyname|Source Type}} to {{keyvalue|geometryBased}}.&lt;br /&gt;
* 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}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Distribution Pattern'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
Again this will control how the the rocks blend into the other nodes. Again, we want a texture to identify the &amp;quot;height&amp;quot; of the tiling rock texture.&lt;br /&gt;
&lt;br /&gt;
* Make sure the Distribution Pattern section is highlighted in the top right.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching heightmap or mask for your tiling rock texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/rock_01_h.tga}}&lt;br /&gt;
* 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 &amp;quot;Window&amp;quot; preview to see how the blending looks.&lt;br /&gt;
* Remember to set the {{keyname|Distribution Pattern Texture Scale}} to the same value as the Diffuse Scale, {{keyvalue|32 32}}.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Local'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
Again we want the normal-map which matches the diffuse texture for the rocks.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Local''' section, browse to the matching normal map for your tiling rock texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/rock_01_local.tga}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Surface Type'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
* Find the {{keyname|Surface Type Properties}} section of the property list.&lt;br /&gt;
* In the {{keyname|Type}} field, enter {{keyvalue|stone}}.&lt;br /&gt;
* Hit {{accelkey|enter}} to accept the surface type.&lt;br /&gt;
&lt;br /&gt;
Your rock textures should now produce correct &amp;quot;stone&amp;quot; effects when shot or collided with.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Preview again!'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Further tweaks ==&lt;br /&gt;
There are other simple changes that can be done in the Terrain Editor to make your MegaTexture look even better.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Node order'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
[[Image:simplemega_node_order.png|frame|Click and drag a node to change the order]]&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
* {{accelbtn|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.&lt;br /&gt;
* Release {{accelbtn|LMB}} when you have positioned the node in the correct place.&lt;br /&gt;
* 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!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Color changes'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
Maybe your dirt texture is too bright? Or maybe your grass looks a little ''too'' green?&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Let's say you want to make the dirt texture darker and a bit more red. Here's how you'd do it:&lt;br /&gt;
* Select your Dirt node.&lt;br /&gt;
* 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).&lt;br /&gt;
* A color wheel and brightness slider will pop up in a new window. You can use this to darken and tint your texture.&lt;br /&gt;
* Choose a darker brightness, and a color slightly towards red. I used '''RGB Values''' of 225, 220, 220.&lt;br /&gt;
* Hit ''OK'' to accept the color.&lt;br /&gt;
* Re-render your MegaTexture preview. You should notice that the dirt layer looks darker now!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Texture rotation'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
An easy way to overcome this is to play with the {{keyvname|Rotation}} value in the Texture Properties section of the Terrain Editor's property list.&lt;br /&gt;
For each node, you should also set the {{keyvname|Distribution Pattern Texture Rotation}} to match the Rotation value if you want your distribution patterns to line up and work correctly.&lt;br /&gt;
&lt;br /&gt;
= Render the MegaTexture =&lt;br /&gt;
=== Save the Surface Tree ===&lt;br /&gt;
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 &amp;quot;Save and Unload&amp;quot; button in the Terrain Editor, or save the whole map.&lt;br /&gt;
&lt;br /&gt;
=== Compile Only Entities ===&lt;br /&gt;
At this stage, your MegaTexture material is still technically &amp;quot;broken&amp;quot;, 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.&lt;br /&gt;
&lt;br /&gt;
However, we need to compile the map in order to tell the [[renderLight]] process which atmosphere to use when lighting the MegaTexture!&lt;br /&gt;
&lt;br /&gt;
So the solution is to do an '''Only Entities''' compile. You can find this in the menu ''Compile -&amp;gt; 2 - Only Entities'' in editWorld. This should be done in a few seconds, and compiles all the information that renderLight needs.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Run the SDK Launcher ===&lt;br /&gt;
Now that your ''.sft'' is saved, go through all the steps outlined in the [[Generate a MegaTexture]] tutorial.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= That's it! =&lt;br /&gt;
[[Image:simplemega_ingame.jpg|thumb|300px|The MegaTexture in-game!]]&lt;br /&gt;
You've now created your very own MegaTexture to use in your map!&lt;br /&gt;
&lt;br /&gt;
Before you even compile the map, you can get an accurate preview of how it will look in-game by pressing {{accelkey|F6}} to toggle &amp;quot;anim&amp;quot; mode while in editWorld's &amp;quot;RENDER&amp;quot; Camera view (toggled with {{accelkey|F3}}).&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
= Troubleshooting =&lt;br /&gt;
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:&lt;br /&gt;
* 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.&lt;br /&gt;
* 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 ''&amp;lt; &amp;quot;mapname&amp;quot; &amp;gt;'' part described in [[A Simple First Megatexture#Creating a MegaTexture material|this section]]), otherwise it will not be searching for the correct images.&lt;br /&gt;
* 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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
= See Also =&lt;br /&gt;
* [[An Advanced Terrain and Megatexture]] - an advanced guide for complete MegaTexture creation&lt;br /&gt;
* [[Generate a MegaTexture]] - steps for generating a MegaTexture from the SDK launcher.&lt;br /&gt;
* [http://community.enemyterritory.com/forums/showthread.php?t=19326 Forum Thread] - includes textures to download&lt;br /&gt;
&lt;br /&gt;
[[Category:Art]]&lt;br /&gt;
[[Category:Basic Level Design]]&lt;br /&gt;
[[Category:Tutorials]]&lt;/div&gt;</summary>
		<author><name>Ducks</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.splashdamage.com/index.php?title=A_Simple_First_Megatexture&amp;diff=4041</id>
		<title>A Simple First Megatexture</title>
		<link rel="alternate" type="text/html" href="https://wiki.splashdamage.com/index.php?title=A_Simple_First_Megatexture&amp;diff=4041"/>
		<updated>2007-12-17T14:56:43Z</updated>

		<summary type="html">&lt;p&gt;Ducks: /* Troubleshooting */ - capitalised console command for clearer meaning&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Image:simplemega_ingame.jpg|right|thumb|500px|A simple MegaTexture, easily created with only 3 texture layers!]]&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
= Introduction =&lt;br /&gt;
'''For this tutorial you must:'''&lt;br /&gt;
* Have a terrain model UV-mapped in the 0-1 range (covered in the simple first terrain tutorial)&lt;br /&gt;
* Have access to some tiling textures.&lt;br /&gt;
* Have a little understanding the ETQW material system&lt;br /&gt;
&lt;br /&gt;
If you don't have any of the above things, you are not ready to do this tutorial!&lt;br /&gt;
&lt;br /&gt;
'''This tutorial covers:'''&lt;br /&gt;
* How to set up a MegaTexture material&lt;br /&gt;
* How to create a Surface Tree&lt;br /&gt;
* How to add texture nodes in the Terrain Editor&lt;br /&gt;
* How to render and compile a full MegaTexture&lt;br /&gt;
&lt;br /&gt;
'''This tutorial does not cover:'''&lt;br /&gt;
* How to use Blender/Maya/Lightwave/ZBrush/Mudbox/3DSMax/Photoshop&lt;br /&gt;
* How to create tiling textures or heightmaps&lt;br /&gt;
* Anything overly complicated&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Creating a MegaTexture material =&lt;br /&gt;
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:&lt;br /&gt;
 material megatextures/mapname		{ useTemplate megatextures/default_ambient&amp;lt; &amp;quot;mapname&amp;quot; &amp;gt; }&lt;br /&gt;
&lt;br /&gt;
This material would automatically search for a MegaTexture called {{filename|mapname.mega}} in the {{filename|/megatextures/}} folder. This example material uses the ''&amp;quot;default_ambient&amp;quot;'' 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]].&lt;br /&gt;
&lt;br /&gt;
Obviously you would want to use the actual name of your map instead of &amp;quot;mapname&amp;quot;, for consistency's sake and ease of reference.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Assigning the material ===&lt;br /&gt;
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).&lt;br /&gt;
Tips on this process can be found in the [[A Simple First Terrain|simple first terrain tutorial]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Creating the Surface Tree =&lt;br /&gt;
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 &amp;quot;Save and Unload&amp;quot; button in the Terrain Editor.&lt;br /&gt;
[[Image:simplemega_terrainmodel.png|thumb|300px|Root node set up to use the correct terrain mesh]]&lt;br /&gt;
&lt;br /&gt;
=== Add the terrain mesh ===&lt;br /&gt;
Here's how you bring the terrain mesh into the surface tree:&lt;br /&gt;
* {{accelbtn|RMB}} on the left-hand pane, and choose ''New -&amp;gt; Tree'' via the menu.&lt;br /&gt;
** If you already have a Root node, click the &amp;quot;Begin Editing&amp;quot; button instead.&lt;br /&gt;
* Click on the Root node, and set {{keyname|Model}} to the name of the terrain mesh, in this case {{keyvalue|models/terrain/simpleterrain.obj}}.&lt;br /&gt;
* Press {{accelkey|enter}} to confirm the selection, and the terrain should appear in the 3D view.&lt;br /&gt;
&lt;br /&gt;
Be aware that your terrain model will probably appear bright orange or red.&lt;br /&gt;
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!&lt;br /&gt;
&lt;br /&gt;
=== Important note about nodes ===&lt;br /&gt;
When you are editing properties of nodes (names, numbers, texture sources etc.) always remember to hit {{accelkey|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 {{accelkey|enter}}, your changes may not be applied.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Create the first texture node ==&lt;br /&gt;
[[Image:simplemega_firstnode_diffuse.png|thumb|300px|The first texture node's diffuse texture properties]]&lt;br /&gt;
Now that the model is in place, you can start laying down the texture layers (or &amp;quot;nodes&amp;quot;) that will make up your MegaTexture.&lt;br /&gt;
&lt;br /&gt;
First you need to create a new Image Source node in the Terrain Editor.&lt;br /&gt;
* {{accelbtn|RMB}} on your &amp;quot;Root&amp;quot; node and choose ''New -&amp;gt; Image Source'' (or press {{accelkey|shift}}{{accelkey|i}})&lt;br /&gt;
* This will make a new node called &amp;quot;New Image Renderer&amp;quot;.&lt;br /&gt;
* You can rename this new node using the &amp;quot;Name&amp;quot; property field in the '''Object''' section.&lt;br /&gt;
* Rename the node &amp;quot;Dirt&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You will notice in the top right of the Terrain Editor, a section listing things like &amp;quot;Diffuse&amp;quot;, &amp;quot;Distribution&amp;quot;, &amp;quot;Distribution Pattern&amp;quot; etc. Selecting one of these will list all of the properties for that section of the current node.&lt;br /&gt;
The ones we need to worry about are as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Diffuse'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
This is the colour map of the current node, and it should point to a tiling TGA texture.&lt;br /&gt;
* Make sure the Diffuse section is highlighted in the top right of the Terrain Editor.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to a generic tiling dirt texture. Remember to hit {{accelkey|enter}} afterwards!&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/dirt_02_d.tga}}&lt;br /&gt;
* The {{keyname|Scale}} field at the very bottom of the property list allows you to choose how much to tile the texture.&lt;br /&gt;
** 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!&lt;br /&gt;
** 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.&lt;br /&gt;
That's all you need to do for the Diffuse settings in this node.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Distribution'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
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''.&lt;br /&gt;
* Make sure the Distribution section is highlighted in the top right.&lt;br /&gt;
* Since this is our first node, we want to show over the whole terrain. This means the distribution map should be 100% white.&lt;br /&gt;
* You can either assign a pure white TGA texture, or change the {{keyname|Source Type}} to {{keyvalue|geometryBased}}.&lt;br /&gt;
** {{keyvalue|geometryBased}} will by default create a fully white map, so if you don't have a white TGA handy, this is faster.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Distribution Pattern'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
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.&lt;br /&gt;
* 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!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Local'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
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.&lt;br /&gt;
* Make sure the Local section is highlighted in the top right.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching normal map for your tiling dirt texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/dirt_02_local.tga}}&lt;br /&gt;
* The Local texture's tiling amount is automatically the same as the Diffuse texture.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Surface Type'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
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.&lt;br /&gt;
* Find the ''Surface Type Properties'' section of the property list.&lt;br /&gt;
* 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.&lt;br /&gt;
* Hit {{accelkey|enter}} to accept the surface type.&lt;br /&gt;
&lt;br /&gt;
Your dirt textures will now produce correct &amp;quot;dirt&amp;quot; effects when shot or collided with!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Previewing the result'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
[[Image:simplemega_firstnode_preview.jpg|thumb|300px|The Render mode preview of the first node]]&lt;br /&gt;
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]]&lt;br /&gt;
&lt;br /&gt;
* Notice the drop-down arrow on the right of the button. Click it, and select ''&amp;quot;Full&amp;quot;'' instead of ''&amp;quot;None&amp;quot;''.&lt;br /&gt;
* Your terrain should change colour to black. This means it's ready for a preview to be rendered onto it.&lt;br /&gt;
* Click the button itself now, instead of the drop-down. An &amp;quot;Active Tasks&amp;quot; window should pop up, and when it's done, you should see your dirt texture appear on your terrain model.&lt;br /&gt;
* You can switch the camera to Render mode too, which will show your terrain model's shading better.&lt;br /&gt;
* If you want a full-resolution preview of a small area, choose ''&amp;quot;Window&amp;quot;'' instead of ''&amp;quot;Full&amp;quot;'' from the drop-down menu.&lt;br /&gt;
** 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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
'''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.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
== Adding a second node ==&lt;br /&gt;
Now that the first layer of dirt is in place, we can try putting some grass on top of it!&lt;br /&gt;
* Again, {{accelbtn|RMB}} on your &amp;quot;Root&amp;quot; node and choose ''New -&amp;gt; Image Source'' (or press {{accelkey|shift}}{{accelkey|i}})&lt;br /&gt;
* This will make another new node below your &amp;quot;Dirt&amp;quot; node. &lt;br /&gt;
* Name this new node &amp;quot;Grass&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Again, the main map types need to be specified before the node can be rendered:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Diffuse'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
* Make sure the Diffuse section is highlighted in the top right of the Terrain Editor.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to a generic tiling grass texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/grass_04_d.tga}}&lt;br /&gt;
* 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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Distribution'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
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!&lt;br /&gt;
* Make sure the Distribution section is highlighted in the top right.&lt;br /&gt;
* Change the {{keyname|Source Type}} from {{keyvalue|texture}} to {{keyvalue|geometryBased}}.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Geometric Texture Distribution'''&lt;br /&gt;
----&lt;br /&gt;
[[Image:simplemega_geometric_distribution.png|thumb|300px|The geometric texture distribution settings of the second node]]&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
* {{keyname|Altitude Lower}} - Enabling this will limit the lower parts of the terrain from receiving this node's textures.&lt;br /&gt;
** {{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.&lt;br /&gt;
** {{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.&lt;br /&gt;
* {{keyname|Altitude Upper}} - Enabling this will limit the higher parts of the terrain from receiving this node's textures.&lt;br /&gt;
** {{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.&lt;br /&gt;
** {{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.&lt;br /&gt;
&lt;br /&gt;
* {{keyname|Clamp Distribution To Edge}} - Leave this on Default.&lt;br /&gt;
&lt;br /&gt;
* {{keyname|Resolution}} - The size in pixels of the resulting mask. The default value of {{keyvalue|256}} is fine for nearly any terrain model.&lt;br /&gt;
&lt;br /&gt;
* {{keyname|Slope Lower}} - Enabling this will limit shallower angles of the terrain model from receiving this node's textures.&lt;br /&gt;
** {{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.&lt;br /&gt;
** {{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.&lt;br /&gt;
* {{keyname|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.&lt;br /&gt;
** {{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.&lt;br /&gt;
** {{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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Distribution Pattern'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
[[Image:simplemega_dist_ramps.jpg|thumb|300px|The difference between using or not using a Distribution Pattern, and varying Ramp Widths]]&lt;br /&gt;
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!&lt;br /&gt;
So what we want here is a texture to identify the &amp;quot;height&amp;quot; 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.&lt;br /&gt;
&lt;br /&gt;
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!&lt;br /&gt;
&lt;br /&gt;
* Make sure {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching heightmap or mask for your tiling grass texture.&lt;br /&gt;
** This example is using {{filename|textures/megagen/temperate/grass_04_mask.tga}}&lt;br /&gt;
* 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 &amp;quot;Window&amp;quot; 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.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Local'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
Again we want the normal-map which matches the diffuse texture for the grass.&lt;br /&gt;
* Make sure the Local section is highlighted in the top right.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching normal map for your tiling grass texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/grass_04_local.tga}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Surface Type'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
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.&lt;br /&gt;
* Find the ''Surface Type Properties'' section of the property list.&lt;br /&gt;
* 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.&lt;br /&gt;
* Hit {{accelkey|enter}} to accept the surface type.&lt;br /&gt;
&lt;br /&gt;
Your grass textures should now produce correct &amp;quot;grass&amp;quot; effects when shot or collided with!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Preview again!'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
[[Image:simplemega_secondnode_preview.jpg|thumb|300px|The Render mode preview of the second node blended with the first node]]&lt;br /&gt;
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.&lt;br /&gt;
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.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
== Adding a third node ==&lt;br /&gt;
[[Image:simplemega_thirdnode_preview.jpg|thumb|300px|The Render mode preview of the third node blended with the other two nodes]]&lt;br /&gt;
Now that the grass and dirt are in place, we need some rocks to make the terrain look more natural.&lt;br /&gt;
* Add a new Image Renderer node below your &amp;quot;Grass&amp;quot; node and name it &amp;quot;Rock&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Again, the main map types need to be specified before the node can be rendered:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Diffuse'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
* Set the '''Diffuse''' texture and scale.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/rock_01_d.tga}} at a scale of {{keyvalue|32 32}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Distribution'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
Again we can use Geometric Texture Distribution to easily apply the rock textures only to the cliff-like angles.&lt;br /&gt;
* Make sure the Distribution section is highlighted in the top right.&lt;br /&gt;
* Change the {{keyname|Source Type}} to {{keyvalue|geometryBased}}.&lt;br /&gt;
* 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}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Distribution Pattern'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
Again this will control how the the rocks blend into the other nodes. Again, we want a texture to identify the &amp;quot;height&amp;quot; of the tiling rock texture.&lt;br /&gt;
&lt;br /&gt;
* Make sure the Distribution Pattern section is highlighted in the top right.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching heightmap or mask for your tiling rock texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/rock_01_h.tga}}&lt;br /&gt;
* 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 &amp;quot;Window&amp;quot; preview to see how the blending looks.&lt;br /&gt;
* Remember to set the {{keyname|Distribution Pattern Texture Scale}} to the same value as the Diffuse Scale, {{keyvalue|32 32}}.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Local'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
Again we want the normal-map which matches the diffuse texture for the rocks.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Local''' section, browse to the matching normal map for your tiling rock texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/rock_01_local.tga}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Surface Type'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
* Find the {{keyname|Surface Type Properties}} section of the property list.&lt;br /&gt;
* In the {{keyname|Type}} field, enter {{keyvalue|stone}}.&lt;br /&gt;
* Hit {{accelkey|enter}} to accept the surface type.&lt;br /&gt;
&lt;br /&gt;
Your rock textures should now produce correct &amp;quot;stone&amp;quot; effects when shot or collided with.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Preview again!'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Further tweaks ==&lt;br /&gt;
There are other simple changes that can be done in the Terrain Editor to make your MegaTexture look even better.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Node order'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
[[Image:simplemega_node_order.png|frame|Click and drag a node to change the order]]&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
* {{accelbtn|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.&lt;br /&gt;
* Release {{accelbtn|LMB}} when you have positioned the node in the correct place.&lt;br /&gt;
* 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!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Color changes'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
Maybe your dirt texture is too bright? Or maybe your grass looks a little ''too'' green?&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Let's say you want to make the dirt texture darker and a bit more red. Here's how you'd do it:&lt;br /&gt;
* Select your Dirt node.&lt;br /&gt;
* 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).&lt;br /&gt;
* A color wheel and brightness slider will pop up in a new window. You can use this to darken and tint your texture.&lt;br /&gt;
* Choose a darker brightness, and a color slightly towards red. I used '''RGB Values''' of 225, 220, 220.&lt;br /&gt;
* Hit ''OK'' to accept the color.&lt;br /&gt;
* Re-render your MegaTexture preview. You should notice that the dirt layer looks darker now!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Texture rotation'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
An easy way to overcome this is to play with the {{keyvname|Rotation}} value in the Texture Properties section of the Terrain Editor's property list.&lt;br /&gt;
For each node, you should also set the {{keyvname|Distribution Pattern Texture Rotation}} to match the Rotation value if you want your distribution patterns to line up and work correctly.&lt;br /&gt;
&lt;br /&gt;
= Render the MegaTexture =&lt;br /&gt;
=== Save the Surface Tree ===&lt;br /&gt;
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 &amp;quot;Save and Unload&amp;quot; button in the Terrain Editor, or save the whole map.&lt;br /&gt;
&lt;br /&gt;
=== Compile Only Entities ===&lt;br /&gt;
At this stage, your MegaTexture material is still technically &amp;quot;broken&amp;quot;, 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.&lt;br /&gt;
&lt;br /&gt;
However, we need to compile the map in order to tell the [[renderLight]] process which atmosphere to use when lighting the MegaTexture!&lt;br /&gt;
&lt;br /&gt;
So the solution is to do an '''Only Entities''' compile. You can find this in the menu ''Compile -&amp;gt; 2 - Only Entities'' in editWorld. This should be done in a few seconds, and compiles all the information that renderLight needs.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Run the SDK Launcher ===&lt;br /&gt;
Now that your ''.sft'' is saved, go through all the steps outlined in the [[Generate a MegaTexture]] tutorial.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= That's it! =&lt;br /&gt;
[[Image:simplemega_ingame.jpg|thumb|300px|The MegaTexture in-game!]]&lt;br /&gt;
You've now created your very own MegaTexture to use in your map!&lt;br /&gt;
&lt;br /&gt;
Before you even compile the map, you can get an accurate preview of how it will look in-game by pressing {{accelkey|F6}} to toggle &amp;quot;anim&amp;quot; mode while in editWorld's &amp;quot;RENDER&amp;quot; Camera view (toggled with {{accelkey|F3}}).&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
= Troubleshooting =&lt;br /&gt;
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:&lt;br /&gt;
* 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.&lt;br /&gt;
* 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 ''&amp;lt; &amp;quot;mapname&amp;quot; &amp;gt;'' part described in [[A Simple First Megatexture#Creating a MegaTexture material|this section]]), otherwise it will not be searching for the correct images.&lt;br /&gt;
* 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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
= See Also =&lt;br /&gt;
* [[An Advanced Terrain and Megatexture]] - an advanced guide for complete MegaTexture creation&lt;br /&gt;
* [[Generate a MegaTexture]] - steps for generating a MegaTexture from the SDK launcher.&lt;br /&gt;
* [http://community.enemyterritory.com/forums/showthread.php?t=19326 Forum Thread] - includes textures to download&lt;br /&gt;
&lt;br /&gt;
[[Category:Art]]&lt;br /&gt;
[[Category:Basic Level Design]]&lt;br /&gt;
[[Category:Tutorials]]&lt;/div&gt;</summary>
		<author><name>Ducks</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.splashdamage.com/index.php?title=A_Simple_First_Megatexture&amp;diff=4040</id>
		<title>A Simple First Megatexture</title>
		<link rel="alternate" type="text/html" href="https://wiki.splashdamage.com/index.php?title=A_Simple_First_Megatexture&amp;diff=4040"/>
		<updated>2007-12-17T14:55:11Z</updated>

		<summary type="html">&lt;p&gt;Ducks: /* Further tweaks */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Image:simplemega_ingame.jpg|right|thumb|500px|A simple MegaTexture, easily created with only 3 texture layers!]]&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
= Introduction =&lt;br /&gt;
'''For this tutorial you must:'''&lt;br /&gt;
* Have a terrain model UV-mapped in the 0-1 range (covered in the simple first terrain tutorial)&lt;br /&gt;
* Have access to some tiling textures.&lt;br /&gt;
* Have a little understanding the ETQW material system&lt;br /&gt;
&lt;br /&gt;
If you don't have any of the above things, you are not ready to do this tutorial!&lt;br /&gt;
&lt;br /&gt;
'''This tutorial covers:'''&lt;br /&gt;
* How to set up a MegaTexture material&lt;br /&gt;
* How to create a Surface Tree&lt;br /&gt;
* How to add texture nodes in the Terrain Editor&lt;br /&gt;
* How to render and compile a full MegaTexture&lt;br /&gt;
&lt;br /&gt;
'''This tutorial does not cover:'''&lt;br /&gt;
* How to use Blender/Maya/Lightwave/ZBrush/Mudbox/3DSMax/Photoshop&lt;br /&gt;
* How to create tiling textures or heightmaps&lt;br /&gt;
* Anything overly complicated&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Creating a MegaTexture material =&lt;br /&gt;
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:&lt;br /&gt;
 material megatextures/mapname		{ useTemplate megatextures/default_ambient&amp;lt; &amp;quot;mapname&amp;quot; &amp;gt; }&lt;br /&gt;
&lt;br /&gt;
This material would automatically search for a MegaTexture called {{filename|mapname.mega}} in the {{filename|/megatextures/}} folder. This example material uses the ''&amp;quot;default_ambient&amp;quot;'' 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]].&lt;br /&gt;
&lt;br /&gt;
Obviously you would want to use the actual name of your map instead of &amp;quot;mapname&amp;quot;, for consistency's sake and ease of reference.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Assigning the material ===&lt;br /&gt;
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).&lt;br /&gt;
Tips on this process can be found in the [[A Simple First Terrain|simple first terrain tutorial]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Creating the Surface Tree =&lt;br /&gt;
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 &amp;quot;Save and Unload&amp;quot; button in the Terrain Editor.&lt;br /&gt;
[[Image:simplemega_terrainmodel.png|thumb|300px|Root node set up to use the correct terrain mesh]]&lt;br /&gt;
&lt;br /&gt;
=== Add the terrain mesh ===&lt;br /&gt;
Here's how you bring the terrain mesh into the surface tree:&lt;br /&gt;
* {{accelbtn|RMB}} on the left-hand pane, and choose ''New -&amp;gt; Tree'' via the menu.&lt;br /&gt;
** If you already have a Root node, click the &amp;quot;Begin Editing&amp;quot; button instead.&lt;br /&gt;
* Click on the Root node, and set {{keyname|Model}} to the name of the terrain mesh, in this case {{keyvalue|models/terrain/simpleterrain.obj}}.&lt;br /&gt;
* Press {{accelkey|enter}} to confirm the selection, and the terrain should appear in the 3D view.&lt;br /&gt;
&lt;br /&gt;
Be aware that your terrain model will probably appear bright orange or red.&lt;br /&gt;
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!&lt;br /&gt;
&lt;br /&gt;
=== Important note about nodes ===&lt;br /&gt;
When you are editing properties of nodes (names, numbers, texture sources etc.) always remember to hit {{accelkey|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 {{accelkey|enter}}, your changes may not be applied.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Create the first texture node ==&lt;br /&gt;
[[Image:simplemega_firstnode_diffuse.png|thumb|300px|The first texture node's diffuse texture properties]]&lt;br /&gt;
Now that the model is in place, you can start laying down the texture layers (or &amp;quot;nodes&amp;quot;) that will make up your MegaTexture.&lt;br /&gt;
&lt;br /&gt;
First you need to create a new Image Source node in the Terrain Editor.&lt;br /&gt;
* {{accelbtn|RMB}} on your &amp;quot;Root&amp;quot; node and choose ''New -&amp;gt; Image Source'' (or press {{accelkey|shift}}{{accelkey|i}})&lt;br /&gt;
* This will make a new node called &amp;quot;New Image Renderer&amp;quot;.&lt;br /&gt;
* You can rename this new node using the &amp;quot;Name&amp;quot; property field in the '''Object''' section.&lt;br /&gt;
* Rename the node &amp;quot;Dirt&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You will notice in the top right of the Terrain Editor, a section listing things like &amp;quot;Diffuse&amp;quot;, &amp;quot;Distribution&amp;quot;, &amp;quot;Distribution Pattern&amp;quot; etc. Selecting one of these will list all of the properties for that section of the current node.&lt;br /&gt;
The ones we need to worry about are as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Diffuse'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
This is the colour map of the current node, and it should point to a tiling TGA texture.&lt;br /&gt;
* Make sure the Diffuse section is highlighted in the top right of the Terrain Editor.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to a generic tiling dirt texture. Remember to hit {{accelkey|enter}} afterwards!&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/dirt_02_d.tga}}&lt;br /&gt;
* The {{keyname|Scale}} field at the very bottom of the property list allows you to choose how much to tile the texture.&lt;br /&gt;
** 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!&lt;br /&gt;
** 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.&lt;br /&gt;
That's all you need to do for the Diffuse settings in this node.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Distribution'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
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''.&lt;br /&gt;
* Make sure the Distribution section is highlighted in the top right.&lt;br /&gt;
* Since this is our first node, we want to show over the whole terrain. This means the distribution map should be 100% white.&lt;br /&gt;
* You can either assign a pure white TGA texture, or change the {{keyname|Source Type}} to {{keyvalue|geometryBased}}.&lt;br /&gt;
** {{keyvalue|geometryBased}} will by default create a fully white map, so if you don't have a white TGA handy, this is faster.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Distribution Pattern'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
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.&lt;br /&gt;
* 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!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Local'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
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.&lt;br /&gt;
* Make sure the Local section is highlighted in the top right.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching normal map for your tiling dirt texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/dirt_02_local.tga}}&lt;br /&gt;
* The Local texture's tiling amount is automatically the same as the Diffuse texture.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Surface Type'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
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.&lt;br /&gt;
* Find the ''Surface Type Properties'' section of the property list.&lt;br /&gt;
* 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.&lt;br /&gt;
* Hit {{accelkey|enter}} to accept the surface type.&lt;br /&gt;
&lt;br /&gt;
Your dirt textures will now produce correct &amp;quot;dirt&amp;quot; effects when shot or collided with!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Previewing the result'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
[[Image:simplemega_firstnode_preview.jpg|thumb|300px|The Render mode preview of the first node]]&lt;br /&gt;
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]]&lt;br /&gt;
&lt;br /&gt;
* Notice the drop-down arrow on the right of the button. Click it, and select ''&amp;quot;Full&amp;quot;'' instead of ''&amp;quot;None&amp;quot;''.&lt;br /&gt;
* Your terrain should change colour to black. This means it's ready for a preview to be rendered onto it.&lt;br /&gt;
* Click the button itself now, instead of the drop-down. An &amp;quot;Active Tasks&amp;quot; window should pop up, and when it's done, you should see your dirt texture appear on your terrain model.&lt;br /&gt;
* You can switch the camera to Render mode too, which will show your terrain model's shading better.&lt;br /&gt;
* If you want a full-resolution preview of a small area, choose ''&amp;quot;Window&amp;quot;'' instead of ''&amp;quot;Full&amp;quot;'' from the drop-down menu.&lt;br /&gt;
** 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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
'''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.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
== Adding a second node ==&lt;br /&gt;
Now that the first layer of dirt is in place, we can try putting some grass on top of it!&lt;br /&gt;
* Again, {{accelbtn|RMB}} on your &amp;quot;Root&amp;quot; node and choose ''New -&amp;gt; Image Source'' (or press {{accelkey|shift}}{{accelkey|i}})&lt;br /&gt;
* This will make another new node below your &amp;quot;Dirt&amp;quot; node. &lt;br /&gt;
* Name this new node &amp;quot;Grass&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Again, the main map types need to be specified before the node can be rendered:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Diffuse'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
* Make sure the Diffuse section is highlighted in the top right of the Terrain Editor.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to a generic tiling grass texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/grass_04_d.tga}}&lt;br /&gt;
* 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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Distribution'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
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!&lt;br /&gt;
* Make sure the Distribution section is highlighted in the top right.&lt;br /&gt;
* Change the {{keyname|Source Type}} from {{keyvalue|texture}} to {{keyvalue|geometryBased}}.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Geometric Texture Distribution'''&lt;br /&gt;
----&lt;br /&gt;
[[Image:simplemega_geometric_distribution.png|thumb|300px|The geometric texture distribution settings of the second node]]&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
* {{keyname|Altitude Lower}} - Enabling this will limit the lower parts of the terrain from receiving this node's textures.&lt;br /&gt;
** {{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.&lt;br /&gt;
** {{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.&lt;br /&gt;
* {{keyname|Altitude Upper}} - Enabling this will limit the higher parts of the terrain from receiving this node's textures.&lt;br /&gt;
** {{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.&lt;br /&gt;
** {{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.&lt;br /&gt;
&lt;br /&gt;
* {{keyname|Clamp Distribution To Edge}} - Leave this on Default.&lt;br /&gt;
&lt;br /&gt;
* {{keyname|Resolution}} - The size in pixels of the resulting mask. The default value of {{keyvalue|256}} is fine for nearly any terrain model.&lt;br /&gt;
&lt;br /&gt;
* {{keyname|Slope Lower}} - Enabling this will limit shallower angles of the terrain model from receiving this node's textures.&lt;br /&gt;
** {{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.&lt;br /&gt;
** {{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.&lt;br /&gt;
* {{keyname|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.&lt;br /&gt;
** {{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.&lt;br /&gt;
** {{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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Distribution Pattern'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
[[Image:simplemega_dist_ramps.jpg|thumb|300px|The difference between using or not using a Distribution Pattern, and varying Ramp Widths]]&lt;br /&gt;
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!&lt;br /&gt;
So what we want here is a texture to identify the &amp;quot;height&amp;quot; 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.&lt;br /&gt;
&lt;br /&gt;
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!&lt;br /&gt;
&lt;br /&gt;
* Make sure {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching heightmap or mask for your tiling grass texture.&lt;br /&gt;
** This example is using {{filename|textures/megagen/temperate/grass_04_mask.tga}}&lt;br /&gt;
* 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 &amp;quot;Window&amp;quot; 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.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Local'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
Again we want the normal-map which matches the diffuse texture for the grass.&lt;br /&gt;
* Make sure the Local section is highlighted in the top right.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching normal map for your tiling grass texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/grass_04_local.tga}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Surface Type'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
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.&lt;br /&gt;
* Find the ''Surface Type Properties'' section of the property list.&lt;br /&gt;
* 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.&lt;br /&gt;
* Hit {{accelkey|enter}} to accept the surface type.&lt;br /&gt;
&lt;br /&gt;
Your grass textures should now produce correct &amp;quot;grass&amp;quot; effects when shot or collided with!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Preview again!'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
[[Image:simplemega_secondnode_preview.jpg|thumb|300px|The Render mode preview of the second node blended with the first node]]&lt;br /&gt;
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.&lt;br /&gt;
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.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
== Adding a third node ==&lt;br /&gt;
[[Image:simplemega_thirdnode_preview.jpg|thumb|300px|The Render mode preview of the third node blended with the other two nodes]]&lt;br /&gt;
Now that the grass and dirt are in place, we need some rocks to make the terrain look more natural.&lt;br /&gt;
* Add a new Image Renderer node below your &amp;quot;Grass&amp;quot; node and name it &amp;quot;Rock&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Again, the main map types need to be specified before the node can be rendered:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Diffuse'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
* Set the '''Diffuse''' texture and scale.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/rock_01_d.tga}} at a scale of {{keyvalue|32 32}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Distribution'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
Again we can use Geometric Texture Distribution to easily apply the rock textures only to the cliff-like angles.&lt;br /&gt;
* Make sure the Distribution section is highlighted in the top right.&lt;br /&gt;
* Change the {{keyname|Source Type}} to {{keyvalue|geometryBased}}.&lt;br /&gt;
* 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}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Distribution Pattern'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
Again this will control how the the rocks blend into the other nodes. Again, we want a texture to identify the &amp;quot;height&amp;quot; of the tiling rock texture.&lt;br /&gt;
&lt;br /&gt;
* Make sure the Distribution Pattern section is highlighted in the top right.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Image Properties''' section, browse to the matching heightmap or mask for your tiling rock texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/rock_01_h.tga}}&lt;br /&gt;
* 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 &amp;quot;Window&amp;quot; preview to see how the blending looks.&lt;br /&gt;
* Remember to set the {{keyname|Distribution Pattern Texture Scale}} to the same value as the Diffuse Scale, {{keyvalue|32 32}}.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Local'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
Again we want the normal-map which matches the diffuse texture for the rocks.&lt;br /&gt;
* In the {{keyname|File Name}} field of the '''Local''' section, browse to the matching normal map for your tiling rock texture.&lt;br /&gt;
** This example is using {{keyvalue|textures/megagen/temperate/rock_01_local.tga}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Surface Type'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
* Find the {{keyname|Surface Type Properties}} section of the property list.&lt;br /&gt;
* In the {{keyname|Type}} field, enter {{keyvalue|stone}}.&lt;br /&gt;
* Hit {{accelkey|enter}} to accept the surface type.&lt;br /&gt;
&lt;br /&gt;
Your rock textures should now produce correct &amp;quot;stone&amp;quot; effects when shot or collided with.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Preview again!'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Further tweaks ==&lt;br /&gt;
There are other simple changes that can be done in the Terrain Editor to make your MegaTexture look even better.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Node order'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
[[Image:simplemega_node_order.png|frame|Click and drag a node to change the order]]&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
* {{accelbtn|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.&lt;br /&gt;
* Release {{accelbtn|LMB}} when you have positioned the node in the correct place.&lt;br /&gt;
* 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!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Color changes'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
Maybe your dirt texture is too bright? Or maybe your grass looks a little ''too'' green?&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Let's say you want to make the dirt texture darker and a bit more red. Here's how you'd do it:&lt;br /&gt;
* Select your Dirt node.&lt;br /&gt;
* 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).&lt;br /&gt;
* A color wheel and brightness slider will pop up in a new window. You can use this to darken and tint your texture.&lt;br /&gt;
* Choose a darker brightness, and a color slightly towards red. I used '''RGB Values''' of 225, 220, 220.&lt;br /&gt;
* Hit ''OK'' to accept the color.&lt;br /&gt;
* Re-render your MegaTexture preview. You should notice that the dirt layer looks darker now!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''Texture rotation'''&amp;lt;/big&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
An easy way to overcome this is to play with the {{keyvname|Rotation}} value in the Texture Properties section of the Terrain Editor's property list.&lt;br /&gt;
For each node, you should also set the {{keyvname|Distribution Pattern Texture Rotation}} to match the Rotation value if you want your distribution patterns to line up and work correctly.&lt;br /&gt;
&lt;br /&gt;
= Render the MegaTexture =&lt;br /&gt;
=== Save the Surface Tree ===&lt;br /&gt;
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 &amp;quot;Save and Unload&amp;quot; button in the Terrain Editor, or save the whole map.&lt;br /&gt;
&lt;br /&gt;
=== Compile Only Entities ===&lt;br /&gt;
At this stage, your MegaTexture material is still technically &amp;quot;broken&amp;quot;, 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.&lt;br /&gt;
&lt;br /&gt;
However, we need to compile the map in order to tell the [[renderLight]] process which atmosphere to use when lighting the MegaTexture!&lt;br /&gt;
&lt;br /&gt;
So the solution is to do an '''Only Entities''' compile. You can find this in the menu ''Compile -&amp;gt; 2 - Only Entities'' in editWorld. This should be done in a few seconds, and compiles all the information that renderLight needs.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Run the SDK Launcher ===&lt;br /&gt;
Now that your ''.sft'' is saved, go through all the steps outlined in the [[Generate a MegaTexture]] tutorial.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= That's it! =&lt;br /&gt;
[[Image:simplemega_ingame.jpg|thumb|300px|The MegaTexture in-game!]]&lt;br /&gt;
You've now created your very own MegaTexture to use in your map!&lt;br /&gt;
&lt;br /&gt;
Before you even compile the map, you can get an accurate preview of how it will look in-game by pressing {{accelkey|F6}} to toggle &amp;quot;anim&amp;quot; mode while in editWorld's &amp;quot;RENDER&amp;quot; Camera view (toggled with {{accelkey|F3}}).&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
= Troubleshooting =&lt;br /&gt;
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:&lt;br /&gt;
* 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.&lt;br /&gt;
* 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 ''&amp;lt; &amp;quot;mapname&amp;quot; &amp;gt;'' part described in [[A Simple First Megatexture#Creating a MegaTexture material|this section]]), otherwise it will not be searching for the correct images.&lt;br /&gt;
* 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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= See Also =&lt;br /&gt;
* [[An Advanced Terrain and Megatexture]] - an advanced guide for complete MegaTexture creation&lt;br /&gt;
* [[Generate a MegaTexture]] - steps for generating a MegaTexture from the SDK launcher.&lt;br /&gt;
* [http://community.enemyterritory.com/forums/showthread.php?t=19326 Forum Thread] - includes textures to download&lt;br /&gt;
&lt;br /&gt;
[[Category:Art]]&lt;br /&gt;
[[Category:Basic Level Design]]&lt;br /&gt;
[[Category:Tutorials]]&lt;/div&gt;</summary>
		<author><name>Ducks</name></author>
		
	</entry>
</feed>