 |
forums.ps2dev.org Homebrew PS2, PSP & PS3 Development Discussions
|
| View previous topic :: View next topic |
| Author |
Message |
Jesse
Joined: 28 Mar 2006 Posts: 9
|
Posted: Tue Mar 28, 2006 11:22 pm Post subject: Non-working blending mode |
|
|
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 |
|
 |
fish
Joined: 08 Feb 2006 Posts: 25
|
Posted: Wed Mar 29, 2006 12:56 am Post subject: Re: Non-working blending mode |
|
|
| 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 |
|
 |
Jesse
Joined: 28 Mar 2006 Posts: 9
|
Posted: Wed Mar 29, 2006 1:06 am Post subject: |
|
|
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 |
|
 |
sebbbi
Joined: 12 Apr 2006 Posts: 1
|
Posted: Wed Apr 12, 2006 12:43 am Post subject: |
|
|
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 |
|
 |
chp
Joined: 23 Jun 2004 Posts: 313
|
Posted: Wed Apr 12, 2006 3:53 am Post subject: |
|
|
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 |
|
 |
|
|
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
|