Game Textures

From PSwiki
Jump to navigation Jump to search

Guide to appropriate image file dimensions

As a rule, all textures (whether for items, characters, or environments) should be a power of two in each dimension (it is an issue of efficient use of memory). That means you can use any of the following choices for a texture size: 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, and so on (but unless you’re texturing a skybox, you'll probably need to stop there). The textures don't have to be square: they don't have to have the same size in both dimensions. So 64 x 128 works, for instance, or 512 x 32, or 256 x256. But you shouldn't make a texture image that is 200 x 200 pixels, since 200 isn't a power of two.

The size of the texture depends on the model it wraps around. A small and simple item, like an apple, should have a texture with dimensions no higher than 128. A weapon can go up to 256, and characters are either 512 or 1024 (the latter in the case of a large, single-mesh NPC). Inventory icons are sized at 64x64 to fit slots.

When you are working on a texture, you should always work at twice the size of the final. Scaling down an image at the end tightens it up, and hides most small imperfections. It also allows you to add detail that, while still visible on the final model, would be harder to add using the size of the final texture. Working any larger than twice the size, may mean losing those details in the end result.


Determining textures size

The resolution of the texture is critical in the final result you will get in game. The higher the resolution per square meter, the better will look in game when players approach the item.

To give you some guidelines, the Hydlaa houses use a resolution of 128x128 pixels every 3x3 meters block. This resolution is not something we should use anymore these days, it's too low.

Other items like windows use a resolution of 128 pixels every meter. This is a much better resolution, and the minimum we should use.


Small textures

Items with a size of about a hand, at most half an arm, may not need a texture with more than 256 pixels in their longest dimension. If applicable, try to reuse parts of the texture for several parts of the model by overlapping UV areas (e.g. 3 of the 4 quadrants of a finger ring may look the same, and the inside may look like the outside).

Medium textures

Items with a size of at most a shirt or trousers may not need a texture with more than 512 pixels in their longest dimension. As those items are more notable, ensure that their specific details can be easily recognised even from some distance. Decide how some light and shadow distribution in the texture may improve the recognition.

Large and huge textures

A model about the size of a Dermorian or Ylian model deserves a texture with a maximum dimension of 1024 or more pixels, one even larger may require up to 2048 pixels as maximum. Expect fine details to be recognised.

Combining Textures

If you are combining many textures into one texture map make sure you only do this for assets that cannot be used elsewhere (i.e. walls of a building etc). Make sure that the resultant texture size is not greater than 2048 x 2048.


Transparency

Decide early if you need transparency, and which kind.

PlaneShift supports 3 types of textures: 1) Not transparent (DTX1) 2) Binary transparency: each pixel is just either opaque or transparent (DTX1a) 3) Alpha transparency or range transparency: you have a value from 0-255 associated to the amount of transparency each pixel has (DTX5)

Obviously binary transparency is more efficient and consumes less memory, but gives more sharp edges and CS will render the edge more or less along the pixels edge. While DTX5 used with an antialiased edge in CS with binary alpha flag, will render the alpha-solid color edge very nicely rounded. You should decide based on the model what kind of transparency you will need on the texture.

Dxt1a vs dxt5.png


Examples: Most icons usually need DXT5 due to the black halo. Model textures in general may only need DXT1, exceptions are the Carkarass wings, or the Grendol stomach; sharp edged textures like tree leaves should still use DTX5 or 3, but in CS should be flagged as binary alpha

Always keep a lossless version of your texture (e.g. PNG, with Alpha channel if necessary). The DirectX Texture Compression reduces the color resolution, you won't be able to retrieve a texture of good quality once you lost a master. You will as well prefer to keep a multi-layer master if you worked with layers, in a portable format (e.g. Photoshop *.psd or GIMP *.xcf).


Icons

They are textures with a dimension of 64x64 pixels. They are in general transparent, and because they usually have a blurry black "halo" around the displayed image, with at least 5 pixels width, you will use the DXT5 compression. After downsizing a bigger image to 64x64 pixels, applying a careful "Unsharp mask" may improve the details in the icon before compressing it.


Avoiding mipmap halos

If you decided to use transparency for texture areas with sharp and small details (e.g. hair or leaves), test the appearance with a lower mipmap level by looking at the model in a distance. Even though the texture is "transparent" in a higher resolution, the transparent texture area still contains the information which color would be there if the alpha channel got removed, and that color will get blended into the borders in lower resolutions. Try to set those areas to a dark color (e.g. by storing the alpha channel, filling transparent areas with a dark gray, and applying the saved alpha mask again).

For example, the Nvidia DDS converter "nvdxt" and the Nvidia DDS plugin for Photoshop are able to blend lower mipmap levels against black (default), or against a specific color, while the ATI Compressonator keeps the contained color information in transparent areas.

The more modern "nvcompress" has a nasty habit of filtering the transparency map too, therefore you should avoid using it with a sharpening filter like "Kaiser", or the binary alpha conversion will make the edges look frayed.

Exporting to DDS

If you don't need several levels of transparency, you don't waste color resolution during the DirectX Texture Compression by chosing the variant DXT1 (no transparency) or DXT1a (binary transparency: each pixel is just either opaque or transparent). Only if you need a "ramp" of transparency, use DXT3 (if you expect only few distinct levels, mainly horizontally or vertically) or DXT5 (for interpolated, soft blends).


Dxt trasparency.png


Always create DDS texture files with precalculated mipmaps. If your DDS converter supports dithering, I'd recommend to enable it (it adds slight noise which can avoid banding in wide color ramps, and improves the subjective recognition of an average color).


(Guide provided by LigH)