Adding Custom Textures

From Mod Wiki

Jump to: navigation, search

So you're creating your own level, and want to add your own custom textures to use on the geometry?

Contents

Introduction

For this tutorial you must know:

  • How to create your own textures using an image editing program (if you don't know how, this tutorial on GFXArtist may help).
  • How to create brushwork inside a working map (if you don't know this, see the tutorial for A Simple First Map).

This tutorial covers:

  • How to create a new material file from scratch.
  • How to edit and reload your materials while running the game


Terms

These are the terms that will be used throughout the tutorial, so make sure you know which is which!

"Material file"

  • These are the high-level "containers" for materials. They can store any number of material declarations. They are simply text files with the file type of .mtr (for example C:\ETQW\SDK\base\materials\mapobjects.mtr), and can be edited in any text-editing application, like Notepad.

"Material declaration"

  • Also known just as a "material". This is the text description of a single material. It contains the paths to any textures you want to show up in the game.

"Textures"

  • These are the .tga images which your material declaration will look for. At the very least you will want a diffuse map (just the colour/brightness information of a texture) - however most of the retail ETQW materials use diffuse maps, normal maps and specular maps. You can find out more about these file types in the Basic Texture Overview article.


Requirements

To make sure that your materials will work properly, your texture images need to be the right size, and the right format.

All textures should be .tga (Targa) format.

  • Always use uncompressed Targa files (don't use RLE compression when saving textures).
  • Use 32-bit Targa files for anything which needs an alpha channel for effects (eg. transparency).
  • Use 24-bit Targa files for everything else.

All textures should be sized in pixels to a power of 2.

  • Textures do not have to be square, but the length of the sides must be powers of 2.
  • This means that the width and height of your images could be sized like 64x64, 256x128, 512x1024, etc.
  • But they could not be sized like 57x57, 257x120, 600x1020, etc.


Creating a material file

You could start by just putting extra material declarations into an existing .mtr file, but this can become messy and hard to keep track of. It's best to create your own .mtr file to store all your custom materials.

If your new textures are part of a set for a specific map, it is sensible make a new material file in the /materials/ folder called <span style="padding: 0 0.5ex; background: #def;" title="A file or folder named '<mapname>.mtr'"><mapname>.mtr</span>. The easiest way is to create a new, empty .txt file and just rename the extension to .mtr .

You now have a file ready to add your material declarations to.

Important note

If you create a new .mtr file while ETQW or EditWorld are running, it will not be picked up by a reloaddecls command. You will need to restart the whole game in order for the new .mtr file to be read.

Any material files which existed before the game or editor were run will be updated by the reloaddecls command.


Material declarations

The material declaration is a description of how your textures will be displayed in the game, and also additional options for how the game will interact with your material.

Every texture you want to use must be included in a material declaration.

In general, they are set up like this:

material textures/mapname/my_wall_01
{
	surfacetype "metal"
	{
		diffusemap		textures/mapname/my_wall_01_d.tga
		bumpmap			textures/mapname/my_wall_01_local.tga
		specularmap		textures/mapname/my_wall_01_s.tga
	}
}
  • material - required to define the structure as a material type. The name which follows is what will be displayed in EditWorld's Media Browser.
    • In this case, textures/mapname/my_wall_01 is what would show up in EditWorld.
  • surfacetype - declares what effects and sounds will be played when bullets, players or vehicles collide with your material.
  • diffusemap - this specifies the path (relative to your base or mod directory) of any texture you want to use as a diffuse map.
  • bumpmap - this specifies the path (relative to your base or mod directory) of any texture you want to use as a local-space normal map.
  • specularmap - this specifies the path (relative to your base or mod directory) of any texture you want to use as a specular map.


Bear in mind that you don't have to use a bump map or a specular map, though these maps will help your material look more believable in game.

For more map types and complex materials, look at the See Also section at the bottom of this article.


Multiple materials in one file

Obviously, you will want to create a new material declaration for each new texture you make. It's easy to keep these all in a single .mtr file, you just stack them up with a line break between each one.

You can also add single-line comments and block comments to break up your material file if you want to make it easier to read.

Here's an example:

// This is a comment which will be ignored by the game

material textures/mapname/my_wall_01
{
	surfacetype "metal"
	{
		diffusemap		textures/mapname/my_wall_01_d.tga
		bumpmap			textures/mapname/my_wall_01_local.tga
		specularmap		textures/mapname/my_wall_01_s.tga
	}
}

material textures/mapname/my_floor_01
{
	surfacetype "concrete"
	{
		diffusemap		textures/mapname/my_floor_01_d.tga
	}
}

/* This is a block comment, which
can contain as much information
as you want until it closes like this */

material models/mapname/my_mapobject
{
	surfacetype "metal"
	{
		diffusemap		models/mapname/my_mapobject_d.tga
		bumpmap			models/mapname/my_mapobject_local.tga
		specularmap		models/mapname/my_mapobject_s.tga
	}
}


Testing

There are several commands which can help us to preview and update our materials and textures to get a real-time result of any changes we're making.

  • reloaddecls - Reloads all declaration files, this includes any .mtr files which were loaded during engine startup.
  • reloadimages - Reloads all texture files. This may be quite slow the first time you use the command, since it has to check every texture in the game for updates. After the first time, it should be much faster. This means any time you change and re-save your .tga files, you can run this command and see the updates in game!


We recommend binding these functions to hotkeys so you can just hit a button in the game rather than having to bring down the console and type it out every time!


Troubleshooting

If you have any problems getting your material to show up in game, check this list:

  • Make sure you have put your .mtr file in the right folder.
  • Make sure your material declarations have all the braces in the correct places.
  • Make sure the texture paths referenced by the material declaration actually exist!
  • If you made a new .mtr file while the game was running, you will need to restart the whole engine before it will be loaded.
  • General troubleshooting info is available here.


That's it!

You should now be able to use your new textures as part of your custom level.


See Also

  • Materials - complete material reference.
  • Detail Textures - adding high-frequency detail to your materials.
  • Texturesheets - learn to optimise your textures onto sheets for better performance.
Personal tools