Results 1 to 5 of 5

Thread: gl_TexCoord[0]

  1. #1
    Junior Member Newbie
    Join Date
    Oct 2008
    Location
    South Africa
    Posts
    15

    gl_TexCoord[0]

    I am struggling here.

    I have problems with the accuracy of the call to gl_TexCoord[0].
    I am using GLSL and the GLUT architecture.

    in my vertex shader, i have the code:
    Code :
    void main() {
       gl_TexCoord[0]=gl_MultiTexCoord0; 
       gl_Position=ftransform();         
    }

    My Fragment Shader takes in a nxn texture and a nx1 texture.
    These two are multiplied together,
    but when i do multiply them together, then it doesnt take the exact coordinates (as my results arent the same through the fragment shader as through doing the calculation on the CPU)

  2. #2
    Senior Member OpenGL Pro dletozeun's Avatar
    Join Date
    Jan 2006
    Location
    FRANCE
    Posts
    1,367

    Re: gl_TexCoord[0]

    I do not understand how you want to multiply the nxn texture by the nx1 one. Can you elaborate a bit more what you are trying to do? The fragment shader code would be helpful too.

  3. #3
    Junior Member Newbie
    Join Date
    Oct 2008
    Location
    South Africa
    Posts
    15

    Re: gl_TexCoord[0]

    thanks for the further request.
    im looking to make a Jacobi Iteration on the GPU using GLSL.

    the fragment shader looks like this:
    Code :
    uniform sampler2D input_A;
    uniform sampler2D input_x;
     
    void main(void)
    {
        float A_Value,
              x_Value;
     
        A_Value = texture2D(input_A,vec2(gl_TexCoord[0].x, 1.0-gl_TexCoord[0].y)).x;
        x_Value = texture2D(input_x,vec2(0.5,1.0-gl_TexCoord[0].y)).x;        
     
        gl_FragColor = vec4(A_Value*x_Value);
    }

  4. #4
    Senior Member Frequent Contributor
    Join Date
    May 2005
    Location
    Prague, Czech Republic
    Posts
    913

    Re: gl_TexCoord[0]

    How do you calculate the texture coordinates and what filtering mode is set on those textures? It is possible that you sample different texels or even combination of them (if filtering is enabled).

  5. #5
    Junior Member Newbie
    Join Date
    Oct 2008
    Location
    South Africa
    Posts
    15

    Re: gl_TexCoord[0]

    The filtering on all of the Textures is: GL_NEAREST

    And the Coordinates are set in:

    Code :
        //Render Screen Aligned Quad
        glMatrixMode(GL_PROJECTION);   //select the Projection matrix
        glPushMatrix();                   //save the current projection matrix
        glLoadIdentity();
        glOrtho(0.0,float(window_Width),0.0,float(window_Height),-1,1);
        glMatrixMode(GL_MODELVIEW);
        glPushMatrix();
        glLoadIdentity();
    	//glBindTexture(GL_TEXTURE_2D,test_Texture/*output_Texture.getTexID()*/);
        //Render Quad
        glBegin(GL_QUADS);
    	glTexCoord2f(1.0f,0.0f);  glVertex3f(render_Width,render_Height, 0.0f);
    	glTexCoord2f(0.0f,0.0f);  glVertex3f(        0.0f,render_Height, 0.0f);
    	glTexCoord2f(0.0f,1.0f);  glVertex3f(        0.0f,         0.0f, 0.0f);
    	glTexCoord2f(1.0f,1.0f);  glVertex3f(render_Width,         0.0f, 0.0f);
        glEnd();
        //Return to Normal Projection
        glMatrixMode(GL_PROJECTION);
        //Load the previous Projection matrix (Generaly, it is a Perspective projection)
        glPopMatrix();
        //Select the Modelview matrix stack
        glMatrixMode(GL_MODELVIEW);
        //Load the previous Modelview matrix
        glPopMatrix();

Similar Threads

  1. non power-of-two textures and gl_TexCoord
    By g0l3m in forum OpenGL: GLSL
    Replies: 13
    Last Post: 05-13-2007, 07:45 PM
  2. What is "gl_TexCoord[0].st" ?
    By firegun9 in forum OpenGL: GLSL
    Replies: 7
    Last Post: 02-14-2007, 08:24 AM
  3. Accessing gl_TexCoord[0].p
    By cof in forum OpenGL: GLSL
    Replies: 4
    Last Post: 11-10-2005, 02:17 AM
  4. Replies: 1
    Last Post: 04-25-2005, 01:03 AM
  5. gl_TexCoord[] indexing
    By Aeluned in forum OpenGL: GLSL
    Replies: 1
    Last Post: 05-17-2004, 10:34 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean