Arb_fragment_program texture determination

i am trying to write a simple arb_fragment_program that checks if there is a texture bound to to the fragment or not. if there is a texture, it takes the color from the texture and multiplies it with the fragment.color. if not, it takes only the fragment.color.

to do the checks, i use the standard return values of TEX and modify them to get a negative/positive number that is passed to KIL. the documentation on ARB_fragment_program sais that the return values of TEX are (R=0, G=0, B=0, A=1).

so i wrote this code:

!!ARBfp1.0
OUTPUT out = result.color;
MOV out, fragment.color;
TEMP temp;
TEX temp, fragment.texcoord[0], texture[0], 2D;
TEMP istex;
ADD istex.x, temp.x, temp.y;
ADD istex.x, istex.x, temp.z;
ADD istex.x, istex.x, -0.001;
KIL istex.x;
MUL out, fragment.color, temp;
END

this would work if TEX would return the values that it should return. but it returns (R=0.443, G=0.522, B=0.188, A=1).

I am willing to bet you have a texture bound left over from another render call.

Besides, just enable alpha testing against zero then bind a dummy texture with (0,0,0,0) in all stages that you care about and just do the multiply against the diffuse.

This is simple, faster (no Kill instruction) and certain to work.

ok, i’ll do that.
btw. nice nickname :slight_smile:

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.