hi folks, i’d like to do a projective texture fetch within an ARB fragment program to enable a kind of shadow mapping. the texture i’m currently using is a shadow map of type GL_TEXTURE_2D. i want to compute the texture coordinates based on the fragment.position.
TEMP texcoord, texcol, res;
MOV texcoord, fragment.position;
set texcoord.w to screendim.x
MOV texcoord.w, program.local.x;
TXP texcol, texcoord, texture, 2D;
SGE res, texcol, fragment.position;
res.z should be 1.0 if fragment is in light
MUL result.color, fragment.color, res.zzzz;
The local parameter program.local contains the dimensions of the squared screen in its x coordinate which is a power of two.
the fragment program works fine, except for some scattered pixels which are lit when they shouldn’t and vice versa.
since i’m new to shader programming i believe i do a misstake somewhere but i couldn’t find out. any hints are welcome.