Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: Querying Textue Coordinate in Fragment Shader

  1. #1
    Intern Contributor
    Join Date
    Sep 2007
    Location
    Southern California
    Posts
    60

    Querying Textue Coordinate in Fragment Shader

    I want to do color bayer processing in a GLSL fragment shader. In order to determine whether the texel is red, green or blue, I need to know what the X and Y offsets are.

    Is there a function available in a fragment shader that will give me the X and Y position of that texel, or do I have to do this in a vertex shader and pass the information on to the fragment shader in a varying vec2 variable?

  2. #2
    Senior Member OpenGL Guru
    Join Date
    May 2009
    Posts
    4,713

    Re: Querying Textue Coordinate in Fragment Shader

    The fragment shader must have a texture coordinate in order to access a texture. Where it comes from is up to you. You could make one up out of thin air, via some algorithm, or from per-vertex data passed from earlier in the rendering pipeline.

  3. #3
    Intern Contributor
    Join Date
    Sep 2007
    Location
    Southern California
    Posts
    60

    Re: Querying Textue Coordinate in Fragment Shader

    Thanks Alfonse.

    If I understand you, the coordinate that I'm looking for is the variable 'gl_TexCoord[0].st' that I use in my Texture Sampler Access function 'texture2D()'.

    So if I'm using GL_TEXTURE_2D sampler access, I'll get value 0 - 1 for the X and Y values, and if I use GL_TEXTURE_RECTANGLE, I'll get actual discreet pixel values.

    Am I getting warmer?

    Thanks.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •