Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Textures] New index and 32 bit texture support article #124

Merged
merged 6 commits into from
Aug 4, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions docs/zengin/textures.md

This file was deleted.

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].
muczc1wek marked this conversation as resolved.
Show resolved Hide resolved

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.
muczc1wek marked this conversation as resolved.
Show resolved Hide resolved

## 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.
kamilkrzyskow marked this conversation as resolved.
Show resolved Hide resolved
4. Press `Save` and check your texture in-game:
![Ingame Example](../../assets/images/EXAMPLE_INGAME.WEBP)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In-game

Also modify the images that are too big with attr_list.
Example from Union Getting Started {: style='min-width: 0;' }
Or something similar

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which images are too big?

Copy link
Collaborator

@kamilkrzyskow kamilkrzyskow Jul 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I missed this notification, probably got merged with the other message.

Which images are too big?

Those that take up too much vertical sapce on my 1080p monitor and don't have fine details that require the bigger size🤔So this is yet another subjective issue hmm. So you can keep the sizing for now as is. I'll think about a more general CSS change, as currently the issue is the min-width: 75% in the .md-content img override. Small images explode in size to keep the aspect ratio.

If you want, you can also play around with it, removing that min-width, and replace it with a combination of min-height, max-height using rem values. Like:

min-height: 8rem;
max-height: 20rem;

but perhaps there is no optimal solution for this, and some images will still have to be adjusted with attr_list.
If you decide to change the CSS, be sure to check other pages with images like C_ITEM, VDPS, Spacer 👌


## 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)
muczc1wek marked this conversation as resolved.
Show resolved Hide resolved

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.
muczc1wek marked this conversation as resolved.
Show resolved Hide resolved

=== "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)
muczc1wek marked this conversation as resolved.
Show resolved Hide resolved

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).
70 changes: 70 additions & 0 deletions docs/zengin/textures/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Textures

Textures are pictures that get projected onto 3D models and on a 2D user interface in the game. ZenGin uses its own texture format `.TEX`, that in fact is a container for the texture in one of available formats. This section will discuss how to work with textures in ZenGin.
muczc1wek marked this conversation as resolved.
Show resolved Hide resolved

!!! Note
Technical documentaion of the `.TEX` texture format can be found in the [ZenKit documentaion](https://zk.gothickit.dev/engine/formats/texture/).
muczc1wek marked this conversation as resolved.
Show resolved Hide resolved

## Basics

All created textures have to be located in the `_WORK\DATA\TEXTURES\` directory. The compiled `.TEX` files are saved in the `_COMPILED\` subdirectory.

Here are some tips for working with Gothic textures:

- Textures must have dimensions that are multiples of 4.
- Square textures (with some exceptions, like faces or some interface elements) are preferred for easier mipmap generation.
- It is recommended not to use textures bigger than 4096x4096.
- Avoid things like `_V0`, `_A1` etc. in the texture name endings, as suffixes like this are used for [multitextures](multitextures.md).

## Formats

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. Learn more about it in the [32 Bit texture support](./32bit_texture.md) article.

## Mipmaps

[Mipmaps](https://en.wikipedia.org/wiki/Mipmap) are pre-generated versions of textures at different levels of detail. They are used, to improve rendering performance and reduce aliasing artifacts. When engine converts the texture it automatically generates mipmaps. Other tools may handle it differently, so it's better to check it before conversion.

!!! Example "How it works?"
If you want to learn more about mipmaps in ZenGin there is a [great article](https://www.gothic-reloaded-mod.org/en/blog/more-than-a-texture-patch-2) by Gothic Reloaded Mod Team.

## Engine compilation

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).
kamilkrzyskow marked this conversation as resolved.
Show resolved Hide resolved

The engine compilation may be affected by keywords in the texture name or directory.

**Color depth**

Textures are compiled by default with a color depth of 16 bits per pixel and needs 4 bits of memory per pixel. To force the engine to convert textures with a different color depth, you need to add an ending to the name of the texture or directory `_16BIT` or `_32BIT`. Using 16/32 bit images makes sense when there are visual problems or noise after compression, but they take up more memory.

Example: `_WORK\DATA\TEXTURES\SKY\NOMIP_16BIT\CLOUDS.TGA`.

**nomip**

By default, [Mipmaps](#mipmaps) are generated for all textures. However, if the texture path contains the directory `nomip`, then a Mipmap will not be created for such a texture. It makes sense to use if you experience visual problems or interference associated with the use of Mipmaps, and also to save memory if the texture is rarely used in the game, or the texture is too small.

Example: `_WORK\DATA\TEXTURES\EFFECTS\NOMIP\LIGHTNING.TGA`

## Tools
There are some tools created by the Gothic community, that simplify working with ZenGin textures.

### GoMan
Oldest texture tool, created by PyroX. Has a good viewer, but there are already better alternatives.

[:octicons-download-16: Download](https://www.worldofgothic.de/dl/download_97.htm)

### GoTex
Simple converter, written by [ThielHater](https://forum.worldofplayers.de/forum/members/52111-ThielHater?). Implements features like custom mipmaps and popular image formats support.

[:material-forum: Thread on WoG](https://forum.worldofplayers.de/forum/threads/1601349-Tool-GoTex)

[:fontawesome-brands-github: GitHub](https://github.com/ThielHater/GoTex)

### zTEXiPy
Latest tool, developed by [Shoun](https://gitlab.com/Shoun2137). Offers batch conversion, an intuitive viewer, and Windows context menu shortcuts.

[:fontawesome-brands-gitlab: GitLab](https://gitlab.com/Shoun2137/ztexipy)

23 changes: 23 additions & 0 deletions docs/zengin/textures/multitextures.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Multitextures

Multitextures are used, for example, to create animation. For example, rippling water is represented by a sequence of textures `WATER_A0.TGA` that can be applied to 3D geometry. Also in Gothic, multitextures are used to replace the texture of a character's body.

## Naming convention

The naming convention for multitextures is as follows:
```
NAME_[Letter0][Number0]_..[LetterN][NumberN].TGA
```

Example: `HUM_HEAD_HAIR1_C0_V0.TGA`

In this way, multitextures are interconnected. The format is used exclusively for creating multitextures. Therefore, a name like `w_s2_v1.TGA` to name only one texture is not allowed. The engine handles incorrect names, but not quickly.

## Body textures

Multitextures used for the body use two channels:

- V - for skin variation
- C - for skin tone

For example, the texture `Hum_Body_Naked_V2_C3.tga` describes the body of a person without armor, variant 2, and skin tone 3 (Dark-skinned). Setting up specific character texture variations is determined in the script.
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.