1. This forum is obsolete and read-only. Feel free to contact us at support.keenswh.com

DX11 DDS files, "Invalid image file header"

Discussion in 'Modding' started by Rhedd, Dec 2, 2015.

Thread Status:
This last post in this thread was made more than 31 days old.
  1. Rhedd

    Rhedd Trainee Engineer

    Messages:
    50
    So I'm at the texturing stage now, thanks to a lot of help from Digi, Tristavius, and Harag, and I'm running into yet another snag that I think I can blame on Keen...

    When I try to use a vanilla texture in 3DStudio Max, I get an error saying "Invalid image file header" on all *_add, *_cm, and *_ng files. *_me and *_ns files work fine.

    The same holds true for trying to look at the textures in Photoshop using the Nvidia DDS plugin. All of the listed invalid files are just black with green lines (clearly not loading), while the two types that work in 3DS load fine in PS.

    I tried loading some *_cm (*_add, etc.) files from popular mods I have, as well, and almost all of them have the same problem, but if I pick a mod that I KNOW was created very recently, after the release of DX11, all of the textures load fine. This had led me to believe that I'm having problems with DDSs that were run through Keen's converter, and they aren't being made with the proper file headers to open in anything other than the game itself.

    Anyone have any insights? Is this a common problem?
     
  2. Harag

    Harag Junior Engineer

    Messages:
    913
    The .dds format has a lot of subformats. Each new version of DirectX can add more. Most software that reads or writes .dds files only supports the subformats that were introduced up to and including DirectX 9. Keen uses the BC7 subformat for their DirectX 11 textures because it has superior image quality compared to older formats. From my link you can see that BC7 is a DirectX 11 level feature so support in other software isn't very widespread (even though DirectX 11 has been around for a while now).

    Another new thing in DirectX 10 is that the format of the file-header changed from using Four-Character-Codes (FourCC) to something Microsoft calls DXGI header which has extended information on the pixel format of the file. This is what trips up 3DSMax and Photoshop (and Gimp). Were it not for the new header format you would probably see some error message similar to "The file format 'BC7' is not supported".

    You are not required to use BC7 or the new header format, however - that's why you are able to find mods where the textures for SE's Dx11 renderer can be opened and viewed with Photoshop. But you loose some image quality if you don't use BC7 and you can't include colorspace information (sRGB or linear) if you don't use the new header format. The latter might lead to the problem that textures look darker in-game than intended.

    If you just want to view those textures I recommend PicoPixel which can view any .dds subformat there currently is.
    If you want to edit the textures you can use Microsoft's texconv command-line tool to convert them from .dds back to another format like .png. Just keep in mind that .dds compression is lossy, so round-trip conversions (dds png dds) loose some image quality even if you don't edit the .png. Keep the .png (or whatever) if you plan to make further changes in the future and only convert to .dds as a final step to get the textures into the game.

    texconv is also the tool of choice if you have true PBR textures. Keen's texture converter is simply not capable of converting those. Personally, I use two different settings to convert the textures depending on the phase of my texturing workflow I'm in. As long as I'm still working on the textures I leave the .dds files uncompressed because compressing as BC7 takes too damn long for a quick check how a texture looks in-game:

    Code:
    texconv -f R8G8B8A8_UNORM_SRGB -sepalpha Hatch_cm.tga
    texconv -f R8G8B8A8_UNORM -sepalpha Hatch_ng.tga
    texconv -f R8G8B8A8_UNORM_SRGB -sepalpha Hatch_add.tga
    
    texconv -f BC3_UNORM -fl 9.1 -sepalpha Hatch_de.tga
    texconv -f BC3_UNORM -fl 9.1 -sepalpha Hatch_ns.tga

    Note that only the _cm texture is in sRGB colorspace because that's the only one that has real color information where perception with the human eye benefits from the modified intensity distribution of sRGB. The _de texture has no way to store colorspace information so as far as I know SE always assumes it's in sRGB. Also note that you need to tell texconv to treat the alpha channel separate from the RGB channels via -sepalpha. Otherwise texconv will "optimize" the .dds and you'll get black RGB channels where the alpha is 0. Especially with _cm and _add textures this can easily happen.

    I only compress to BC7 once I'm satisfied with a texture:

    Code:
    texconv -f BC7_UNORM_SRGB -if TRIANGLE_DITHER_DIFFUSION -sepalpha Hatch_cm.tga
    texconv -f BC7_UNORM -if TRIANGLE_DITHER_DIFFUSION -sepalpha Hatch_ng.tga
    texconv -f BC7_UNORM_SRGB -if TRIANGLE_DITHER_DIFFUSION -sepalpha Hatch_add.tga
    
    texconv -f BC3_UNORM -fl 9.1 -sepalpha Hatch_de.tga
    texconv -f BC3_UNORM -fl 9.1 -sepalpha Hatch_ns.tga
    Only here it makes sense to apply an image filter. You don't need to filter uncompressed RGB because it's already pixel-perfect in comparison to the source image.
     
    Last edited: Oct 31, 2016
    • Informative Informative x 2
  3. Rhedd

    Rhedd Trainee Engineer

    Messages:
    50
    Man, modding for this game needs a few more undocumented hurdles! Maybe two or three more command-line programs would help smooth things along, too... >_>

    Anyway, thanks Harag! I love your answers because they're so complete. You give every bit of information that anyone would need, including hotlinks, and that's great!

    I've been working with DDS files since they first started being used so I'm familiar with the different flavors, but I usually get them IN to games. Guess I'm surprisingly inexperienced when it comes to getting them back out again. Of course, with no official documentation (that I've seen) explaining what format Keen uses or expects, it's pretty hard to guess what the problem might be, and this is the first game I've seen that uses non DX9-compatible textures, anyway.

    Crazy that 3DS Max 2016 (that's SIXTEEN) still doesn't recognize modern DDS types!

    Your help should solve my problems, though. I'm mostly interested in just being able to sample official textures so my metal looks like their metal, etc., but your post saved me a number of other frustrations that I was obviously going to run into down the road. Thanks again!

    One last question, does Blender recognize BC4-7 formats? If not, how does anyone use a vanilla texture in a modded material, since 3DS Max simply won't allow me to load it.
     
  4. Harag

    Harag Junior Engineer

    Messages:
    913
    Nope, Blender can't read BC7, either. But as long as the file-path is correct that's not a problem.
     
  5. Rhedd

    Rhedd Trainee Engineer

    Messages:
    50
    Cool, thanks!
     
  6. Tristavius

    Tristavius Senior Engineer

    Messages:
    1,368
    Wow, there was a hell of a lot there I didn't know too, or at least didn't think I needed to consider. I confess, I'm still just throwing everything into DXT5 as it works. Since Windows 10 upgrade it also seems to be more shell integrated with previews showing directly from the folders etc. Unfortunately BC7s seem to have no tools to work with them.... Not GIMP, not Photoshop, not Substance Designer. Hope that changes one day!

    I also highly recommend PicoPixel as above... it's extremely basic in what it can do except for one fact: It opens anything. Seriously, never had it refuse to open something before.
     
  7. Jaken Veina

    Jaken Veina Apprentice Engineer

    Messages:
    134
    Are the benefits of using BC7 really that great, as opposed to DXT3 or DXT5?
     
  8. Harag

    Harag Junior Engineer

    Messages:
    913
    That depends entirely on the quality and detail of the source image. Here is an interesting article on the topic (it only talks about BCn compression; DXT5 ≡ BC3).

    Then again, you are asking "why?". I'm asking "why not?". It doesn't take that much time if you only compress your final textures (see my post above).
     
    Last edited: Feb 1, 2016
  9. KKthebeast

    KKthebeast Trainee Engineer

    Messages:
    1
    I know this is an Old thread I hope this is helpful, But someone created a viewer to replace the stock one in 3ds Max 2013 for BC7+ (dx10+) https://www.nexusmods.com/fallout4/mods/20540/? Allows you to select and view BC7 Diffused, Normal, Spec
     
Thread Status:
This last post in this thread was made more than 31 days old.