Project section of a texture

i have this texture:

i only want one of those circles to been projected on the scene.
i can offset the projection coordinates to limit it to the lower left circle:

vec2 p = vec2( proj.x*0.333, proj.y*0.5 );
Attenuation *= texture2D( texture, p/proj.w ).r;

question: how do i have to offset the projection coordinates so that the other circles are projected? i guess those are not fixed values, but depend on the projector/fragment distance…

btw: i cannot post topics with firefox anymore, the forums always tell me that “the host from which you are accessing the board is not recognized as a valid host.”

You essentially want a scale-bias of the texture coordinates that work under projection, right? Well, you’ve figured out the scale already. For the bias all you have to do is multiply your bias with .w since that’s what you divide with in the end.

For instance, clip-space to texture coordinates:

texCoord = clipPosition;
texCoord.xy *= 0.5;
texCoord.xy += 0.5 * texCoord.w;

The last line there offsets by 0.5.

works fine, thanks! :smiley:

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