Texturing

From FreeSpace Wiki
Revision as of 15:03, 28 June 2008 by TopAce (talk | contribs) (I just checked. ''Noticable'' is a misspelling. ''Noticeable'' is the correct form.)
Jump to: navigation, search

General

Properly texturing a model is perhaps one of the easiest aspects of modeling to actually do, but possibly the hardest to do well. There are two types of texturing methods, tiling and mapping, each with its own distinct advantages and disadvantages. I am not qualified to explain mapping (also called texture wrapping or unwrapping), as this is by far the more difficult of the two to do well. This form of map is most commonly used on fighters, although some capships (many FS1 cruisers, as well as distinct ships like the Lucifer) make use of full mapping. The advantage comes in a form-fitted map, that has each piece distinctly textured to reflect the designer's intentions as to what function each section should serve. However, especially with the older 256x256 maps, large scale mapping can be blurry and inconsistant if extreme care is not given to the construction of a map. Mapping a ship also requires you to be able to create techy maps in a photoshop-like program, and there really isn't an effective substitute.

Texture tiling: This method is simple, and (besides being the primary capital ship texturing method used by Volition) produces a consistantly crisp and consistant hull if applied correctly. When constructing a model, the choice between mapping and tiling generally comes early; anything with large flat or gradually curved expanses can easily exceed the optimal resolution for wrapped textures and makes tiling extremely noticeable. As a general rule of thumb, don't create large expances of unbroken hull and you won't have this problem. If you can't get around it, though, try to split the section into two or more horizontal or vertical sections that can be mapped with similar textures or otherwise find a way to break overly repeated textures up. Using a varient of the same texture (such as ~C~Tile1 and ~C~Tile5 from the stock FS2 textures) can work really well here. Once your model is ready to texture, you must provide UV coordinates for each polygon so that the game renderer knows how to display your textures. I start out usually by applying a box UV map to the whole object, and then work from there. This comes with the advantage of lining everything up for tiled textures, but can create some odd seaming effects around 45 degree facings. I then go back and planar map (TS5) or unwrap (3ds Max) any parts that require special attention, such as engines, viewports, corners, etc. so that they fit the scheme I want. I would advise against spherical, cylindrical, or shrinkwrap UV map options, as they tend to create unstable normals (in TS) and almost always create an unexpected "pole" effect around the ends which is difficult to rectify. For a step-by-step walkthrough, I would strongly suggest taking your modeling program of choice and just playing with it. See what you can come up with. And that's all of the texture section until someone who is better at it than I am comes along and fixes this page up.

Choosing dimensions

When making textures for models always use dimensions that are equal to 2n (2 to the power of some number), this means these numbers:

16, 32, 64, 128, 256, 512, 1024, 2048, 4096 etc.
  • 16 is the smallest texture FS2 will deal with, using anything smaller is a waste.
  • 256 is a special value because without changing a registry setting D3DuseLargeTextures (or using the launcher "Use Large textures") this is the largest texture that can be used by the engine without it having to cut into sections. This is also the maximum texture size for voodoo 2 & 3 cards.
  • 1024 - This is the maximum texture size for many older cards that aren't voodoo, a TNT2 for example would have this maximum.
  • 4096 - This is the maximum for a Geforce 4 card, however make sure you consider your texture sizes carefully a 4096x4096 (16 bit) texture takes up about 34 Meg, that's more memory for one texture than the TNT2 has in in total.

So what happens if you don't use these magic numbers? The engine will use the next one up. So if your texture is 257x257 then the texture will be 512x512 and the image will either be stretched across this larger area or the extra space will be wasted.

Remember that texturing is one of the most time consuming things your card has to deal with, with bad texture sizes its easy to waste processor time without making the result look any better.

The same goes for most other textures (and anims) in FS2 and all other games, the exception to this is interface art. e.g. the main hall background, this texture won't look good if it is stretched in the Y direction to 480 or 768 because the smoothing code is different.

SCP Team Recommendations

The new HT&L feature of Freespace 2 SCP has allowed a vast increase in the number of polygons that can be displayed at any one time, however, in order to keep gameplay smooth, the SCP team recommends the following rules when making models for use in Freespace 2.

Textures :-

1 : Use as few textures per model as is possible, optimization is the key. For fighters and bombers you should only need a single 1024 x 1024 map for the model. Capital ships can use more textures, but the less textures and the less memory they take up, the better.

2 : Unless it is absolutely vital, use the .DDS format for storing your images. The DXT formats of these files are compressed and are automatically decompressed by your video hardware, so they take up far less memory, thus improving performance. Freespace 2 also supports .TGA format files, but these should only be used where .DDS files are causing noticeable compression errors on your texture (this can happen most noticeably with semi-transparent textures, or gradients)

  • DDS format consists of multiple types. If the texture needs an alpha channel, use DXT5 compression, otherwise use DXT1c compression. (DXT1c uses way less memory. DXT1a can also be used like DXT1c because its alpha channel is ignored -See below-. Both prevent the 'mirror' effect as the game uses a fixed amount of environmental reflectiveness.)
    • Tip: See if the program you use to compress has a High Quality option. With the nvdxt cmdline program, the switch is: -quality_highest
  • Other alternatives to TGA -- in cases where DXT compression is unacceptable (noticeable errors/artifacts) -- are u888, u8888, or u1555. u888 is 24 bit color and u8888 is 32 bit color (24 bit plus 8 bit alpha map), just like the types of TGA. The file doesn't get any smaller than TGA, but it can now have mipmaps (see Models). u1555 is 15-bit color, usually best for files that used to be PCX.

3 : For highly detailed ships, it is better, from a memory point of view, to use one large texture than several smaller ones.

4 : ALWAYS use texture sizes that are a power of 2, i.e. 256, 512, 1024 or, at most, 4096. However older ATI cards can only use 2048² maps. So it is recommended to use this as maximum. You can have different ratios, such as 512x256, but always use these sizes.

Models :-

Remember that any Level of Detail models are going to be stored in memory, so use them sensibly. Freespace SCP now uses Mipmap technology, so you no longer need to create LOD’s for the textures, an old requirement of Freespace 2 modding. Whilst polygon count does not have as dramatic effect on performance as texture size does, it is, as always, best to optimize where possible.

Texture Types

Freespace 2 SCP uses mostly .DDS and .TGA format images. These can also be linked together to form animated maps (see later). Also, .PCX files are commonly found as they were the original format of Freepsace 2 Textures.

Please read important info about texture format priority in the help for -mod command line flag.


Texture naming conventions

Whilst the textures on your models can be called anything, there are certain naming conventions in creating effects textures such as glow-maps or specularity, basically the naming convention works as follows.

TextureName.xxx – This is the colour map for the material. It should be mapped out to the models UV Map. This can use an alpha map for transparency.

TextureName-glow.xxx – This is the glow map for the model. It simulates the effect of ‘portholes’ or other glowing part of the ship. Using the same UV Map, and a black background, make any flat lighting effects you want on the ship on this texture. These are different from Glow-points, which are points on the model and are covered later. NOTE: Glow maps do not use the alpha channel. So using a 32-Bit format like DXT5 will waste memory. It is recommended to use DXT1 for glow maps.

TextureName-shine.xxx – This is the Specular map of the model, once again using the UV’s for the model, colour in all the parts of the surface which are metallic, using whatever colour you want the shininess to be. The brighter the colour, the shinier it will be. NOTE: Shine maps can also have an alpha map. This alpha map is used to define the level of ‘reflection’ when environment mapping is operating.

TextureName-trans.xxx – This enables the transparency for the map of the model, once again using the UV’s for the model. Map in question can also be set as -shine or -glow map (for example TextureName-trans-glow).

NOTE : When creating Shine-maps, if the map does not have any environment mapping (reflection effect) then the Spec-map should be saved in DXT1c format with no Alpha-map. This will improve performance for maps that do not use environemt mapping (environment mapping is different to Specular, which helps give a metallic 'effect' to the material).


Animated Textures

Freespace 2 SCP also supports two kinds of animated file format. The first is the standard .ANI extension as used by Freespace Retail, you can convert these using the AniBuilder program from the Descent Tools package. The Second format is the new .eff file. This allows multiple single images to be chained together into an animated texture. All .EFF image files must be in the same format, but can be in any format Freespace SCP supports, and must have an underscore and their Frame number added onto their name as a 4-digit number starting at 0000, for example RunningLights_0000.DDS, RunningLights_0001.DDS etc. Now simply create a new text file for your animated texture with the same Base name as your texture and a .EFF extension (in this case, RunningLights.EFF) and simply enter the following text.

$Type: XXX - Defines the type of file being used, can be DDS, TGA, PCX or others

$Frames: XX - Defines the number of Frames in the total (looping) animation.

$FPS: XX - The Frame Per Second speed of the animation.


This file should be saved in the textures folder of your project alongside the images themselves.


Effect textures

Textures are also used in weapon bitmaps, explosions, background nebulas and planets, glow points and so on.

General considerations about ship textures also apply here. As an example, Media VP compilations have changed explosion .ANI clips by .EFF (.DDS) ones.


Alpha Channel management

With the exception of -shine maps, where the alpha channel sets the environmental reflectiveness, the alpha channel is normally used to set the transparency level of the texture. The way it behaves is:

  • Bitmap formats with no alpha channel. The black pixels of the texture are transparent. Any other colour is shown. Of course, this rule doesn't apply to ship textures where you can have black shown pixels.
  • DXT1a DDS textures. They have 1 bit alpha channel, (DXT1c ones don't have alpha channel), but this channel is ignored. They behave as textures without alpha channel.
  • Other formats with alpha channel. Pixel transparency is controlled by the alpha channel value. Black (0 value) is transparent and white is fully opaque.