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 

RGBA + global alpha value

 
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 Jan 22, 2006 4:46 am    Post subject: RGBA + global alpha value Reply with quote

Hello all ^^

I have a RGBA image that I use as a simple sprite, it's usually 5551 (just 1 bit to define if the pixel is transparent or not). Up to here, I used:
sceGuBlendFunc(GU_ADD,GU_ONE_MINUS_SRC_ALPHA,GU_SRC_ALPHA,0,0);
This will work, if the bit is 1, then it's transparent, else not.
But now, I want to add a global alpha value to my sprite, so that it's semi-transparent. Usually, I just do:
sceGuBlendFunc(GU_ADD, GU_FIX, GU_FIX, coeff, 0xffffffff-coeff);
Where coeff can be 0x00808080 for semi-transparency. It works, but the problem is that this won't take the alpha value in consideration and the transparent sprite part will be drawn as solid black...

The goal would be a blendfunction that multiplies GU_SRC_ALPHA by a fixed value, like GU_ONE_MINUS_SRC_ALPHA * GU_FIX and GU_SRC_ALPHA * GU_FIX, but it seems not to be possible regarding the documentation.

If anyone can help me, I would really appreciate, thanks :)
_________________
Sorry for my bad english
Oldschool library for PSP - PC version released
Back to top
View user's profile Send private message
jsgf



Joined: 12 Jul 2005
Posts: 254

PostPosted: Sun Jan 22, 2006 7:21 am    Post subject: Reply with quote

You could do it that way, I guess, but the more conventional approach is to use the current colour to modulate the texture pixels.

Use:
Code:
sceGuTexFunc(GU_TFX_MODULATE, GU_TCC_RGBA);
sceGuBlendFunc(GU_ADD,GU_SRC_ALPHA,GU_ONE_MINUS_SRC_ALPHA,0,0);
sceGuColor(0xNNffffff); // NN = alpha

This will multiply each texture pixel with the current colour, as well as take the texture's alpha channel into account. Note you can also use this for tinting the image, rather than just changing the alpha.
Back to top
View user's profile Send private message Visit poster's website
Brunni



Joined: 08 Oct 2005
Posts: 186

PostPosted: Sun Jan 22, 2006 9:16 pm    Post subject: Reply with quote

Thanks, it works, but the problem is that my alpha is opaque when 0 and transparent when 1, because it's for a library and I don't want to fill my buffers with 0xff000000 by default.
sceGuBlendFunc(GU_ADD,GU_ONE_MINUS_SRC_ALPHA,GU_SRC_ALPHA,0,0);
sceGuTexFunc(GU_TFX_MODULATE, GU_TCC_RGBA);
sceGuAmbientColor(coeff<<24);
If I do that, it will multiply them and they will become more opaque instead of more transparent :(
In fact I would need to make something like Av=(1-At)*Af but sceGuTexFunc doesn't permit this.
Any solution?
_________________
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