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 

Inverting alpha channel

 
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 Feb 19, 2006 10:37 pm    Post subject: Inverting alpha channel Reply with quote

Hello,
I have a problem, in my library that I would like to keep as simple as possible, an alpha channel with 0 is represented as opaque and 1 as transparent, contrarily to the PSP default, so that drawing an opaque rect will use RGB(1,2,3) colors, not RGBA(1,2,3, 0xff).
But here's the problem, using 5650 pixelformat, alpha will be returned as '1' by the PSP, so that the image is always opaque, but in my case it means transparent, and the image will not be drawn...
So, is there a possiblity of inverting directly the alpha channel without such problems? I've tried anything with sceGuBlendFunc but no way :(
Thank you :)
_________________
Sorry for my bad english
Oldschool library for PSP - PC version released
Back to top
View user's profile Send private message
weak



Joined: 13 Jan 2005
Posts: 114
Location: Vienna, Austria

PostPosted: Mon Feb 20, 2006 1:06 am    Post subject: Reply with quote

Code:

// option1
sceGuAlphaFunc(GU_LESS,0xff,0xff);
sceGuEnable(GU_ALPHA_TEST);

//option2
sceGuEnable(GU_BLEND);
sceGuBlendFunc(GU_ADD, GU_ONE_MINUS_SRC_ALPHA, GU_SRC_ALPHA, 0, 0);


works both here (for GU_PSM_8888 and GU_PSM_T8)
Back to top
View user's profile Send private message
Brunni



Joined: 08 Oct 2005
Posts: 186

PostPosted: Mon Feb 20, 2006 2:23 am    Post subject: Reply with quote

Thank you for your reply.
But unhopefully it won't work for 5650 mode, as alpha is returned as 1, so if you test if alpha < 255, it will always be 255 and never drawn, and with GU_ONE_MINUS_SRC_ALPHA, GU_SRC_ALPHA, it will do 0*texture+1*dst, so never drawn :(
And is there a possibility to do standard alpha blend with this? I tried but the only thing to do is alpha testing, and it will work only for 255 values...
_________________
Sorry for my bad english
Oldschool library for PSP - PC version released
Back to top
View user's profile Send private message
weak



Joined: 13 Jan 2005
Posts: 114
Location: Vienna, Austria

PostPosted: Mon Feb 20, 2006 7:30 am    Post subject: Reply with quote

well, without an alpha value it will be kind of hard ;)
maybe use another texture format?

if you want differentiated blending (more than just 0,1) you will have to use a texture format that allows to store more values for the alpha component

edit
----
to make it clear:

GU_PSM_5650 -> no space for alpha, hence no blending or testing
GU_PSM_5551 -> 1bit for alpha (0||1), so you could do a simple alpha test
GU_PSM_8888 -> 8bits for alpha -> 256 different levels of blending
Back to top
View user's profile Send private message
Brunni



Joined: 08 Oct 2005
Posts: 186

PostPosted: Mon Feb 20, 2006 5:12 pm    Post subject: Reply with quote

Ok thanks, so I'll just disable alpha test/blending in 5650 mode.
Another question related to this, I want to do for example: x*(1-asrc)*csrc+y*(1-adst)*cdst with custom x and y values so that semi transparency is possible.
This can be done with standard alpha (that is, x*asrc*csrc+y*adst*cdst), but I didn't find if it was possible to do it with an inverted alpha value, so for example if my alpha channel is 0x80 (semi transparent), it would then be 0xc0 (3/4 transparent) with the operation.
Is there a possibility to do such an operation?
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
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