TGA image supporting applications

Post anything to do with editing Nexuiz here. Whether its problems you've had, questions, or if you just want to show off your work.

Moderators: Nexuiz Moderators, Moderators

Wed Oct 08, 2008 1:40 pm

  • This test was made to understand which applications create and save transparent and semi transparent TGA files correctly so no fixtrans is required. I tested image with opaque borders, transparent background and semi transparent brushes. PNG version:
    Image

    Paint.NET:
    Transparency is saved correctly, header is always saved wrong.

    GIMP:
    Transparency is saved correctly, header is preserved from already existing file (do not fix wrong one) or if the new file is created by GIMP, correct header is appended.

    ImageMagick:
    Preserves header (do not fix wrong one).

    XnView:
    Fixes and writes correct header.

    IrfanView:
    Fixes and writes correct header.

    ArtGem:
    Always writes wrong header. Transparency is saved correctly.

    Painter X:
    Transparency and header are saved correctly.

    Photoshop CS4:
    Always writes wrong header. Didn't know any convenient way to get semi transparent images working.


    Addtional notes:
    Fixtrans seems to mess RGB color space. It is seen both in XnView and Painter X.
    RGB color space in Painter X:
    Image
    RGB color space after fixtrans'ed conversion:
    Image

    Need to look at it deeper, though.
    Alien
    Forum addon
     
    Posts: 1212
    Joined: Tue Apr 22, 2008 7:12 am

Wed Oct 08, 2008 1:47 pm

  • Exactly that is fixtrans's purpose. Many applications simply store black (or another color you do not want, or a color that once was there before) in unallocated pixels, or do not allow changing the color of fully transparent pixels without having to make them nontransparent first.

    However, the resampling algorithms used in the graphics cards linearily interpolate BOTH alpha AND RGB data. So a pixel with alpha value 0 still has influence when a neighbor pixel has alpha larger than 0. This tends to cause weird borders around images. This problem gets even worse when the engine creates mipmaps, because that uses the exact same algorithm.

    The only thing fixtrans does is replacing the RGB color of alpha 0 pixels by some pixel nearby, keeping alpha at 0, so the artifacts from the wrong resampling (that all GPUs, and DP use, because it is much faster than doing it right) disappear.

    So the "RGB color space" of your test image is actually wrong: the grey part of your figure has black alpha-zero pixels surrounding it, which causes black outline artifacts when rendering. Fixtrans is there to fix exactly that.

    That fixtrans also converts from PNG to TGA, or writes good TGA headers, is merely a side effect.
    1. Open Notepad
    2. Paste: ÿþMSMSMS
    3. Save
    4. Open the file in Notepad again

    You can vary the number of "MS", so you can clearly see it's MS which is causing it.
    User avatar
    divVerent
    Site admin and keyboard killer
     
    Posts: 3809
    Joined: Thu Mar 02, 2006 4:46 pm
    Location: BRLOGENSHFEGLE

Wed Oct 08, 2008 2:24 pm

  • Test image is wrong, cause I tested TGA not PNG file. This is merely a converted TGA into PNG (converter was bad then).
    Here, are 2 files which I compared. Both are reported as good in fixtrans. Yet, RGB is shown as different. So maybe fixtrans do not detect smth then:
    http://www.mediafire.com/?ftimgtsk85f
    http://www.mediafire.com/?zitdm30dm42

    divVerent wrote:Exactly that is fixtrans's purpose. Many applications simply store black (or another color you do not want, or a color that once was there before) in unallocated pixels, or do not allow changing the color of fully transparent pixels without having to make them nontransparent first.

    However, the resampling algorithms used in the graphics cards linearily interpolate BOTH alpha AND RGB data. So a pixel with alpha value 0 still has influence when a neighbor pixel has alpha larger than 0. This tends to cause weird borders around images. This problem gets even worse when the engine creates mipmaps, because that uses the exact same algorithm.

    The only thing fixtrans does is replacing the RGB color of alpha 0 pixels by some pixel nearby, keeping alpha at 0, so the artifacts from the wrong resampling (that all GPUs, and DP use, because it is much faster than doing it right) disappear.

    So the "RGB color space" of your test image is actually wrong: the grey part of your figure has black alpha-zero pixels surrounding it, which causes black outline artifacts when rendering. Fixtrans is there to fix exactly that.

    That fixtrans also converts from PNG to TGA, or writes good TGA headers, is merely a side effect.


    Why does it matter which colour fully transparent pixel uses? If it is fully transparent, you can't see it anyway. Or is it something wrong in graphic cards that neighbour pixel color has an effect? How does artifacts disappear using wrong resampling?
    Last edited by Alien on Wed Oct 08, 2008 3:27 pm, edited 3 times in total.
    Alien
    Forum addon
     
    Posts: 1212
    Joined: Tue Apr 22, 2008 7:12 am

Wed Oct 08, 2008 3:16 pm

  • Sure, fixtrans is not even trying to do that, I told you what it DOES.
    1. Open Notepad
    2. Paste: ÿþMSMSMS
    3. Save
    4. Open the file in Notepad again

    You can vary the number of "MS", so you can clearly see it's MS which is causing it.
    User avatar
    divVerent
    Site admin and keyboard killer
     
    Posts: 3809
    Joined: Thu Mar 02, 2006 4:46 pm
    Location: BRLOGENSHFEGLE

Wed Oct 08, 2008 3:17 pm

  • EDITED above post. And yet shouldn't fixtrans fix it too?
    Image
    Alien
    Forum addon
     
    Posts: 1212
    Joined: Tue Apr 22, 2008 7:12 am

Wed Oct 08, 2008 3:33 pm

  • Fix what? What is broken? It can't make stuff transparent that isn't. That was never its purpose.

    And yes, GPUs DO use the wrong algorithm when interpolating, which fixtrans is meant to fix.

    E.g.

    Pixel (0,0) = (red, alpha=1)
    Pixel (1,0) = (red, alpha=1)
    Pixel (0,1) = (red, alpha=1)
    Pixel (1,1) = (green, alpha=0)

    If you try to render pixel (0.5,0.5) (which happens when using e.g. GL_LINEAR texture mode), you will get:

    (75% red, 25% green, alpha=0.75)

    That's what happens then... and shows how the green pixel gets an influence.
    1. Open Notepad
    2. Paste: ÿþMSMSMS
    3. Save
    4. Open the file in Notepad again

    You can vary the number of "MS", so you can clearly see it's MS which is causing it.
    User avatar
    divVerent
    Site admin and keyboard killer
     
    Posts: 3809
    Joined: Thu Mar 02, 2006 4:46 pm
    Location: BRLOGENSHFEGLE

Wed Oct 08, 2008 3:39 pm

  • divVerent wrote:Fix what? What is broken? It can't make stuff transparent that isn't. That was never its purpose.

    Make image ABOVE look like correct one (BELOW) - fix black pixels (black in photoshop, paint x means transparency).
    Image

    Thanks for info about cards.

    In the wrong one pic I posted, black pixels would get influence. ;)
    Alien
    Forum addon
     
    Posts: 1212
    Joined: Tue Apr 22, 2008 7:12 am

Wed Oct 08, 2008 4:15 pm

  • It does do that just fine. Unless you are referring to another image "above".
    1. Open Notepad
    2. Paste: ÿþMSMSMS
    3. Save
    4. Open the file in Notepad again

    You can vary the number of "MS", so you can clearly see it's MS which is causing it.
    User avatar
    divVerent
    Site admin and keyboard killer
     
    Posts: 3809
    Joined: Thu Mar 02, 2006 4:46 pm
    Location: BRLOGENSHFEGLE

Wed Oct 08, 2008 4:59 pm

  • I'm referring to this bad image:
    Image
    Alien
    Forum addon
     
    Posts: 1212
    Joined: Tue Apr 22, 2008 7:12 am

Wed Oct 08, 2008 6:17 pm

  • fixtrans can't turn a non-transparent image into a transparent one, if you mean that. DP still loads the image with its normal TGA loading routine.
    1. Open Notepad
    2. Paste: ÿþMSMSMS
    3. Save
    4. Open the file in Notepad again

    You can vary the number of "MS", so you can clearly see it's MS which is causing it.
    User avatar
    divVerent
    Site admin and keyboard killer
     
    Posts: 3809
    Joined: Thu Mar 02, 2006 4:46 pm
    Location: BRLOGENSHFEGLE

Wed Oct 08, 2008 6:51 pm

  • No. I'll explain you on irc later then. The bad image is also transparent, I've only posted rgb view without alpha channel.
    Alien
    Forum addon
     
    Posts: 1212
    Joined: Tue Apr 22, 2008 7:12 am

Wed Oct 08, 2008 8:47 pm

  • GIMP doesn't handle the alpha channel correctly in TGA files, this is a known issue. When making photosoup textures (such as SimonOC's terrain textures) I need to save as an RGB tga and a separate greyscale version. Then I use ImageMagick to mogrify the RGB tga by adding the greyscale version as the alpha channel.
    Taiyo.uk
    Alien trapper
     
    Posts: 436
    Joined: Mon Apr 17, 2006 8:48 pm
    Location: Reading, IN-GER-LUND!!!

Thu Oct 09, 2008 7:30 am

  • Taiyo.uk wrote:GIMP doesn't handle the alpha channel correctly in TGA files, this is a known issue. When making photosoup textures (such as SimonOC's terrain textures) I need to save as an RGB tga and a separate greyscale version. Then I use ImageMagick to mogrify the RGB tga by adding the greyscale version as the alpha channel.


    Why? It works for me.
    Image

    Use transparent background and later set colour opacity when texturing.

    Original tga file - made with Gimp only
    Alien
    Forum addon
     
    Posts: 1212
    Joined: Tue Apr 22, 2008 7:12 am

Thu Oct 09, 2008 8:51 am

  • GIMP IIRC saves TGA wrong if in Grayscale mode. Change to RGB mode before saving as TGA, if you have an alpha channel.
    1. Open Notepad
    2. Paste: ÿþMSMSMS
    3. Save
    4. Open the file in Notepad again

    You can vary the number of "MS", so you can clearly see it's MS which is causing it.
    User avatar
    divVerent
    Site admin and keyboard killer
     
    Posts: 3809
    Joined: Thu Mar 02, 2006 4:46 pm
    Location: BRLOGENSHFEGLE



Return to Nexuiz - Editing




Information
  • Who is online
  • Users browsing this forum: No registered users and 1 guest