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 

per pixel alpha

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



Joined: 19 May 2004
Posts: 246
Location: Melbourne, Australia

PostPosted: Thu May 17, 2007 9:56 am    Post subject: per pixel alpha Reply with quote

I have been having a few issues with images that have per pixel alpha values.

It is hard to describe what is happening in all cases. When the alpha is 0 nothing is displayed, all correct there. But when the alpha was 255 it was still been alpha blended with the background.

What I discovered last night though is that if I rescale the 0-255 alpha values into 0-63 then everything works correctly. Anybody have any ideas about that? It seems the last two bits are used for something else.
Back to top
View user's profile Send private message
ps2devman



Joined: 09 Oct 2006
Posts: 265

PostPosted: Thu May 17, 2007 6:58 pm    Post subject: Reply with quote

These are a few comments I've put in system.c in Q*Bert starter kit :

gsKit_set_primalpha(gsGlobal, GS_SETREG_ALPHA(1,2,0,0,0), 1);
//Cv=(Cd-0)*As>>7+Cs (p100 GS user manual)
//Alpha blending per pixel is on (p115 GS user manual)

Cv: Color value you get actually after operation
Cd: Color read at pixel destination
Cs: Color read in texture source
As: Alpha read in texture source

The formula above is only one of the possible formula you can obtain.
(only reading GS user manual will allow you to learn how to change the formula)

So... With this formula, and this one only, you can consider :
if Alpha = 128 & Cs= 0 (because 128>>7=1), color is transparency 100%
if Alpha = 0, result color is Cs, opaque 100%
and so on
if Alpha > 128 you may have unpredictable results in case of overflows
Back to top
View user's profile Send private message
radad



Joined: 19 May 2004
Posts: 246
Location: Melbourne, Australia

PostPosted: Fri May 18, 2007 10:15 am    Post subject: Reply with quote

Doesnt your formula suggest that any alpha value from 0-127 is 100% opaque?

Where is the GS user manual?
Back to top
View user's profile Send private message
radad



Joined: 19 May 2004
Posts: 246
Location: Melbourne, Australia

PostPosted: Fri May 18, 2007 12:15 pm    Post subject: Reply with quote

Ok, I have looked that up. I think I get it now.
Thanks.
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 -> PS2 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