Alpha channel copy

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
Brunni
Posts: 186
Joined: Sat Oct 08, 2005 10:27 pm

Alpha channel copy

Post by Brunni »

Hello,
I have an image (drawbuffer) that for example is filled with: 0x00000000.
I want to fill this image with for example: 0xff808080.
The alpha channel seems not to be copied to the destination, even if alpha-blending is turned off, so here I'll have 0x00808080 on the dest buffer if I draw a 0xff808080-colored poly on it or do sceGuClear.
Does anybody know how I could copy alpha channel as well as colors to the destbuffer when drawing?
Thanks in advance
Sorry for my bad english
Image Oldschool library for PSP - PC version released
User avatar
Raphael
Posts: 646
Joined: Tue Jan 17, 2006 4:54 pm
Location: Germany
Contact:

Post by Raphael »

Did you set sceGuTexMode(GU_TX_REPLACE,GU_RGBA) so that destination alpha is set correctly?
Brunni
Posts: 186
Joined: Sat Oct 08, 2005 10:27 pm

Post by Brunni »

Yes, but it didn't changed anything. Maybe there is something else I missed?
Sorry for my bad english
Image Oldschool library for PSP - PC version released
User avatar
Raphael
Posts: 646
Joined: Tue Jan 17, 2006 4:54 pm
Location: Germany
Contact:

Post by Raphael »

Well I'd need to peek at your setup- & drawingcode to get the problem. Most likely it's something really simple
Brunni
Posts: 186
Joined: Sat Oct 08, 2005 10:27 pm

Post by Brunni »

Hm I don't have my code here, sorry, but I took some GU samples for testing (spharm for example) and in all cases, alpha was not stored to the destination.

The problem is that in normal situation, alpha is never stored to the destination buffer. It's just used for blending. So in my case it seems that when blending is disabled, alpha information is just lost (unuseful).
So there might be something else to enable in the GE so that alpha is copied to the dest buffer?

Thank you in advance :)
Sorry for my bad english
Image Oldschool library for PSP - PC version released
memon
Posts: 63
Joined: Mon Oct 03, 2005 10:51 pm

Post by memon »

Do you enable stencil buffer? I think you can either use destination alpha or stencil buffer since they share the same memory.
Brunni
Posts: 186
Joined: Sat Oct 08, 2005 10:27 pm

Post by Brunni »

Yes thanks, this actually works for clearing the destbuffer, but it doesn't if I want to draw images (or I didn't understand stencil doc correctly).
I found a workaround, which is to set the stencil buffer to 0, then every drawn pixel replaces stencil value with 0xff (alpha test -> only nonzero-alpha pixels are drawn). Then drawn pixels will be opaque, the rest will be transparent. But this is not a very satisfying alternative, as it's really limited :(
Is there any alternative for writing alpha to the destbuffer?
Thanks in advance
Sorry for my bad english
Image Oldschool library for PSP - PC version released
rapso
Posts: 140
Joined: Mon Mar 28, 2005 6:35 am

Post by rapso »

I have the very same problem, I need to render to the alphachannel and it seems not to work, it does work for clearing, but I need it during usual rendering.

here: http://forums.ps2dev.org/viewtopic.php? ... ha+channel someone seemed to get it working.

so does anyone know the magic difference to get it work?
User avatar
Raphael
Posts: 646
Joined: Tue Jan 17, 2006 4:54 pm
Location: Germany
Contact:

Post by Raphael »

By the way: the framebuffer's alpha DOES get filled, provided you use GU_TCC_RGBA with sceGuTexFunc.
Probably that? At least I can confirm that rendering alpha to destination IS possible, though I didn't specifically test it. It was rather an (unwanted) side-effect that I noticed in my last 32bit TGA screenshot.
<Don't push the river, it flows.>
http://wordpress.fx-world.org - my devblog
http://wiki.fx-world.org - VFPU documentation wiki

Alexander Berl
rapso
Posts: 140
Joined: Mon Mar 28, 2005 6:35 am

Post by rapso »

Raphael wrote:
By the way: the framebuffer's alpha DOES get filled, provided you use GU_TCC_RGBA with sceGuTexFunc.
Probably that?
Brunni wrote:Yes, but it didn't changed anything. Maybe there is something else I missed?
so I guess there is something more to set to get it running. when I was running my test, the alpha did not change at all during rendering (so not even just "black" alphavalues were set).
At least I can confirm that rendering alpha to destination IS possible, though I didn't specifically test it. It was rather an (unwanted) side-effect that I noticed in my last 32bit TGA screenshot.
would be nice if someone could post some source, this would help a lot to find that difference.
Fanjita
Posts: 217
Joined: Wed Sep 28, 2005 9:31 am

Post by Fanjita »

Note that the alpha byte in the framebuffer gets filled with random values since firmware 2.5, as a countermeasure against exploits that use code loaded in the framebuffer.

(Actually, it might not be random, it might just be 0 - I don't remember exactly.)
Got a v2.0-v2.80 firmware PSP? Download the eLoader here to run homebrew on it!
The PSP Homebrew Database needs you!
User avatar
Raphael
Posts: 646
Joined: Tue Jan 17, 2006 4:54 pm
Location: Germany
Contact:

Post by Raphael »

But only in VSH I suppose? Because in games etc. the framebuffer alpha is supposed to hold the stencil bits if stenciling is enabled, so it would be bad if they just wrote over those bits in any unpredictable (to the game app) way.
<Don't push the river, it flows.>
http://wordpress.fx-world.org - my devblog
http://wiki.fx-world.org - VFPU documentation wiki

Alexander Berl
Fanjita
Posts: 217
Joined: Wed Sep 28, 2005 9:31 am

Post by Fanjita »

True, I would imagine this only applies to wallpaper in VSH.
Got a v2.0-v2.80 firmware PSP? Download the eLoader here to run homebrew on it!
The PSP Homebrew Database needs you!
Brunni
Posts: 186
Joined: Sat Oct 08, 2005 10:27 pm

Post by Brunni »

Raphael wrote:
By the way: the framebuffer's alpha DOES get filled, provided you use GU_TCC_RGBA with sceGuTexFunc.
Probably that? At least I can confirm that rendering alpha to destination IS possible, though I didn't specifically test it. It was rather an (unwanted) side-effect that I noticed in my last 32bit TGA screenshot.
Same as rapso: impossible to get it working (and I created this topic 1 year ago: you can imagine I've tried a LOT of things since this).
I tried GU_TCC_RGBA, but it doesn't work. I've tried a lot of things, but alpha NEVER gets filled :(
You say that you got it working, but can you please post a sample with source code? Please (I'm getting crazy)...
Sorry for my bad english
Image Oldschool library for PSP - PC version released
Post Reply