found how to use color function (filtering)

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

Moderators: cheriff, TyRaNiD

Post Reply
yoyofr
Posts: 23
Joined: Sat Jun 25, 2005 7:08 pm
Location: paris
Contact:

found how to use color function (filtering)

Post by yoyofr »

Hi,

I'm still playing a lot with GU & found how to use

Code: Select all

sceGuColorFunc(int a0, unsigned int color, int a2);
It's a color filtering function.
a0 is function (GU_EQUAL,GU_LESS,....)
a2 is the color mask

you'll have to acticate color testing & then specify the function in the same way you specify a depth/alpha function.

enable it with :

Code: Select all

sceGuEnable(GU_UNKNOWN_17)
specify a simple function to not render blue pixel :

Code: Select all

sceGuColorFunc(GU_EQUAL,0,0XFF0000)
chp
Posts: 313
Joined: Wed Jun 23, 2004 7:16 am

Post by chp »

Ah, nice, this could be useful for color-keyed textures and other areas. Good work! I'll add it to GU.

EDIT: Hm, just to understand that correctly... that call would reject any pixel that does not keep the blue channel to 0, right?

EDIT 2: Also, it seems as the function masks the function by 0x03, GU_LESS and above are not available when color testing.
GE Dominator
yoyofr
Posts: 23
Joined: Sat Jun 25, 2005 7:08 pm
Location: paris
Contact:

Post by yoyofr »

Hm, just to understand that correctly... that call would reject any pixel that does not keep the blue channel to 0, right?
exactly.
Also, it seems as the function masks the function by 0x03, GU_LESS and above are not available when color testing.
good to know !
In fact I was trying to be able to filter a particular color when I have checked this in order to do adaptive blending. My texture used for blending has a back color (the one filtered) & some pixels resulting from
a previous rendering.
The back color has to be blended using add or sub & the pixels different
from back color have to be blended & then the result has to be divided by 2.
So I blend with a GU_FIX,GU_FIX,0xFFFFFF,0xFFFFFF with color filtering on,
so that only my back color is used. Moreover I setup stencil buffer so that
written are are marked.
Then I blend with a GU_FIX,GU_FIX,0x7F7F7F,0x7F7F7F with color filtering off. Stencil buffer allow me to update only what wasn't updated in first pass.

Now if you can guess why I have to do this, you're pretty smart ;-)
it's not a new game....
ector
Posts: 195
Joined: Thu May 12, 2005 10:22 pm

Post by ector »

SNES? :)
laxer3a
Posts: 23
Joined: Wed May 11, 2005 1:09 am

Post by laxer3a »

Yoyofr, it seems that we have been caught and we have a winner here :)
yoyofr
Posts: 23
Joined: Sat Jun 25, 2005 7:08 pm
Location: paris
Contact:

Post by yoyofr »

hehe, you're smart ector, really :-)
matkeupon
Posts: 26
Joined: Sat Jul 02, 2005 10:58 pm

Post by matkeupon »

Can someone help me with the functions and mask values ??

I'm trying to blit stuff with a transparent color. I use 5551 textures, and only using the rgba test and bilinear filtering, then my transparent color is displayed on edges (I guess because of the filtering, turning it off just works fine).

So I guess I'll need a color test, but I don't get how the function and mask work...

Note that I can set the color value to anything, so you can take any color you want as an example :)
matkeupon
Posts: 26
Joined: Sat Jul 02, 2005 10:58 pm

Post by matkeupon »

Don't bother, I figured it out...

sceGuAlphaFunc(GU_GREATER, 0x80, 0xff);

does it fine :)
flipinstyxs
Posts: 1
Joined: Wed Aug 03, 2005 10:06 am

Post by flipinstyxs »

sorry this doesnt have to do anything with this discussion but i just wanted to thank yoyofr for a job well done on his port of the SNES. i've been reading on some of the blogs you've been posting and i kinda knew the direction of where your talent was going...once again awesome job!...As a matter of fact i'll leave a little something this friday through paypal...hopefully it will buy at least a six pack of beers!
Post Reply