Texturing

From FreeSpace Wiki

Jump to: navigation, search

Contents

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 inconsistent 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 consistently crisp and consistent 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 variant 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.
  • Neither component of the resolution should be smaller than 16, i.e. 16x256 is fine but do not use 4x512. Old ATI cards (X1950 and similar) and even older Nvidia (FX 5200, possibly others) cards will corrupt these textures for some reason.
  • 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.
  • 2048 - This is the maximum texture size for many older ATI cards. So it is recommended to use this as maximum as a general rule.
  • 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- ).
      • 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 below). 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.


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 FreeSpace 2 Textures. As of Feb 05, 2010, PNG Support was made available to the engine as well.

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


Important note about Squadron Insignias

Squadron Insignias, used on pof models which have included its support, are stored in /data/players/squads, not in data/maps. Although .DDS files can be used, in order to keep backwards and multiplayer compatibility, a .PCX version is also needed. So if you want to use a new insignia with .DDS format, you must also provide it in .PCX one, (the texture must be duplicated). More info can be found in Mantis report 1834.


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.


Important note about Models and Texture Loading

As it has happened at least once, this should be defined for future notice. The POF _only_ needs to ever have the colour map (also known as Base Map or Diffuse Map) defined. All of the other types (-normal, -glow, -shine etc) do not need to be defined in the POF so long as they share the same prefix of the name.
Ex: MyShip.dds defined in the POF will have MyShip-Normal.dds, MyShip-Glow.dds and MyShip-Shine.dds loaded by the game engine should they exist because the "MyShip" part links them together.


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, but for the most part, does not need one at all. DXT1 (non-alpha) is the typical format for this map.


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. This effect is turned on by -glow command line flag.

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.

NOTE: FSOpen Glow maps are additive, they ADD colour to the existing texture. 3d modelling programs (like 3ds Max, for example), do not use additive glow maps. They simply use it as a mask. Beware of this difference, as a ship rendered in 3ds max may look different in game due to this difference.

TextureName-shine.xxx

This is the Specular map of the model, once again using the UV’s for the model. The -Shine maps RGB channels are additive to the Diffuse map, hence why many will appear (when viewing in a texture viewer) to be darker than the diffuse map. This effect is turned on by -spec command line flag.

NOTE about environmental mapping: Shine maps are also used by the env mapping effect, (turned on by -env command line flag). You can have 3 situations:

  • No available -shine map. There won't be any env mapping effect either.
  • Available -shine map without alpha channel. The level of environmental reflection is based on the luminance derived from the -shine map RGB values.
  • Available -shine map with a fully valid alpha channel. The alpha channel gives full independent control over the env map effect. In this case, its reflection level is directly set by the alpha channel values, where brighter areas in the Alpha channel whil have a higher level of reflection and be "glass" like the brighter it gets.


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). Transparency can also be set through alpha channel (see further below), but the use of the -trans method offers a number of benefits, attributed to the different nature of its rendering. For one, use of -trans textures eliminates the issue of rendering order, and the texture behaves as if the "transparent" box is checked in the ship lab.

Note: unlike with other textures, simply providing an extra MyShip-trans texture doesn't work. You must actually name your base texture MyShip-trans and do so also in the pof file. So instead of MyShip.dds, MyShip-normal.dds and MyShip-trans.dds, you need MyShip-trans.dds and MyShip-trans-normal.dds.

New texture types within GLSL rendering

OpenGL has been improved in order to use shaders (GLSL) rather than fixed pipeline GPU functions. This enhancement has introduced two new effects, normal mapping and height/parallax mapping, and its associated auxiliary textures. See OpenGL Shaders (GLSL) section for more info about this new rendering system.


TextureName-normal.xxx

This is the Normal/Bump map. These provide an appearance of raised or lowered surfaces on the model that, while they add detail, may be too costly to implement directly within the model polygons themselves. Normal maps tell the render which angle each texture pixel detail should actually have against the flat model triangle where it is applied. Then, a local modification of the general lighting is dynamically applied per pixel based on this info, the viewing angle and location of light sources, generating a fine 3D detail appearance. This effect is turned on by -normal command line flag.

There are many different ways in which to create a normal map, from Crazybump and other 3rd party stand-alone applications, to the Photoshop and Gimp nVidia DDS tools. ATI also has a normal map generating tool as well, as do many modeling applications (via plugins or scripts). Command line tools that handle converting textures to DDS are capable of creating a DXT5_NM, but this is not the most optimal approach.

A basic approach (from a diffuse or shine map) is to make sure it is as clean of any grit or texturing (unless intended) as these will create raised or lowered surfaces on the model. If necessary, the image can be converted to greyscale from RGB and then back again. Adjusting the contrast to bring out definition lines is also useful. Once the basic outline (dark lines for recesses and bright lines for protrusions) are made, you can generate your normal map.

Saving it directly as DXT5_NM however, is not going to work very well with the unique way that FSO handles normal map generation. A general idea is that only the Green and Alpha channels need any data. Green contains the horizontal lines while the alpha channel controls the vertical. The other 2 channels (Red and Blue) can be painted all black. Before doing this, however, you will need to copy the grayscale looking normal information from the Red channel and paste it to the alpha channel. Then save as a DXT5. (Alternatively, you can save it as u8888 to test it out prior to making it a DXT5. This allows for modifications to be made without unduly re-compressing the map every time. For this reason, creating a file and using "Save As - DXT5_NM" and then manipulating the channel data is a bad idea and provides limited control of your output.)

Bear in mind, that due to the way the human eye reacts to things, you may think your normal map is inverted (IE: What you have set to be recesses are popping out at you instead of away from you). Don't Panic! Nothing has gone wrong as you will see once it is in-game.


TextureName-height.xxx

This is the height map used within the parallax displacement effect. This effect is turned on by -height command line flag. NOTE: This effect is currently not supported by the shaders distributed with the MediaVPs. If you wish to use it, you need to implement support for it.

TextureName-misc-xxx

This map is used to apply team colors to the hull texture. The base color is applied to the red channel, and the stripe color is applied to the green channel. The blue and alpha channels apply team colors to the glow map using the base and stripe colors respectively.

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, PNG, TGA, JPG, PCX

$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.
  • Normal Map alpha channel: There is no transparency here, but rather additional data for rendering the lighting effects for the normal map. This channel stores what gets generated by the RED channel of a normal map generation filter (Such as Photoshops NormalMap Filter).


Wiki articles index

Personal tools