sceGuBlendFunc usage ?

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

Moderators: cheriff, TyRaNiD

Post Reply
hlide
Posts: 739
Joined: Sun Sep 10, 2006 2:31 am

sceGuBlendFunc usage ?

Post by hlide »

I would like to convert some glBlend* operations in GU sceGuBlendFunc, but i have some difficulties because there are some not even defined in pspgl.

The only one I could be sure (according what I found out in PSPGL) is the following two :

Code: Select all

(1.0 x Cd + 1.0 x Cs) :

    glBlendFunc(GL_ONE,GL_ONE);
    glBlendEquationEXT(GL_FUNC_ADD_EXT);

--->

    sceGuBlendFunc(GU_ADD, GU_FIX, GU_FIX, 0xffffff, 0xffffff);
and

Code: Select all

(1.0 x Cd - 1.0 x Cs) :

    glBlendFunc(GL_ONE,GL_ONE);
    glBlendEquationEXT(GL_FUNC_REVERSE_SUBTRACT_EXT);

--->

    sceGuBlendFunc(GU_REVERSE_SUBTRACT, GU_FIX, GU_FIX, 0xffffff, 0xffffff);

there are other two I dunno how to translate :

Code: Select all

(0.5 x Cs + 0.5 x Cd) :

    glBlendColorEXT(0.0,0.0,0.0,0.5);
    glBlendFunc(GL_CONSTANT_ALPHA,GL_CONSTANT_ALPHA);
    glBlendEquationEXT(GL_FUNC_ADD_EXT);

--->

    sceGuBlendFunc(GU_ADD, ?, ?, ?, ?);

Code: Select all

(1.0 x Cd + 0.25 x Cs) :

    glBlendColorEXT(0.0,0.0,0.0,0.5);
    glBlendFunc(GL_CONSTANT_ALPHA,GL_ONE);
    glBlendEquationEXT(GL_FUNC_ADD_EXT);


--->

    sceGuBlendFunc(GU_ADD, ?, GU_FIX, ?, 0xffffff);
I hope someone knows the answer :/
hlide
Posts: 739
Joined: Sun Sep 10, 2006 2:31 am

Post by hlide »

anyone to help me ? i'm lost :(

I would be expecting something like :

Code: Select all

(0.5 x Cs + 0.5 x Cd) :

    glBlendColorEXT(0.0,0.0,0.0,0.5);
    glBlendFunc(GL_CONSTANT_ALPHA,GL_CONSTANT_ALPHA);
    glBlendEquationEXT(GL_FUNC_ADD_EXT);

--->

    sceGuBlendFunc(GU_ADD, GU_FIX, GU_FIX, 0x7f7f7f, 0x7f7f7f);

Code: Select all

(1.0 x Cd + 0.25 x Cs) :

    glBlendColorEXT(0.0,0.0,0.0,0.5);
    glBlendFunc(GL_CONSTANT_ALPHA,GL_ONE);
    glBlendEquationEXT(GL_FUNC_ADD_EXT);


--->

    sceGuBlendFunc(GU_ADD, GU_FIX, GU_FIX, 0x3f3f3f, 0xffffff);
Can anybody correct my code if i'm wrong ?
hlide
Posts: 739
Joined: Sun Sep 10, 2006 2:31 am

Post by hlide »

Up : please tell me if i'm wrong :'(
chp
Posts: 313
Joined: Wed Jun 23, 2004 7:16 am

Post by chp »

Looks about right, yes. If you want to read it more easily you can use the macros available, so something like this ...

Code: Select all

sceGuBlendFunc(GU_ADD, GU_FIX, GU_FIX, GU_COLOR(0.25f,0.25f,0.25f,0.25f), GU_COLOR(1,1,1,1));
... would multiply the input source pixel with 0.25 and add it to the destination, much like you have written yourself already.
GE Dominator
hlide
Posts: 739
Joined: Sun Sep 10, 2006 2:31 am

Post by hlide »

Great ! thx chp !

well there is something i don't understand :

PSPGL defines GL_ONE as being equivalent to GU_COLOR(255, 255, 255, 0) and not to GU_COLOR(255, 255, 255, 255).

Is there any difference between :

Code: Select all

sceGuBlendFunc(GU_ADD, GU_FIX, GU_FIX, GU_COLOR(0.25f,0.25f,0.25f,0.25f), GU_COLOR(1,1,1,1));
and

Code: Select all

sceGuBlendFunc(GU_ADD, GU_FIX, GU_FIX, GU_COLOR(0.25f,0.25f,0.25f, 0), GU_COLOR(1,1,1, 0));
and

Code: Select all

sceGuBlendFunc(GU_ADD, GU_FIX, GU_FIX, GU_COLOR(0,0,0,0.25f), GU_COLOR(0,0,0,1));
?
chp
Posts: 313
Joined: Wed Jun 23, 2004 7:16 am

Post by chp »

It probably depends on how you want the alpha-component of the color to affect the input. I have not properly tested how the alpha-vs-alpha blending is done on the PSP. On the PS2 the alpha-channel wasn't affected by blending, which is stopping me from answering which approach that is the correct one.
GE Dominator
Post Reply