forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Alpha channel copy

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
Brunni



Joined: 08 Oct 2005
Posts: 186

PostPosted: Sun Mar 12, 2006 9:18 pm    Post subject: Alpha channel copy Reply with quote

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
Oldschool library for PSP - PC version released
Back to top
View user's profile Send private message
Raphael



Joined: 17 Jan 2006
Posts: 646
Location: Germany

PostPosted: Sun Mar 12, 2006 10:31 pm    Post subject: Reply with quote

Did you set sceGuTexMode(GU_TX_REPLACE,GU_RGBA) so that destination alpha is set correctly?
Back to top
View user's profile Send private message Visit poster's website
Brunni



Joined: 08 Oct 2005
Posts: 186

PostPosted: Sun Mar 12, 2006 11:28 pm    Post subject: Reply with quote

Yes, but it didn't changed anything. Maybe there is something else I missed?
_________________
Sorry for my bad english
Oldschool library for PSP - PC version released
Back to top
View user's profile Send private message
Raphael



Joined: 17 Jan 2006
Posts: 646
Location: Germany

PostPosted: Mon Mar 13, 2006 3:58 am    Post subject: Reply with quote

Well I'd need to peek at your setup- & drawingcode to get the problem. Most likely it's something really simple
Back to top
View user's profile Send private message Visit poster's website
Brunni



Joined: 08 Oct 2005
Posts: 186

PostPosted: Tue Mar 14, 2006 9:49 pm    Post subject: Reply with quote

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
Oldschool library for PSP - PC version released
Back to top
View user's profile Send private message
memon



Joined: 03 Oct 2005
Posts: 63

PostPosted: Tue Mar 14, 2006 11:15 pm    Post subject: Reply with quote

Do you enable stencil buffer? I think you can either use destination alpha or stencil buffer since they share the same memory.
Back to top
View user's profile Send private message
Brunni



Joined: 08 Oct 2005
Posts: 186

PostPosted: Wed Mar 15, 2006 4:58 am    Post subject: Reply with quote

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
Oldschool library for PSP - PC version released
Back to top
View user's profile Send private message
rapso



Joined: 28 Mar 2005
Posts: 147

PostPosted: Mon Mar 12, 2007 11:47 am    Post subject: Reply with quote

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?t=6648&highlight=alpha+channel someone seemed to get it working.

so does anyone know the magic difference to get it work?
Back to top
View user's profile Send private message
Raphael



Joined: 17 Jan 2006
Posts: 646
Location: Germany

PostPosted: Mon Mar 12, 2007 5:09 pm    Post subject: Reply with quote

Quote:
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
Back to top
View user's profile Send private message Visit poster's website
rapso



Joined: 28 Mar 2005
Posts: 147

PostPosted: Mon Mar 12, 2007 5:39 pm    Post subject: Reply with quote

Raphael wrote:
Quote:
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).

Quote:

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.
Back to top
View user's profile Send private message
Fanjita



Joined: 28 Sep 2005
Posts: 217

PostPosted: Mon Mar 12, 2007 7:16 pm    Post subject: Reply with quote

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!
Back to top
View user's profile Send private message
Raphael



Joined: 17 Jan 2006
Posts: 646
Location: Germany

PostPosted: Mon Mar 12, 2007 9:24 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message Visit poster's website
Fanjita



Joined: 28 Sep 2005
Posts: 217

PostPosted: Tue Mar 13, 2007 10:32 am    Post subject: Reply with quote

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!
Back to top
View user's profile Send private message
Brunni



Joined: 08 Oct 2005
Posts: 186

PostPosted: Sat Mar 31, 2007 11:36 pm    Post subject: Reply with quote

Raphael wrote:
Quote:
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
Oldschool library for PSP - PC version released
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group