Back to tutorial index page

 

Setting up and using custom assets in ET:QW

(Using template files for materials, loading custom ASE models into the editor and using texture blending on 'indoor' modelled environments)

This is my first tutorial for ET:QW. Although similar to Doom 3 and Quake 4, some of the processes involved are some what different to those the level designer has become familiar with.

This discussion is not aimed at the noob designer and assumes some experience and expertise with current idtech and stand alone modelling and 2D art applications commonly utilised by level designers.

 

Template files

Template files are a nifty short cut for creating  materials (.mtr files). Rather than having to cut and paste often used material scripts over and over again it is possible to set up a .template file that an .mtr script can call on. The really handy feature is that it is possible to call multiple .templates within a single .template file. At the time of writing I have only set up a template for standard textures ( local, diffuse and specular maps), but in theory it should be possible to set up .templates for alpha masked materials, glow maps, or any other effect you can think of, then cross reference and call on each as required. For further technical information have a look at this.

Below is my .template script:

template material/dk_et1_generic

{
parameters < TextureParm >
text {
diffusemap TextureParm_d
bumpmap TextureParm_local
specularmap TextureParm_s
}
}
 

The name of the script can be any thing you like, in this case dk_et1_generic.

The parameter section defines names that will be replaced when the script is called. The text section gives the information that will be inserted into the .mtr.

The file is saved as a custom name, in this case dk_et1.template, in the template folder.

In the materials folder I create a  text file called dk_et1.mtr

The file sets up all the textures in the dk_et1 texture folder. For each texture all that is required is the following entry:

material textures/dk_et1/concrete_512_darktan

{
useTemplate material/dk_et1_generic< "textures/dk_et1/concrete_512_darktan" >
}

The concrete_512_darktan part is the name of my texture. For every desired material you require an entry in your .mtr as above, but edit the texture name for each.

The .mtr calls the .template and the entry TextureParm is replaced by my textures name (concrete_512_darktan) as the game creates a full .mtr out of my .template so I don't have to.

 

 

Loading ASE models, correctly textured into ET:QW

For this article some understanding of Blender 2.44 (including installing and setting up python 2.5 and installing the appropriate Goofas export scripts). If any of this sounds unfamiliar then take a look at the excellent series of tutorials on Kat's Bits.

As the particular model that was being imported into ET:QW was a natural cave area that required organic looking texturing, this discussion will also cover setting up a texture blending material script. On natural/organic features abrupt texture transitions just look wrong. It is much more satisfactory to smoothly blend one texture into another.

Getting started...

The first step is to create your desired mesh. Not having a huge amount of spare cash, and not being a supporter of illegally copied software I have no access to 3D Studio Max or Lightwave. All of my modelling is done with the truly excellent Blender3D. Blender is a free stand alone 3D application of immense power and a huge community of support and information. I have yet to come across anything that is required of video game models that can not be done (and done well) using Blender.

Exactly how to create your model in Blender is a huge topic in itself, and covered already in many other places. Again, visit Kat's Bits for further information.

The model must have a material applied, and a texture linked to that material. It must be unwrapped and the texture applied to the mesh. If built from quads, remember to triangulate the model on completion. For my organic looking cave area, the mesh was 'smoothed'. As already mentioned my intent was to blend textures together. The limitations of this is that only two textures can be blended at any one time. A special script has to be written and applied to the mesh's texture (more on this later). Basically what the game script will do is look for colour information about the model's vertices. If a vertex is white one texture will be applied, if it is black another texture will be applied. The gradient tone change between those white and black vertices results in the degree of texture blending between those two points. The blending process begins in Blender3D. We need to colour (vertex paint) the model. By default the unpainted model is white. In Vertex Paint mode, select the colour black and apply this colour to areas of the mesh that you want texture blending to occur. In my case I wanted the floor texture to seamlessly blend into the cavern walls.

With everything set, the model is exported using the Goofas ASE export script.

Setting things up in EditWorld....

Having produced an ASE model, there are still a few more hoops to jump through. The game will not be able to apply a texture to the model unless we give the model a texture path that the game understands. Some hand editing of the mesh file is required. The useful thing about ASE models is that they are basically text files. It is easy to change textures manually, without the need to go back into your stand alone 3D application. For this part of the process any text editor will suffice, but Edit Pad is by far the best tool.

Below is the relevant section of the ASE model file opened in edit pad:

*MATERIAL_LIST {
*MATERIAL_COUNT 1
*MATERIAL 0 {
*MATERIAL_NAME "textures/dk_et1/terra"
*MATERIAL_CLASS "Standard"
*MATERIAL_AMBIENT 0.0000 0.0000 0.0000
*MATERIAL_DIFFUSE 0.8000 0.8000 0.8000
*MATERIAL_SPECULAR 1.0000 1.0000 1.0000
*MATERIAL_SHINE 0.5000
*MATERIAL_SHINESTRENGTH 0.0978
*MATERIAL_TRANSPARENCY 0.0000
*MATERIAL_WIRESIZE 1.0000
*MATERIAL_SHADING Blinn
*MATERIAL_XP_FALLOFF 0.0000
*MATERIAL_SELFILLUM 0.0000
*MATERIAL_FALLOFF In
*MATERIAL_XP_TYPE Filter
*MAP_DIFFUSE

I have highlighted the line that requires editing for ET:QW. For D3 and Q4 it was the bitmap path that needed altering, for ET:QW, this has changed. Now the material path needs changing. In the past the path was written as:

//q4base/textures/whatever

note now it reads:

textures/dk_et1/terra

For the game to find the texture a folder called dk_et1 must be added to the textures folder, and a  .mtr file called dk_et1 added to the materials folder, with a script defining the material called terra.

The model itself is placed within a folder (in this case called dk_et1) inside the mapobjects folder, inside the models folder.

Further information on exactly what the dk_et1.mtr needs to contain in order for the required texture blending to be achieved later on.

Every thing is in its place, so how is it loaded into EditWorld?.....

Fire up the editor then right click over the 2D window. Look for  Model Static at the top (shown below):

Select Model Static then locate the custom folder:

Select the desired model, it will be previewed in the render window on the right of the model loading window. If there is a problem with the model's texture pathway it will have a default red and black texture missing skin:

The model will be loaded with its point of origin at 0,0,0 on the grid.

For a quick render, a single light is added, the results are shown below:

Achieving the texture blend....the script part

The clever texture blending is achieved as already stated through vertex painting on the model itself and through the use of a specific script in the game.

Things work a little different between Q4 and ET:QW, although the fundamentals remain the same. Below is a texture blending script used for Q4:

textures/milltest/floorblend
{
qer_editorimage textures/myfolder/mytexture1.tga
materialType rock
noSelfShadow

//### TEXTURE 1
{
blend bumpmap
map textures/myfolder/mytexture1_local.tga
VertexColor
}
{
blend diffusemap
map textures/myfolder/mytexture1_d.tga
VertexColor
}
{
blend specularmap
map textures/myfolder/mytexture1_s.tga
VertexColor
}

//### TEXTURE 2
{
blend bumpmap
map textures/myfolder/mytexture2_local.tga
inverseVertexColor
}
{
blend diffusemap
map textures/myfolder/mytexture2_d.tga
inverseVertexColor
}
{
blend specularmap
map textures/myfolder/mytexture2_s.tga
inverseVertexColor
}
}

The myfolder and mytexture would be replaced by your own custom names.

The ET:QW version:

material textures/dk_et1/terra
{
qer_editorimage textures/dk_et1/rock_d.tga
surfacetype stone
noSelfShadow

//### TEXTURE 1
{
bumpmap textures/dk_et1/rock_local.tga
VertexColor
}
{
diffusemap textures/dk_et1/rock_d.tga
VertexColor
}


//### TEXTURE 2
{
bumpmap textures/dk_et1/veg_local.tga
inverseVertexColor
{
diffusemap textures/dk_et1/veg_d.tga
inverseVertexColor
}

}
 

I have highlighted the alterations with italics in the new script. The above script has no specular stage, which is irrelevant for the discussion here, if necessary, one could be added. Rocks just don't look very good shiny!

Starting at the top, every script now requires the name material at the begining. The next change is materialType is changed to surfacetype, and the declarations for the surfacetype available to choose from is altered.

It is not necessary to define each texture map with blend. The bumpmap, diffusemap or specularmap declarations act as shorthand.

That's about that. The important point to grasp is to be extremely careful setting up the texture path in the model and the naming conventions in the texture folder, materials folder and in the .mtr itself. When things don't work as you think they should the most common cause is pathway errors.

For further information just send me an email at dk<AT>leveldk.co.uk

Good luck and have fun!!!