Skip to content

radiant: redo 60113678 (!102), fix alpha channel for tRNS cheap transparency PNG

Thomas Debesse requested to merge illwieckz/netradiant:fixpng into master

This is just !102 (merged) redone, the fix seems to have been lost when doing !116 (merged).

Basically, netradiant was displaying wrongly some transparent textures, those with cheap transparency stored in tRNS.

If your some of your translucent png textures looked like this, you were facing this bug:

netradiant png cheap transparency

netradiant png cheap transparency

netradiant png cheap transparency

netradiant png cheap transparency

The PNG specification has more than 15 format variants, about 9 for format with transparency. The compression efficiency of PNG does not really comes from the compression algorithm which seems to not have any picture-specific algorithm (it's just zlib) but from that panel of format variants an optimizer can leverage.

As seen on the screenshot, I made a special map to test those PNG formats, the map can be found there: https://github.com/UnvanquishedAssets/UnvanquishedTestAssets/tree/master/src/map-test-pngalpha_src.dpkdir

The map can also be used to test PNG support in q3map2, and a game renderer.

Thanks to alphashadow feature, we can test q3map2 is reading properly the PNG alpha channel by casting shadows this way:

netradiant png cheap transparency

netradiant png cheap transparency

netradiant png cheap transparency

netradiant png cheap transparency

netradiant png cheap transparency

To test the engine, and help to test q3map2, the textures are displayed two time in game, with a proper blend (true alpha channel), or with a GE128 function to look like what q3map2 proceeds for real when casting shadows:

netradiant png cheap transparency

netradiant png cheap transparency

Edited by Thomas Debesse

Merge request reports