XNA Creators Club Online
Page 1 of 1 (5 items)
Sort Posts: Previous Next

Transparent textures

Last post 06-22-2008 7:31 PM by jwatte. 4 replies.
  • 04-11-2008 9:35 AM

    Transparent textures

    I'm trying to use some textures with transparent areas but they're not displaying correctly in either XSI or XNA.  I'm using a png, which displays fine in Photoshop, but when I apply the texture to an object in XSI the transparent area is distorted - has an almost rainbow effect to it.  This effect carries through to XNA so I'm thinking it's something I'm missing in XSI.

    Is there some setting to enable the alpha channel in textures that I'm missing?  I'm using the phong.fx shader supplied with XSI just incase that has some bearing.


  • 04-11-2008 1:41 PM In reply to

    Re: Transparent textures

    Without a screen shot, it's impossible for us to answer for sure. My guess is that you're using post-multiplied alpha when you should be using pre-multiplied, or vice versa. A second possibility is that the fringe of your alpha texture has the wrong color.
    Jon Watte, Direct3D MVP kW X-port 3ds Max .X exporter kW Animation source code
  • 04-12-2008 4:49 AM In reply to

    Re: Transparent textures

    I'll get a screenshot posted up later.  I think the main issue I'm having though is when using any of the example FX shaders in XSI, I don't see any options for transparency.  The default Scene_Material and the MentalRay shaders have a dedicated Transparency/Reflection tab where I can enable/edit the various transparency options, but these of course aren't compatible with XNA.

    I'm obviously missing something so I'll list exactly what I'm doing to apply the texture:

    1) XNA Game Studio > Create Model
    2) Browser > Select phong.fx > Drag and drop on mesh
    3) Materials > Double click "phong" in Render Tree
    4) Images tab > New Ambient Map > Select texture
    5) New Texture Space > Cubic

    As I said, I can't see any option at all for transparency - only selecting Ambient, Albedo, and Normal Maps, applying projections for each, and a DirectXFX_Parameters tab for changing Ambient, Diffuse, and Specular RGBs along with Specular Power.

    Apologies if this is a really simple thing and I'm just being stupid about it, but I can't find any information on how to get this working.

    P.S. Just in case there was an issue with using PNGs, I've also tried some TGAs but this resulted in a black opaque instead of the transparent background.
  • 06-22-2008 12:33 PM In reply to

    Re: Transparent textures

    I'm having this issue also.  My transparent areas are showing as black.  I've seen a couple of posts about this with no resolution.  Has anyone had success using a texture image with an alpha channel?

    How would I tell if my alpha is pre-multiplied or post-multiplied?

    Thanks,

    RB

  • 06-22-2008 7:31 PM In reply to

    Re: Transparent textures

    If your image is pre-multiplied, then it is darker where it is transparent, and becomes black where it is totally transparent. (verify by comparing color channels to the alpha channel in Photoshop or similar)

    If your image is not pre-multiplied, then it will have the same color no matter the level of transparency.

    To blend a pre-multiplied alpha image into the frame buffer, you set SRCBLEND to ONE and DESTBLEND to INVSRCALPHA.

    To blend a non-pre-multiplied alpha image into the frame buffer, you set SRCBLEND to SRCALPHA and DESTBLEND to INVSRCALPHA.

    In general, I find that pre-multiplied alpha works best, because it avoids some fringing/filtering artifacts you may get with non-pre-multiplied, and it also allows you to over-brighten because of the additive mode, which is great for particles and other effects.

    Jon Watte, Direct3D MVP kW X-port 3ds Max .X exporter kW Animation source code
Page 1 of 1 (5 items) Previous Next