[Linux] Alpha is broken in DDS files when packed with DXT
rkfg
Russia Join Date: 2013-09-03 Member: 187744Members, Reinforced - Supporter, Reinforced - Silver, Reinforced - Gold, Reinforced - Diamond, Reinforced - Shadow
The story is simple, I wanted to try a new crosshair, namely "Wilson's White Dot + Skie's Hit Indicator Crosshair" by @Mendasp, and it looked nice. But when I shoot something or someone, the red version of the crosshair was displayed with an ugly semitransparent black square around it.
I liked the mod and this was annoying so I decided to dig into the issue. The stock crosshairs work fine, there must be something different with the modded ones. I used the "file" command to get some info about them.
Stock:
I liked the mod and this was annoying so I decided to dig into the issue. The stock crosshairs work fine, there must be something different with the modded ones. I used the "file" command to get some info about them.
Stock:
crosshairs.dds: Microsoft DirectDraw Surface (DDS), 64 x 1024, crosshairs-hit.dds: Microsoft DirectDraw Surface (DDS), 64 x 1024,Modded:
crosshairs.dds: Microsoft DirectDraw Surface (DDS), 64 x 1024, crosshairs-hit.dds: Microsoft DirectDraw Surface (DDS), 64 x 1024, DXT1Aha! And that was it. I installed a gimp-dds package, opened the crosshairs-hit.dds file and saved it without the DXT1 compression. Now it works as expected, clear and nice. But of course this should work out of the box without any manipulations, I tried another crosshair mod months ago and it had even the normal crosshair with a completely opaque black square around it. Now I can guess it had DXT1 compression for the main file, not only for the hit.
Comments
More about DXT can be found at Wikipedia: http://en.wikipedia.org/wiki/S3_Texture_Compression
BTW 268 will include a new version of nvcompress which is alot faster and works also at pcs without cuda installed.
Also the overall rule for dds files in ns2 is:
Has alpha channel? -> use DXT5
Has no alpha channel? -> use DXT1
...if it doesn't support alpha channel then why GIMP opens it with alpha enabled and lets it be resaved with it properly? I mean, if there was no alpha, the background should be black or white but it was absolutely transparent. I couldn't find the difference until I file'd all those files. If you don't have black boxes with DXT1-compressed textures, it can only mean that DXT1 is handled differently on Windows OR the Direct3D version of the engine versus the OpenGL one. Maybe blending shaders differ? It's pretty simple to blend the crosshair texture so that black is transparent, it's called additive blending I suppose.
And, ejecute in command line with:
force_s3tc_enable=true [your gl_program]
or:
export force_s3tc_enable=true