Back to tutorial index page

 

Basic MegaTexture walk through

(The basics (and that doesn't mean it's easy!) of creating custom made MegaTextures)

Caveat: This is very much a 'work in progress' at the time of writing. There is much I do not yet understand about the process of creating MegaTextures. As much as providing some guidelines for others this article is written as and 'aide memoir' for myself as to the procedures I followed.

Where to start...:

First things first. More than any other game I have designed for the work flow required for Quake World is of the utmost importance. I jumped several stages ahead of myself in trying to produce a working MegaTexture. It seems to me the most sensible approach to level design for this game is to block the level out in edit world, block out the game play, then export into an external 3D application to create the meshes required for the level. To create a realistic terrain that exactly fits the world geometry seems to require that it is the last piece of the jigsaw to be put into place. None the less, I wanted to explore the steps I needed to follow in order to create a mega texture.

The steps taken, once understood where relatively simple, but do require a significant level of skill in other areas.

Enough waffle, let's get down to it.

Some prior preparatory steps where made. This basically involved creating several organic (rock/stone/vegetation) diffuse map textures in PhotoShop and accompanying normal (local maps) in Crazy Bump. Several suitable images were also produce to act as detail map images. All of these files were placed in to a custom folder named dk_et1 and this was then added to the base/textures folder.

The first step is to set up a map .mtr file. In this example my map is called dk_et1, so all my media have that prefix. Therefore I created a dk_et1.mtr, in this file I added the scripts for custom textures I thought I might need for the map and also the entry for my MegaTexture:

material megatextures/dk_et1 { useTemplate megatextures/default_ambient< "sdk/dk_et1" > }
material megatextures/dk_et1_noshadows { useTemplate megatextures/default_ambient_noshadows< "sdk/dk_et1" > }

Note that my map sits within the sdk folder. File pathways are the absolute most important factor in achieving a successful result.

Now we have set up a MegaTexture .mtr declaration for a MegaTexture that does not exist as of yet. Now, the process is somewhat difficult in that it will not allow you to create a new MegaTexture that does not already exist. Good this, isn't! :) This means you need to do some hand editing of file names. Open up the SDK base folder and go to the maps folder. Copy and rename the etqwmap.stf and .stm files. In my case to dk_et1.stf and dk_et1.stm. Next go to the megatextures folder. Copy and rename the 4 etqwmap files found within. Again in my case the etqwmap part is altered to dk_et1. All these files will be replaced as we go along, but to begin with these are the hoops that are required to be jumped through.

We have a renderlight file (.rlt) to create too, but for now let's leave that.

The second thing is to create a model for the terrain. In Blender3D  I made a very quick mesh, 32768 units by 32768 units square (the default MegaTexture size I believe). Something to bear in mind is that the entire texture creation process is very much top down. A complex mesh with overhangs and caves is likely to represent a huge challenge to MegaTexture. The mesh requires a material to be applied and a texture applied to the material. The mesh should be unwrapped and UVW mapped with the texture. It appears that the unwrapped mesh should be constrained within the limits of the texture. It really doesn't matter what texture you use as it is in effect a place holder, to be replaced later by the MegaTexture. Make sure you name the material the same path and name of your soon to be created  MegaTexture, in my example megatextures/dk_et1. If you follow this approach no hand editing of the .ase model file will be required. Traingulate, smooth and export the mesh as an .ase model. The model needs to be placed into the models/terrain folder. For the sake of neatness my model went into a models/terrain/sdk/dk_et1 folder.

Ground work over, now to get the terrain into the editor:

The scene needs to be set for the new model. Create a caulk hull big enough to contain the 32768 unit square model. Through in an atmosphere and an info_player_start. Now open the terrain editor (shift+n). Why first reaction was wtf is this? The terrain editor creates a surface tree. The stf we are about to create is a text file, that can be edited later without the need to open the terrain editor. Basically, orders the textures you want to blend together to create your MegaTexture. The terrain editor can get pretty complicated. For the scope of this article things will be kept very basic. Right click on the left hand window and select new, then tree. The begin edit button at the bottom of the left hand window should now become active and the word 'root' appears at the top of the window.

So let us begin.

Many of the features we will discuss here require playing with to achieve the results required.

 

With root selected the middle window will now give you several options to edit. Under editor select the default etqwmap mask (click on the text box and follw the links) for the overlay image.

Select the 4 textures you want to add as detail textures in the 4 detail boxes. I had previously made my own images and placed them in a dk_et1 folder, inside the textures folder. I should add here images need to be non rle compressed 24 bit tga files.

To load the terrain click on the text box next to model and locate your terrain mesh. Load the same mesh for the ST model at this time.

Right click under root and add a new/image source. Right, now we have a new set of options, and some text in the right hand window. With  diffuse selected on the right, ensure source type is set to texture and locate the image you want in the file name text box. Run down the list in the right hand window, selecting various source types required (the different ways in which the image will be blended, applied and projected). In addition to previously creating detail images, I also created diffuse images and localmap images for each of my textures, all of which were placed into my dk_et1 texture folder. For my MegaTexture, the only texture images sources were the diffuse and local maps.

Add more image sources as required and follow the same process of assigning values to the Diffuse, Distribution, Distribution Pattern, Global Mask, Heightmap, Local and Projector Pattern selections.

When you're done, its time to save the map and do some compiling :)

Let's Make a MegaTexture, finally:

One of the less amusing things about this process was not being able to use the MegaBuild front end compiler. For me it simply crashed every time. Therefore I had to mess about from the console running compile options. Once again, allow me to underline the fact that this is an article about how I managed to produce a working MegaTexture, not a technical document on the use of the editor or compilers, that much you must figure out for your selves, as I am.

(Note: where I use sdk/dk_et1 or dk_et1, this refers to my map, replace these entires with your own map's name.)

First we run MegaGen. This is used to output the diffuse and local maps required to generate the MegaTexture.  It is also used to create detail and detailmask textures and the .stm file.

Run each of the following:

megagen sdk/dk_et1

megagen -dtm sdk/dk_et1

megagen -notex -stm sdk/dk_et1

(note: for some reason, running this compile twice fixes the invalid surface type error)

So far as I can tell the detail and dtailmask textures created need to be renamed dk_et1_lit_detail and dk_et1_lit_detailmask, and moved into the megatextures/sdk folder.

Next is the lighting compile. You must create a dk_et1.rlt file in the renderlight folder for this to work. Copy an existing rlt and rename it. Open it in editpad or note pad and edit for your map. In the console type:

renderlight -premulLighting maps/sdk/dk_et1

This creates a dk_et1_lit.tga in the megatextures/sdk folder.

Finally run:

makemegatexture -v -q .5 .5 .5 sdk/dk_et1

The dk_et1.mega should now be created in the megatextures/sdk folder, along with a dk_et1_lit_preview.tga (editor image).

It seems that if you want to re-make the .mega file, you must delete the existing file first.

Save and exit the editor (at which point my editor normally crashes). Reload editworld and open your map. The terrain model should now appear correctly adorned in your brand new MegaTexture.

And here is the last stop, at the time of writing that's as far as I have got. A working, but basic MegaTexture. Have Fun :)