Code To Detect If BCn (Fallout 4) Format .DDS Has Alpha?

about everything
Post Reply
  • Author
  • Message
Offline
User avatar
*sensei*
Posts: 316
Joined: 12 Aug 2013, 18:55
Location: Scotland

Code To Detect If BCn (Fallout 4) Format .DDS Has Alpha?

Over the past few days, I've been agonizing over the alpha channel of .dds files. Namely, how to detect if one is present or not. And there's been no luck on that front; bad documentation coupled with terse C++ programming libraries. Ergh.

So, I figured I'd ask if anybody here (particularly Boris, ya seasoned veteran) has any idea.

Me reason for asking, is that I've made a wee front end for texconv.exe (from the DirectXTex library), which can be found over here, and the source code for it is over here.

Trouble is, I need to detect if a .dds texture has transparency, and if it does, include the "-pmalpha" string argument when launching texconv.exe.

So yeah. How do I do that? I've tried looking at the DDSTextureLoader code, as well as the source of the Intel Texture Works photoshop plugin, but I can't make heads nor tails of the C++ code.

And fwiw, I'm using C# for the program.
_________________
Intel i7 6700k | AMD Vega 56 8GB | 2x16GB DDR4 @ 3000mhz | Windows 7 64bit | Creative Soundblaster X-Fi Titanium Fatal1ty Pro | Asus z170 Pro Gaming

Offline
User avatar
*blah-blah-blah maniac*
Posts: 17427
Joined: 27 Dec 2011, 08:53
Location: Rather not to say

Re: Code To Detect If BCn (Fallout 4) Format .DDS Has Alpha?

Fourcc name of format definition is in dds header, it what says if alpha exists or not. Some formats include alpha. And some of them are former dxt formats actually.
https://msdn.microsoft.com/en-us/librar ... 85%29.aspx
_________________
i9-9900k, 64Gb RAM, RTX 3060 12Gb, Win7

Offline
User avatar
*sensei*
Posts: 316
Joined: 12 Aug 2013, 18:55
Location: Scotland

Re: Code To Detect If BCn (Fallout 4) Format .DDS Has Alpha?

Woops, sorry for the late reply.

It turns out that the issue wasn't that I did not pass the dds format to texconv, but that Intel Texture Works and Fallout 4 render the resized LDirtPath01 .dds textures' alpha incorrectly, after they've been resized through texconv. NVidia's Windows Texture Viewer & Visual Studio show the .dds just fine, however.

Solution was to pass the -sepalpha argument, which doubles the amount of time taken to resize a texture.

If you're curious, my program's here; https://github.com/MajinCry/Fallout-4-Texture-Resizer


Got another question about the .dds header, though. Is the integer @ +0x0c (the first resolution value) the width or the height of a .dds image? I'm fairly certain it's the height, but I might be wrong 'ere.


And on a completely different note, I remember you mentioning that motherboards play a part in draw call performance. Are server boards (e.g, LGA 2011) better/worse/the same at handling draw calls, compared to mid/high end consumer motherboards? Just curious.
_________________
Intel i7 6700k | AMD Vega 56 8GB | 2x16GB DDR4 @ 3000mhz | Windows 7 64bit | Creative Soundblaster X-Fi Titanium Fatal1ty Pro | Asus z170 Pro Gaming

Offline
User avatar
*blah-blah-blah maniac*
Posts: 17427
Joined: 27 Dec 2011, 08:53
Location: Rather not to say

Re: Code To Detect If BCn (Fallout 4) Format .DDS Has Alpha?

I don't remember if anybody reported performance test results with such motherboards, so can't say.

Format of dds header is described in ddraw.h as i remember (just a struct), it's defined in dx7 sdk (and probably it not changed much from that time), so you can see which values have certain offset.
_________________
i9-9900k, 64Gb RAM, RTX 3060 12Gb, Win7
Post Reply