Non-working blending mode

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
Jesse
Posts: 9
Joined: Tue Mar 28, 2006 11:12 pm

Non-working blending mode

Post by Jesse »

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: Select all

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: Select all

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?
fish
Posts: 25
Joined: Wed Feb 08, 2006 5:12 am

Re: Non-working blending mode

Post by fish »

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: Select all

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: Select all

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.
Jesse
Posts: 9
Joined: Tue Mar 28, 2006 11:12 pm

Post by Jesse »

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.
sebbbi
Posts: 1
Joined: Wed Apr 12, 2006 12:15 am

Post by sebbbi »

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);
chp
Posts: 313
Joined: Wed Jun 23, 2004 7:16 am

Post by chp »

If you look at pspgu.h, you will see the following:

Code: Select all

#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
Post Reply