• Advertisement
Sign in to follow this  

texture rectangle in a shader

This topic is 3915 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Suppose I use a texture rectagle in a shader, eg I've drawn it as
glBegin(GL_QUADS);
    glTexCoord2f(0.0, 0.0); 
    glVertex2f(0.0, 0.0);
    glTexCoord2f(texSize, 0.0); 
    glVertex2f(texSize, 0.0);
    glTexCoord2f(texSize, texSize); 
    glVertex2f(texSize, texSize);
    glTexCoord2f(0.0, texSize); 
    glVertex2f(0.0, texSize);
glEnd()
Then in my shader I want to read an offset from the current pixel in the calculation, for a usual texture we can simply calculate the offset as below:
float offset = 1/texsize
vec2 bl=vec2(tex2D(tex,coords+offset)) +
        vec2(tex2D(tex,coords-offset); 
glFragColor=bl;
However, for a rectangle texture can I simply do the following?
float offset = 1;
vec2 bl=vec2(tex2D(tex,coords+offset)) +
        vec2(tex2D(tex,coords-offset); 
glFragColor=bl;
cheers

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement