Hi
For projective texture mapping I’m computing the projection matrix M = TSP*V-1 where T is the translation by 0.5 in x, y, z, S is scaling by 0.5 in x, y, z, P is the projection with fov = 45, aspect 1.0, near .1, far 1. and V-1 is the inverse of the projector’s transformation. Then I enable GL_EYE_LINEAR and fill the four rows of M into the four texgen planes accordingly.
Now having texture parameters (of the texture to be projected) set to GL_REPEAT the projection is fine and of course repeated. Changing it to GL_CLAMP gives the projected texture but the four borders are then still repeated! The multiplication by P should transform the vector into the range [-1, 1] and the scaling/translating will map to the range [0, 1]. What can be the reason for this repeatness?
Sounds like you’re getting the correct behavior. What were you expecting GL_CLAMP to do? OpenGL only clamps the coordinates - but by the spec it still textures every fragment with a positive q. In every implementation I know of it textures fragments with negative q as well.
Bob, the texparams are set correctly.
Cass, then I can set a small (1 or 2 pixel) black boarder around the texture and the “repeated” part would be just black color and not something weird?
cass: I think the correct behaviour would be to clamp texture coordinates in the range [0,1]. If this is the case, why is the texture repeated ? IMO, the fact that coordinates are automatically generated does not skip the clamp operation.
[This message has been edited by vincoof (edited 02-05-2002).]
Clamping is done per-fragment, so it comes after texgen. Kon said the “borders are then still repeated”. This sounds to me like the filtered color half way between the border and edge texels is being smeared - which is the effect of GL_CLAMP.
Thanks Cass! Using GL_CLAMP_TO_BORDER_ARB gives the expected results. Unfortunately this extension is supported only on GeForce3 (and higher). Having a border of one texel the projected texture looks fine too.
And, CL_CLAMP_TO_EDGE doesn’t solve this problem.
Thanks
kon
[This message has been edited by kon (edited 02-05-2002).]