[SOLVED] Pipeline Tool: Import texture with alpha (other format than PNG)

Hi community,

I use Adobe Photoshop for creating my textures. But Phothoshop has one big issue with PNG images: it doesn’t save color pixels in places, where alpha channel is 0. In other words: it doesn’t save alpha channel, only layer transparency. This is unacceptable for game textures, of course.

So, I want to use TGA or PSD, or other rgba format. But it seems, Content Pipeline Tool (3.6.0.1625) imports all of them without alpha. Is it because I have old version, or it is bug, or feature?

Thank You.

Sorry, TGA and other formats works well, like PNG. It was my mistake.

But it seems, alpha channel is imported only with “PremultiplyAlpha” option. So, my additional question is: how to import texture with alpha channel, without premultiplied alpha?

You can set PremultiplyAlpha to False in the PipelineTool, when you select an image resource.

Yes, I know :-). But then, I have texture without alpha:

Same texture - same blending - same code:

  • without premultiply alpha import option, texture IS NOT transparent,
  • with premultiply alpha IS transparent

Maybe, I’am doing something wrong.

Its possible to import texture with alpha, but without premultiply?

It sounds like maybe you aren’t using BlendStates that draw the textures with their alpha channels. How are you testing whether or not the texture is transparent?

I just tried it with various file formats like PNG and TIFF and for me everything works as expected (outputed color data of imported textures as a txt file and inspected alpha values).

Have you tried the ColorKeyColor option or turning the background color of your input image to black before compiling?

Have you tried creating / converting your source images with a different program? (I’m not using Photoshop so I can’t tell if there is a special setting in your tool regarding alpha values).

jnoyola: I’am using blendstates, of course! :slight_smile: Please, read my previous post carefully: I see alpha blending, but only if I import texture with PremultiplyAlpha option. No other changes were made.

I’am beginner in MonoGame, but professional gfx programmer. Maybe there is other (hidden) import option?

sqrMin1: thank You for reply. Why ColorKeyColor option? Texture already has alpha channel. I only want to import it as RGBA texture without any changes. No color keys, no premultiplications.

Yes, I understand what you’re saying, but I’m wondering which BlendState you’re using to draw the texture that tells you it’s not transparent. Because if you don’t want the alpha premultuplied, then you need to use a BlendState that uses your texture’s alpha channel (usually BlendState.NonPremultiplied).

jnoyola: You are right! BlendState.NonPremultiplied is right answer :-). Thank You.
I never saw blend state like this (maybe because I never used premultiplied alpha before) ;), so I supposed, BlendState.AlphaBlend was 100% correct.

2 Likes

Ah, sorry I think I misunderstood your problem. But fine that it’s solved now :slight_smile: