Skip to content

Commit

Permalink
[Textures] 32 Bit texture support article
Browse files Browse the repository at this point in the history
  • Loading branch information
muczc1wek committed Jun 23, 2024
1 parent c287b6a commit 0242807
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 1 deletion.
57 changes: 57 additions & 0 deletions docs/zengin/textures/32bit_texture.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# 32 Bit texture support

By default ZenGin supports only compresed `DXT1` and `DXT3` textures. [zSurface32 patch](https://worldofplayers.ru/threads/43009/page-3#post-1180504), created by Gratt improves texture quality by adding proper `RGBA8888`, `BGRA8888`, `ARGB8888` and `ABGR8888` format readout and DirectX 32 Bit surface support in ZenGin[^1].

To use the patch you must have [Union](../union/index.md) installed. Download the `.patch` file [here](https://worldofplayers.ru/attachments/114570/), and put it into `/system` directory.

!!! Warning
It is advised to use `BGRA8888` due to performance reasons, as other colorspaces require additional conversion at runtime.

## Compilation

ZenGin doesn’t natively support the compilation of such textures. This can only be achieved using external programs. The simplest method to create a texture is by utilizing [zTEXiPy](https://gitlab.com/Shoun2137/ztexipy).

1. Open your texture in zTEXiPy[^2]:
![zTEXiPy's splash dialog](../../assets/images/STEP_1.WEBP)
2. Choose `Save TEX as...`
3. In this window:
![zTEXiPy's saving dialog](../../assets/images/STEP_3.WEBP)
- Uncheck `Generate Mipmaps` if your texture is meant to be used as UI.
- Set the `Colorspace` to `BGRA8888 (zEnum:3)` or other supported format.
4. Press `Save` and check your texture in-game:
![Ingame Example](../../assets/images/EXAMPLE_INGAME.WEBP)

## But why?

This type of texture is compatible with any asset, whether it’s armour or a sword. However, the primary application for such high-quality textures is in user interface elements, which make extensive use of gradients and the alpha channel:

=== "BGRA8888 vs DXT3"

![Comparison between BGRA8888 vs DXT3 (Alpha)](../../assets/images/EXAMPLE_1.WEBP)

This example shows comparison between raw BGRA8888 colorspace and DXT3 (BC2)[^3] compression.
DXT3 shows noticible banding throughout entire texture wherever there's alpha channel, while BGRA8888 has smooth gradient transition.

=== "BGRA8888 vs DXT1"

![Comparison between BGRA8888 vs DXT1](../../assets/images/EXAMPLE_2.WEBP)

This example shows comparison between raw BGRA8888 colorspace and DXT1 (BC1)[^3] compression.
DXT1 shows lossy quantization artifacts, while BGRA8888 has none.

[Source comparison files are available here.](../../assets/EXAMPLE_SOURCE.7z)

The drawback of using these textures is their large size, as they contain uncompressed color data. However, this is a small price to pay for the improved quality of the final product.

!!! Note
This article was originally written by [Shoun](https://gitlab.com/Shoun2137) and published on [G2O Docs](https://gothicmultiplayerteam.gitlab.io/docs/0.3.0/client-manual/32bit-texture-support/).


[^1]:
To learn more about [ZenGin Textures reference click here](https://zk.gothickit.dev/engine/formats/texture/).

[^2]:
zTEXiPy supports TGA, DDS, PNG and WEBP by default, so make sure it's one of those formats.

[^3]:
To learn more about [DXTn Algorithm click here](https://www.buckarooshangar.com/flightgear/tut_dds.html).
2 changes: 1 addition & 1 deletion docs/zengin/textures.md → docs/zengin/textures/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Here are some tips for working with Gothic textures:
When working with textures in ZenGin, it is recommended to use the default texture format if you are unsure about other options. Many of the other formats are either unsupported or buggy in gothic. For transparency, `DXT3` format should be used. For pure RGB colors, `DXT1` format is recommended.

!!! Tip
Formats like `rgba8888`, `bgra8888`, `argb8888` and `abgr8888` are properly supported with the zSurface32 patch. It is advised to use `bgra8888` due to performance reasons, as other colorspaces require additional conversion at runtime.
Formats like `RGBA8888`, `BGRA8888`, `ARGB8888` and `ABGR8888` are properly supported with the zSurface32 patch. Learn more about it in the [32 Bit texture support](./32bit_texture.md) article.

By default, `.tga` files with a proper resolution are converted to `.TEX` files by the engine, when they appear in the game or a game is started with `-convertall` parameter. Also, you can convert textures to `.TEX` manually using one of the [available tools](#tools).

Expand Down
Binary file added overrides/assets/EXAMPLE_SOURCE.7z
Binary file not shown.
Binary file added overrides/assets/images/EXAMPLE_1.WEBP
Binary file not shown.
Binary file added overrides/assets/images/EXAMPLE_2.WEBP
Binary file not shown.
Binary file added overrides/assets/images/EXAMPLE_INGAME.WEBP
Binary file not shown.
Binary file added overrides/assets/images/STEP_1.WEBP
Binary file not shown.
Binary file added overrides/assets/images/STEP_3.WEBP
Binary file not shown.

0 comments on commit 0242807

Please sign in to comment.