Graphics

Reply

Level 1

Level 1
mayab08
Posts: 9
Registered: ‎28-08-2012
Message 1 of 10 (350 Views)
Accepted Solution

Texture2D Alpha Problem

I have an MDX which works fine in the viewer with an alpha blended texture. It's exported from Max as an FBX with the alpha texture as a 32bit BMP.

 

When I render using BasicModel, the alpha is not being read by the shader. I've tested this by setting alpha explicitly with:

 

    color.w = step(0.5f, max(max(color.x, color.y), color.z));

 

And this comes out with some alpha'd sections of the textures, as expected.

 

I'm using a custom version of BasicModel to add some point lights, and have traced the texture loading down to one line:

 

    new Texture2D( image, true ) ;

 

Which loads the texture from a block of data in memory and generates mipmaps. I've tried forcing the format to rgba, but this makes no odds.

 

So, my question is, where is my alpha channel?! It looks like Texture2D isn't working, as the data in the MDX is correct (going by the model viewer).

 

Can anyone shed some light on this?

 

Thanks!

-- James


Please use plain text.

Level 1

Level 1
mayab08
Posts: 9
Registered: ‎28-08-2012
Message 2 of 10 (344 Views)

Re: Texture2D Alpha Problem

To make this even weirder, I've noticed alpha is working elsewhere.

I changed the texture on the mesh which isn't working to one that is working elsewhere and it still doesn't work.

Somehow either Texture2D is randomly including alpha on the same data, or there is some setting somewhere I am not aware of which tells Texture2D how to deal with alpha channels.

Anyone seen this? Using the latest SDK btw.

ta,
-- James
Please use plain text.

Re: Texture2D Alpha Problem

Hi:

 

Tell me how it's the image info(from explorer) did oyu set the texture as rgba4444? on SDK?

 

Cheers,

Please use plain text.

Level 1

Level 1
mayab08
Posts: 9
Registered: ‎28-08-2012
Message 4 of 10 (334 Views)

Re: Texture2D Alpha Problem

Both textures (the one that works and one that doesnt) are RGB8 -- so 32 bit / 8 bits per channel Windows BMP. I tried forcing the format on Texture2D to rgba 8 and 4 bits per channel. Neither worked, but did have noticeable quality loss in the colour channels, so did work as far as I could tell.

If you open them up in a hex editor, you can see the alpha data is present. Likewise by opening the MDX in the model viewer you can see it is correct. Also opening the MDX in a hex editor the BMP data contained within it matches the expected BMP.

So as far as I can tell, the data is correct, the blend state is set correctly (can force alpha by setting is in fragment code) but the texture is just not reading alpha.

Thanks,
-- James
Please use plain text.

Re: Texture2D Alpha Problem

Hi:

 

Could oyu please try using png files? rgba 32bit?

 

Cheers,

Please use plain text.

Level 1

Level 1
mayab08
Posts: 9
Registered: ‎28-08-2012
Message 6 of 10 (327 Views)

Re: Texture2D Alpha Problem

Saving as 32bit PNG does appear to work, although it's a bit of a pain from photoshop as it wont save the alpha channel, rather is saves the transparency.

 

So this does seem to be a bug in the Texture2D code, as it works in the viewer, and also in other 32bit BMP's.

 

I can provide an MDX which fails if anyone from the SDK team are reading. It really does need fixing -- and preferably increasing the supported texture formats and adding compressed support.... :smileysurprised:)

 

Cheers!

-- James

Please use plain text.

Re: Texture2D Alpha Problem

Hi:

 

Nice to hear that with png works,, now lets try to find out why that image don't work could you please send me the BMP? but ..may be I'm wrong but BMP format never had alpha channel.

 

Cheers

Please use plain text.

Re: Texture2D Alpha Problem

BMP does support alpha channel, but I have rarely seen it in game engines (Can't think of one...), BMP itself is rarely used in games at all (proprietary Microsoft format).
The PSM documentation states "Supported image file formats are PNG, BMP, JPEG, and GIF. The PNG format supports transparencies, so it is best to use this format when you want to use transparent colors. ".

Is there a specific reason you want to go with BMPs? Decompression of a PNG might be even faster than streaming a raw BMP from a filesystem these days. Photoshop indeed does some weird stuff with alpha (although from an artists perspective I've been told it's completely logical), try Paint.NET.
http://markscheurwater.com/project.php
Please use plain text.

Level 1

Level 1
mayab08
Posts: 9
Registered: ‎28-08-2012
Message 9 of 10 (298 Views)

Re: Texture2D Alpha Problem

I'm not too bothered about which format I use, it just happens that BMP is a bit easier to deal with when using alpha channels in PhotoShop.

 

What I find weird is that on some models, the BMP alpha works, on others it does not. Even when using a texture which "works" and copying it to another model, it mysteriously stops working.

 

I've swiched to using PNG's where appropriate but supporting something like TGA would be nice to have. Although PNG does indeed seem to do everything I need.

 

Cheers,

-- James

Please use plain text.

Re: Texture2D Alpha Problem

Hi:

 

MMM that's strange anywasy glad to know PNG worked for eveything you need.

 

Cheers,

Please use plain text.
Announcements

Welcome to the PlayStation Mobile Developer Forums


This is a community for the discussion of technical topics with other developers and SCE engineers. Posting ideas/requests are also appreciated. Join the discussion!

PlayStation®Mobile開発者フォーラムでは世界中の開発者の皆様と一緒に、議論や情報交換が可能です。SCEも議論に参加し、皆様の開発をサポートします。アイデアやリクエストも大歓迎です。ぜひご参加ください。

PSM Developer Registration (for free) on PSM DevPortal is required to post on the forum.
Please sign out then sign in again to the forum and PSM DevPortal after you have completed the registration.

フォーラムへ投稿をするにはPSM DevPortalへの登録(無料)が必要です。
登録後はフォーラムと PSM DevPortalを一度ログアウトし、再度ログインしてください。