[Linux] Alpha is broken in DDS files when packed with DXT

rkfgrkfg Russia Join Date: 2013-09-03 Member: 187744Members, Reinforced - Supporter, Reinforced - Silver, Reinforced - Gold, Reinforced - Diamond, Reinforced - Shadow
edited August 2014 in Technical Support
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.
CErWP5f.png
YBlWmTR.png
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, DXT1
Aha! 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

  • MendaspMendasp I touch maps in inappropriate places Valencia, Spain Join Date: 2002-07-05 Member: 884Members, NS1 Playtester, Contributor, Constellation, NS2 Playtester, Squad Five Gold, NS2 Map Tester, Reinforced - Shadow, WC 2013 - Shadow, Retired Community Developer
    As the mod name says, I took two mods and repackaged them, but I can resave as DXT5 (which all ui textures are meant to use) and republish, thanks for letting me know.
  • GhoulofGSG9GhoulofGSG9 Join Date: 2013-03-31 Member: 184566Members, Super Administrators, Forum Admins, Forum Moderators, NS2 Developer, NS2 Playtester, Squad Five Blue, Squad Five Silver, Reinforced - Supporter, WC 2013 - Supporter, Pistachionauts
    DXT1 doesn't support a alpha channel and therfore generates smaller files than DXT5. So yeah DXT1 was the issue ;)

    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
  • DC_DarklingDC_Darkling Join Date: 2003-07-10 Member: 18068Members, Constellation, Squad Five Blue, Squad Five Silver
    so basicly the mod sucked... :D
  • rkfgrkfg Russia Join Date: 2013-09-03 Member: 187744Members, Reinforced - Supporter, Reinforced - Silver, Reinforced - Gold, Reinforced - Diamond, Reinforced - Shadow
    Mendasp wrote: »
    As the mod name says, I took two mods and repackaged them, but I can resave as DXT5 (which all ui textures are meant to use) and republish, thanks for letting me know.
    Does it mean that you don't experience the described issue? That's interesting because
    DXT1 doesn't support a alpha channel and therfore generates smaller files than DXT5. So yeah DXT1 was the issue ;)
    ...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.
  • MendaspMendasp I touch maps in inappropriate places Valencia, Spain Join Date: 2002-07-05 Member: 884Members, NS1 Playtester, Contributor, Constellation, NS2 Playtester, Squad Five Gold, NS2 Map Tester, Reinforced - Shadow, WC 2013 - Shadow, Retired Community Developer
    Updated. I guess I need to update a few more crosshair mods I have out there that used this combination.
  • JaitoJaito Spain Join Date: 2015-04-10 Member: 203216Members
    http://cgit.freedesktop.org/~mareko/libtxc_dxtn/

    And, ejecute in command line with:
    force_s3tc_enable=true [your gl_program]

    or:
    export force_s3tc_enable=true


Sign In or Register to comment.