Inverting alpha channel

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

Inverting alpha channel

Post by Brunni »

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
Image Oldschool library for PSP - PC version released
weak
Posts: 114
Joined: Thu Jan 13, 2005 8:31 pm
Location: Vienna, Austria

Post by weak »

Code: Select all

// 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)
Brunni
Posts: 186
Joined: Sat Oct 08, 2005 10:27 pm

Post by Brunni »

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
Image Oldschool library for PSP - PC version released
weak
Posts: 114
Joined: Thu Jan 13, 2005 8:31 pm
Location: Vienna, Austria

Post by weak »

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
Brunni
Posts: 186
Joined: Sat Oct 08, 2005 10:27 pm

Post by Brunni »

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
Image Oldschool library for PSP - PC version released
Post Reply