Tex coords to geometry shader duplication

Hi,

I’m using a simple geometry shader to try and perform some calculations on specific areas of an input texture. I’ve got a 512x512 input texture, and am trying to perform some calculations only on the border pixels of this image. So, what I’m doing is the following (for example):

    
    glUseProgramObjectARB(edgeProgram);
    glUniform1iARB(samplerLoc, 0);
    
    glClear(GL_COLOR_BUFFER_BIT);
    glBegin(GL_LINES);
    {
        //Bottom Line.
        glTexCoord2f(0, 0);   glVertex3f(-1.0 + pixelVertexStep,  -1 + pixelVertexStep, -0.5f);
        glTexCoord2f(.25, 0); glVertex3f(-0.5,                    -1 + pixelVertexStep, -0.5f);
        
        glTexCoord2f(.25, 0); glVertex3f(-0.5 + pixelVertexStep , -1 + pixelVertexStep, -0.5f);
        glTexCoord2f(.5, 0);  glVertex3f( 0.0,                    -1 + pixelVertexStep, -0.5f);
        
        glTexCoord2f(.5, 0);  glVertex3f( 0.0 + pixelVertexStep,  -1 + pixelVertexStep, -0.5f);
        glTexCoord2f(.75, 0); glVertex3f( 0.5,                    -1 + pixelVertexStep, -0.5f);
        
        glTexCoord2f(.75, 0); glVertex3f( 0.5 + pixelVertexStep,  -1 + pixelVertexStep, -0.5f);
        glTexCoord2f(1, 0);   glVertex3f( 1.0,                    -1 + pixelVertexStep, -0.5f);
    }                     
    glEnd();
    glUseProgramObjectARB(0);

For each edge (in this case, I’m doing the bottom edge), I render 4 short lines. For each of these lines, my geometry shader spits out 128 points containing new color calculations based on the sampled texture.

My vertex shader is the following:

void main(void)
{
    gl_TexCoord[0]  = gl_MultiTexCoord0;
    gl_Position = gl_Vertex;
}

My geometry shader is the following:


uniform sampler2D TexUnit;

void main()
{ 
    for (int i=0; i<128; i++) {
        gl_FrontColor = texture2D(TexUnit, gl_TexCoord[0].st + float(i)/128.0);
        EmitVertex();
    }
}

The problem I’m seeing when I run this is that the sampled texture points are repeated for each of the four segments. As mentioned previously, I’m specifying the appropriate texture offset steps of each of these 4 line steps as follows:

        glTexCoord2f(0, 0);   glVertex3f(-1.0 + pixelVertexStep,  -1 + pixelVertexStep, -0.5f);
        glTexCoord2f(.25, 0); glVertex3f(-0.5,                    -1 + pixelVertexStep, -0.5f);

So that each line should sample just one quarter of the texture.

It’s very possible that I’ve misunderstood something here about how the specified texture coordinates via glTexCoord2f(…) get passed on to the vertex shader and on to the geometry shader, but I’m really confused as to why each quarter appears to be sampling from the exact same region.

Any ideas would be greatly appreciated!

jim