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 

Non-working blending mode

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



Joined: 28 Mar 2006
Posts: 9

PostPosted: Tue Mar 28, 2006 11:22 pm    Post subject: Non-working blending mode Reply with quote

I've writing a small application for both Windows/GL and the PSP, but there is one blending-mode that doens't seem to work the way I intend it.

Code:
sceGuBlendFunc(GU_ADD, GU_DST_COLOR, GU_ZERO, 0, 0);


This is supposed to multiply the source texels with the destination pixels, right (Dest*Source+0*Dest)? It does just that when I use the Windows/GL equivalent so I shouldn't be completely off.
Code:
sceGuBlendFunc(GU_ADD, GU_ZERO, GU_SRC_COLOR, 0, 0);


This should produce an identical result if I understood it correctly. (0*Source+Source*Dest)

Now, in my app, the result of the first blend seems to be 100% destination, and the result of the second blend is 100% source.

Any ideas?
Back to top
View user's profile Send private message
fish



Joined: 08 Feb 2006
Posts: 25

PostPosted: Wed Mar 29, 2006 12:56 am    Post subject: Re: Non-working blending mode Reply with quote

Jesse wrote:
I've writing a small application for both Windows/GL and the PSP, but there is one blending-mode that doens't seem to work the way I intend it.

Code:
sceGuBlendFunc(GU_ADD, GU_DST_COLOR, GU_ZERO, 0, 0);


This is supposed to multiply the source texels with the destination pixels, right (Dest*Source+0*Dest)? It does just that when I use the Windows/GL equivalent so I shouldn't be completely off.
Code:
sceGuBlendFunc(GU_ADD, GU_ZERO, GU_SRC_COLOR, 0, 0);


This should produce an identical result if I understood it correctly. (0*Source+Source*Dest)

Now, in my app, the result of the first blend seems to be 100% destination, and the result of the second blend is 100% source.

Any ideas?


Surely that makes sense? the funcions are doing exactly what you tell them, i.e.

GU_ADD, GU_DST_COLOR, GU_ZERO ==> destination 0 = destination
GU_ADD, GU_ZERO, GU_SRC_COLOR ==> 0 + source = source

not sure exactly what the syntax would be, but I imagine you would use something like:

GU_MUL, GU_SRC_COLOR, GU_DST_COLOR

to get source*destination


Last edited by fish on Wed Mar 29, 2006 2:12 am; edited 1 time in total
Back to top
View user's profile Send private message
Jesse



Joined: 28 Mar 2006
Posts: 9

PostPosted: Wed Mar 29, 2006 1:06 am    Post subject: Reply with quote

I don't think there is such thing as GU_MUL.

GU_ADD, GU_SUBTRACT, GU_REVERSE_SUBTRACT, GU_MIN, GU_MAX and GU_ABS are the ones defined.
Back to top
View user's profile Send private message
sebbbi



Joined: 12 Apr 2006
Posts: 1

PostPosted: Wed Apr 12, 2006 12:43 am    Post subject: Reply with quote

sceGuBlendFunc(GU_ADD, GU_DST_COLOR, GU_ZERO, 0, 0);
= (src_color * dst_color) + (dst_color * 0) = src_color * dst_color

sceGuBlendFunc(GU_ADD, GU_ZERO, GU_SRC_COLOR, 0, 0);
= (src_color * 0) + (dst_color * src_color) = dst_color * src_color

Both should have indentical results.

Your problem is that "GU_ZERO" is not a proper blending function. You should use GU_FIX instead (with fix parameter 0. "GU_ONE" would have fix parameter 0xffffffff).

Both of these work as you intented (give you the multiply alpha you want):
sceGuBlendFunc(GU_ADD, GU_FIX, GU_SRC_COLOR, 0, 0);
sceGuBlendFunc(GU_ADD, GU_DST_COLOR, GU_FIX, 0, 0);

And this gives you basic additive alpha (src_color * 1 + dst_color * 1):
sceGuBlendFunc(GU_ADD, GU_FIX, GU_FIX, 0xffffff, 0xffffff);
Back to top
View user's profile Send private message
chp



Joined: 23 Jun 2004
Posts: 313

PostPosted: Wed Apr 12, 2006 3:53 am    Post subject: Reply with quote

If you look at pspgu.h, you will see the following:
Code:
#define GU_SRC_COLOR            (0)
#define GU_ONE_MINUS_SRC_COLOR  (1)
#define GU_DST_COLOR            (0)
#define GU_ONE_MINUS_DST_COLOR  (1)


Note how they map to the same values? This is the reason why you cannot multiply them together using this method ... cheap sony engineers. :)

I'll update the documentation to make note of this fact.
_________________
GE Dominator
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