Imposters

From Mod Wiki
Revision as of 17:08, 15 October 2007 by 192.168.0.129 (talk)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Imposters are a way of more cheaply rendering complex models in the distance. Distant models are replaced by a special sprite, this sprite is rendered using a bump and diffuse map so it can be lit like the real thing. These maps can be automatically generated using the imposter tool. In ETQW, imposters are generally used for rendering trees, bushes and other foliage cheaply in the distance.

As the imposter has a bumpmap it is independent of the lighting in your map; changing the lighting will also cause the imposters to change. As the bump & diffuse maps are precalculated based on the model you will have to regenerate the imposter if your model or the model's textures change.

Creating an Imposter

To create an imposter you first have to make an "imposterGenerator" declaration. This specifies what models to use, the names of the output textures and materials and some extra options. The structure is as follows:

imposterGenerator imposters/myfolder/mymodel {
	sourceModel	models/myfolder/mymodel.lwo
	outputTexture	models/myfolder/mymodel.tga
	numAngles	8
	tileSize	64 128
	vertexColored
}

The options are:

  • sourceModel - The model you want to render to the sprites from.
  • outputTexture - The TGA file you want to save the sprites in. Generally keeping this in the same folder as the model makes sense, since it's easy to find.
  • numAngles - The number of angles to generate "sprites" for. More angles will look better, but take more texture memory. Generally, radially similar models need less angles than asymmetrical objects.
  • tileSize - Optional. Specifies the X and Y size in pixels that each sprite rotation should occupy in the destination TGA.
  • vertexColored - Optional. Use this if your source model is rendered in the game using vertex colors.

Notes

All declarations like this should be saved as .imp files in the base/imposters folder. You can have as many "imposterGenerator" declarations in a single .imp file as you want, for example you could keep all imposterGenerator declarations for palm tree models in base/imposters/generate_palm.imp.

Generating an Imposter

Run the console command "imposter [imposterGenerator name]" to (re)create the necessary imposter textures (for the above example, you would type imposter imposters/myfolder/mymodel in the console). This will do the following:

  • Render the model sprites and save them in the specified tga
  • Create a new "imposter" declaration in imposters.imp
  • Create a new material in imposters.mtr

In theory none of these things should be modified by hand, just re-run the "imposter" command. You can also regenerate all imposters in the game by typing "imposter all" in the console.

Using Imposters in Your Map

Any entity can have an "imposter" key, the value of this key should be set to match the imposterGenerator name. The model of that entity will then be replaced by the imposter based on distance (Note that MaxVisDist is ignored for imposters). You can also place an imposter in you map using "misc_imposter", in this case the imposter will always be rendered, never the model. These are more efficient for out of bounds objects than just placing a func_static with an imposter on it (you may still give them a model key so they look similar in Radiant, but the game will only render the imposter).

Considerations for Imposters

  • They take some texture memory, so don't start doing imposters for every small pebble.
  • The "symmetry" of the base model should be along the z-axis, so say you wanted a pillar that has fallen over, it may be better to model it standing upright and then rotate it using the angles key of the entity. That will ensure the least visual distortion is caused by the imposter.