Skip to content

normalmap compressed with crunch -dxn are loaded with reverted B channel #183

@illwieckz

Description

@illwieckz

This bug was uncovered in #180.

All our normal maps are compressed with crunch -dxn and our engine loads them with reverted blue channel (Z component). This was hidden by the bug in the normalmap code that was loading the Z component from alpha channel instead of blue one. Hopefully we did not ship any heightmap in alpha channel and since crunch -dxn drops the alpha channel in any way, it looks like the engine was just using an empty Z component). The normalmap loads correctly if loaded from another format (like webp).

With r_normalMapping disabled:

dpoffsetmapping

With r_normalMapping enabled and normal map compressed with crunch -dxn:

dpoffsetmapping

With r_normalMapping enabled and normal map compressed with crunch -dxn and Z component reverted in engine to workaround the bug:

dpoffsetmapping

With r_normalMapping enabled and normal map compressed with webp:

dpoffsetmapping

The source tree in #180 is meant to be correct. I created a test map with assets I created to be sure they are the way they must be, then fixed the engine to render the test map. The correct engine in this tree is able to render correctly xonotic maps and unvanquished maps if their normal maps were not compressed with crunch -dxn.

We need someone to fix the normalmap loading when they are compressed with dxn (use the branch in #180 branch as a base as master is not correct).

The symptom is a map being almost entirely dark. No need for special map to reproduce the bug, just load released chasm with this branch (or any other map):

dpoffsetmapping

It may be possible that the whole normalmap is reverted, reverted red (X) and reverted green (Y) leads to subtle changes while reverted blue (Z) just break everything.

I'll upload the test map soon but testing with released maps is enough to reproduce the bug. The test map will be useful to check that the bug is entirely fixed. While it's very easy to check for the correct loading of the blue channel with any released map, it may be very difficult and time-consuming to check for the correct loading of red and green channel without the test map.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions