Home Technical Talk

DDS Texture file format, Alpha problems

polycounter lvl 17
Offline / Send Message
W1r3d polycounter lvl 17
Hi

I've been doing some backdrop trees for a project. We will be using DDS textures for our 1bit alphas. We won't be using the .tga format. Since according to our programmer you can't tell if it's 1bit or interpolated alpha using a .tga format. Codewise that is. Now i've been trying a series of different settings using nvidias DDS format. All i get is a huge black outline on my backdrops. Like someone went in with a black magic marker and made thick thick outlines.

Here is the colormap for the backdrop:
Trees.jpg

And here is how the alpha channel looks:
Trees_a.jpg

Now the funny thing is that when i'm looking at the file through the small thumbnail. The background looks black!
I've checked and checked again when i save the file. In the DDS preview window, both 2D and 3D preview. It does NOT! have a black background. I've serched Nvidias Page for any solution but i havn't found any. Read through a lot of documentation but havn't found any.

Replies

  • vik
    Offline / Send Message
    vik polycounter lvl 13
    195jzd.jpg

    >> that`s waht I`d use if it`s 1bit alpha

    If you already tried that, please ignore :)
  • W1r3d
    Offline / Send Message
    W1r3d polycounter lvl 17
    Yes, i have tried it.
    Thank you vik for your reply :)
  • Farfarer
    We had an issue with this on an engine at my last job and had a similar problem - even making the background of the image a different colour, it still left a black outline around 1bit alpha'd textures.

    As it happened, it was an issue with the way the engine processed the textures and it actually made the transparent alpha area black in the RGB channels. Sadly we didn't get a workaround for it and just had to put up with it best we could :/
  • W1r3d
    Offline / Send Message
    W1r3d polycounter lvl 17
    Talon: How did you figure out that the problem was the way the engine processed the images? A bit more information on that would be awsome.

    Thank you for your reply Talon
  • Jeremy Lindstrom
    Offline / Send Message
    Jeremy Lindstrom polycounter lvl 18
    I usually use DXT3 or DXT5 for alpha's.

    (yup was a screen grab)...
  • Farfarer
    W1r3d wrote: »
    Talon: How did you figure out that the problem was the way the engine processed the images? A bit more information on that would be awsome.

    Thank you for your reply Talon
    Haha, we asked the developers if they knew what the issue was :P
  • W1r3d
    Offline / Send Message
    W1r3d polycounter lvl 17
    Using DXT5 isn't really helping me since it uses an interpolated alpha and since i don't want the engine to alphasort my backdrops i have to use a 1bit alpha.

    Dekard: Is that a viewport grab? My trees looks like that in Maya. no black outlines there. It's only when i load them into the engine.
  • W1r3d
    Offline / Send Message
    W1r3d polycounter lvl 17
    Talon: hehe, ok.
  • funshark
    Offline / Send Message
    funshark polycounter lvl 16
    I'm pretty sure you can't assign a background color into DXT1 textures.
    I've had the same problem here so I've done some investigations...

    The black outline is black because of your world background which is surely black too.
    Others colors can appear too, depending of the 3D engine and objects which are behind your transparent one...

    In most cases, it is a sorting problem ( objects with objects ).
    Your developers have to code a better sorting function here.
  • W1r3d
    Offline / Send Message
    W1r3d polycounter lvl 17
    funshark: In cases where you have to alphasort your alpha objects this can surely happen. However as i mentioned above. We are using a 1bit alpha and are in noo need of sorting our alpha objects. I also checked to see if you were indeed right. So i asked the programmer what color the background was in the engine. Apparently it is grey. The outline i'm getting is black. Maybe it could still be related but it seems doubtfull. However my conclusions so far is that:

    A)
    Textures using 1bit or explicit alpha will render the areas with 0-alpha as a default black background. Discarding any color information in order to be able to compress the texture more.

    B)
    The engine processes the texture in some strange way. My reasoning here is that it either destroys the current mips and creates it's own. And that it there defaults the 0-alpha areas of the background color to black.

    What would be very intressting would be to se if there are any other game engines out there who actually uses the DDS format for their texture. I don't think i've actually modded for one that has.

    Thank you Funshark for your reply :)
  • W1r3d
    Offline / Send Message
    W1r3d polycounter lvl 17
    Ok, we have solved the problem ingame. But it's the same right now in the converter. i'm still kinda puzzled about how exactly it was solved. So Option B) is most likely the culprint. I'll see if i can post more about how exactly we solved it.
  • warby
    Offline / Send Message
    warby polycounter lvl 18
    i have known this problem for a long time.
    if you import a 1 bit alpha texture into unreal3 it doesn't cause this problem for some reason and i figure its saved it as a 1 bit dds inside the unreal packages so there can be engine side solutions to the problem !
    the problem indeed is that it will turn all the alpha areas black in the r g and b channels probably for extra compression efficiency and i am also sure that you cant tell the nvidias plugin to do something else.

    so figure out an engine side solution

    or

    make two textures a no alpha dxt1 texture and a 2 bit 1 Chanel texture and tell it via the shader to use that as the alpha
  • funshark
    Offline / Send Message
    funshark polycounter lvl 16
    A)
    Textures using 1bit or explicit alpha will render the areas with 0-alpha as a default black background. Discarding any color information in order to be able to compress the texture more.

    B)
    The engine processes the texture in some strange way. My reasoning here is that it either destroys the current mips and creates it's own. And that it there defaults the 0-alpha areas of the background color to black.

    What would be very intressting would be to se if there are any other game engines out there who actually uses the DDS format for their texture. I don't think i've actually modded for one that has.

    Thank you Funshark for your reply :)

    Our engine ( DirectX based ) uses DDS principaly and i can affirm you it was a sorting issue. Because developers have corrected the problem.
    If the sorting is correctly done, you don't see any border on your alpha.

    Then, I've never seen a background color ( other than black ) in a DXT1 DDS; created with the ATI or Nvidia plugin. If someone has succeeded in this task, please tell me :)
  • W1r3d
    Offline / Send Message
    W1r3d polycounter lvl 17
    Warby: actually there is an option that handles the mipmap compression which you can affect. Under mipmap options in the Nvidia plugin you can see the option Alpha modulate. If left checked your mips will have black areas instead of color. But if you uncheck it you will get color instead of black. I have these 2 pictures to show my point.

    AlphaModulateOff.jpg

    AlphaModulateOn.jpg

    And if you wan't to do something special to any of your miplevels. You can just load the DDS into Photoshop and check the option 'Load Mipmaps'.
  • W1r3d
    Offline / Send Message
    W1r3d polycounter lvl 17
    funshark: yes i agree if the sorting is done correctly you don't see any border at all. However that is assuming you have to do any sorting in the first place. The problem here was that the converter it did 2 light checks instead of 1. So first applied was a ambient which was pretty dark. Then on top of that there was a directional light applied which had a much higher lightvalue. The directional light also creates a "shading" of the alpha using the 1bit alpha as reference. So you get kind of a gradient around the edges. And that is where the much darker ambient light was shining through. So since they were not blending with each other it was like 2 different layers. One which was darker then the other. So the result of it shining through where the directional light was blending was the dark outline.

    Phew... :)
    Problem solved and much learned.
    Thank you everyone who has replied to this thread :D

    *edit*
    Found some more intressting information about DDS compression.
    Enjoy the reading: http://developer.nvidia.com/object/real-time-normal-map-dxt-compression.html
Sign In or Register to comment.