Wednesday, December 24, 2008

How to save your texture?

Exporting a texture

It's always a good idea to work on supersized image, but when the time come to export it as a texture, you have to choose the right size and the right format.



Resizing your image

Choosing the right size of your texture is one of the more important thing in texturing.

If you resize it too small, the texture will look blurry in-game at close range, and even at mid and long range if you shrink it too much. This will look bad, and not realistic.

If you resize it too big, then the texture will look fine everywhere, but it will use too much VRAM (video memory). In case your video card doesn't have enough memory, the texture will be stored in your RAM, hurting your game framerate badly (all textures that are outside the VRAM will be copied through the AGP/PCI port for every screen refresh). However, if your texture can't be seen at close-range, you will never have benefit of such a size, cause only mipmap of your texture will be used. A mipmap is a 2 time smaller texture, used everytime the texture displayed size (in texel) is far too smaller than the original size (in pixel), for performance issue (of course this depends on your actual screen size).
There is no need to have a texture that is always zoomed out in-game compared to its real size, for example, if you run the game at 1280x1024, and you have a 512x512 texture that never take one quarter of your screen, your texture (cycle) will take at best 256x256 pixel of your screen. So it is wise to reduce it to a 256x256 one.

When you have made up your mind, go to your favorite software, resize it and export it.
If you are using Photoshop or The GIMP, always use the bicubic algorithm! Last edition of Photoshop have the bicubic sharpen algorithm that do it very well.

Remember that your texture must be a power-of-2-sized one (look at this post for the why).

Note : Don't worry if resizing a texture to a power-of-2 one wastes the height/width ratio: you just have to set a different X and Y scale for that texture in Radiant ! As you can see in my previous blog post, my painting texture look thin, but in-game, it has a good ratio.

Now you have to choose the right file format.



The TGA format

You should use the TGA format only if you need alpha channels for that texture.

TGA is a non-destructive file format. You will have max quality using this, but in fact, JPEG (at 80% quality) looks the same, but takes 10 times less space most of time.
If you have semi-transparent textures or see-through textures, you must use TGA because of the alpha-channel requirements (too bad PNG-24 isn't handled by Q3).
If you are using Photoshop, save it as 32bits, enable alpha channel, and enable RLE compression (a rough non-destructive compression).



The JPEG format

If you are running Photoshop, don't save with Save As, use Save for Web instead, because filesizes are more optimized (especially for small files).
Disable the progressive checkbox, Q3 doesn't know how to handle progressive jpeg (this feature is only useful for web-browsers, allowing pictures to be displayed with multiple passes, with less blur at each pass).
Enable the optimize checkbox (reduces filesize).
Use a quality of 80%. Never drop quality under 80% because of the famous JPEG artifact! Nobody wants crappy textures! It's useless to use a quality over 80%, you wont see any change, but fileweight will increase drasticly.

1 comment:

  1. This post will have to be updated as PNG is supported in Smokin' Guns 1.1 engine.
    Téquila
    ;)

    ReplyDelete