| 25 | |
| 26 | == Mipmaps == |
| 27 | |
| 28 | Graphics hardware can't resize textures downwards (e.g. when zooming out) with high quality, so we pre-compute scaled versions and store them as mipmaps. Textures that are never scaled down (e.g. GUI elements) should not have mipmaps, to save space. |
| 29 | |
| 30 | There are many ways to do the resizing, with effects on the sharpness of the textures when zoomed out. The [http://code.google.com/p/nvidia-texture-tools/wiki/ResizeFilters NVIDIA Texture Tools page] gives examples of different filtering methods and of gamma-correction. |
| 31 | |
| 32 | == Automatic texture conversion == |
| 33 | |
| 34 | Artists should save and upload textures in PNG format, and the game engine will automatically perform the mipmapping and compression and will cache the result so that it can load quickly next time. This allows us to losslessly edit the textures and tweak the conversion settings, and avoids problems with textures being manually exported with the wrong settings. |
| 35 | |
| 36 | The texture conversion settings are specified in `textures.xml` files. For example, `art/textures/ui/global/button/textures.xml` might say: |
| 37 | {{{ |
| 38 | <?xml version="1.0" encoding="utf-8"?> |
| 39 | <Textures> |
| 40 | <File pattern="*" format="dxt5" mipmap="false" alpha="transparency"/> |
| 41 | <File pattern="button_wood.*" format="rgba"/> |
| 42 | </Textures> |
| 43 | }}} |
| 44 | Each `<File>` line matches some filenames, and applies certain settings to them. If a filename matches multiple lines, later settings will override earlier settings. The `textures.xml` file applies to all files in the same directory, ''and'' in all subdirectories - e.g. you can specify some common default settings in `art/textures/ui/textures.xml` for all UI textures, then override them with specific settings in subdirectories. |
| 45 | |
| 46 | `pattern="..."` determines which filenames are matched by that line. The pattern can include wildcards: `?` matches any character, `*` matches any sequence of zero or more characters. |
| 47 | |
| 48 | The available settings are: |
| 49 | * `format="rgba"` |
| 50 | * `format="dxt1"` |
| 51 | * `format="dxt3"` |
| 52 | * `format="dxt5"` |
| 53 | * `mipmap="true"` |
| 54 | * `mipmap="false"` |
| 55 | * `alpha="transparency"` |
| 56 | * `alpha="player"` |
| 57 | * `filter="box"` |
| 58 | * `filter="triangle"` |
| 59 | * `filter="kaiser"` |
| 60 | * `kaiserwidth="3.0" kaiseralpha="4.0" kaiserstretch="1.0"` |