1. This forum section is a read-only archive which contains old newsgroup posts. If you wish to post a query, please do so in one of our main forum sections (here). This way you will get a faster, better response from the members on Motherboard Point.

GL_CLAMP_TO_BORDER and GL_CLAMP_TO_EDGE ?

Discussion in 'Nvidia' started by Skybuck Flying, Sep 24, 2009.

  1. Hello,

    I am trying to make sense of the following documentation:

    OpenGL 2.1 Reference documentation:

    http://www.opengl.org/sdk/docs/man/

    "
    glTexParameter - set texture parameters
    "

    "
    GL_TEXTURE_WRAP_S

    Sets the wrap parameter for texture coordinate s to either GL_CLAMP,
    GL_CLAMP_TO_BORDER, GL_CLAMP_TO_EDGE, GL_MIRRORED_REPEAT, or GL_REPEAT.
    GL_CLAMP causes s coordinates to be clamped to the range [0,1] and is useful
    for preventing wrapping artifacts when mapping a single image onto an
    object. GL_CLAMP_TO_BORDER causes the s coordinate to be clamped to the
    range -12N1+12N, where N is the size of the texture in the direction of
    clamping.GL_CLAMP_TO_EDGE causes s coordinates to be clamped to the range
    12N1-12N, where N is the size of the texture in the direction of clamping.
    GL_REPEAT causes the integer part of the s coordinate to be ignored; the GL
    uses only the fractional part, thereby creating a repeating pattern.
    GL_MIRRORED_REPEAT causes the s coordinate to be set to the fractional part
    of the texture coordinate if the integer part of s is even; if the integer
    part of s is odd, then the s texture coordinate is set to 1-frac?s, where
    frac?s represents the fractional part of s. Border texture elements are
    accessed only if wrapping is set to GL_CLAMP or GL_CLAMP_TO_BORDER.
    Initially, GL_TEXTURE_WRAP_S is set to GL_REPEAT.
    "

    I am especially confused about the following lines:

    "
    GL_CLAMP_TO_BORDER causes the s coordinate to be clamped to the
    range -12N1+12N, where N is the size of the texture in the direction of
    clamping.GL_CLAMP_TO_EDGE causes s coordinates to be clamped to the range
    12N1-12N, where N is the size of the texture in the direction of clamping.
    "

    The only difference I can see is "coordinate" and "coordinates".

    I am confused about this option... and especially the range description:
    "-12N1+12N"

    What the hell does that mean ?

    I am also a little bit confused about GL_CLAMP but I think I understand
    that.

    Suppose my texture coordinates have range 0 to 1000... then GL_CLAMP would
    always "clamp" this to 0..1.

    So that would be bad because I would like to keep range 0 to 1000... so I
    would need to use another option...

    So that's why I am interested in the border or edge option... I just wanna
    make sure I understand it correctly...

    So some questions:

    1. Are these two options the same thing ? (yes/no will do for now see
    question 4 ;))

    Suppose my texture coordinates are 800 x 600

    2. Will border option clamp to 800x600 ?

    3. Will edge option clamp to 800x600 ?

    4. Is there a conceptual difference between these two options: border and
    egdge ?
    If so... then what's the difference, what's the concept for both ?

    Bye,
    Skybuck.
     
    1. Advertising

    1. Advertising

  2. "Skybuck Flying" <> wrote in message
    news:3883f$4abaf6f9$d53372a9$1.nb.home.nl...
    > Also I noticed another difference between these two options...
    >
    > One is - +
    >
    > The other is + -
    >
    > Time for me to read up on the concept of texture borders:
    >
    > Maybe this doc will help ;):
    >
    > http://www.opengl.org/resources/code/samples/sig99/advanced99/notes/node64.html


    The texture border is a 1 pixel border around the texture... normally opengl
    will mix the texels at the edge with the borders...

    So I guess the "edge" can be considered the last pixels of a texture.

    The border can be considered the pixels outside/around the texture.

    OpenGL also allows the border color to be specified.

    I will not be dealing with borders, so I want to get rid of the border.

    I also do not want any filtering... so nearest will do just fine...

    So from that doc I think this clamp to edge will do just fine:

    "
    GL_CLAMP_TO_EDGE

    This mode clamps the texture coordinates such that the texture border is
    never sampled. The filtered color is derived only from texels at the edge of
    the texture image.
    "

    Hoping that it works fingers crossed ! ;) :)

    Me better save that document it's a good explanation of texture borders and
    edges ! ;)

    Also I am not yet sure if texture coordinates always have to be from 0 to 1
    for clamping to work...

    I should be able to specify the texture dimensions/range somewhere ;) /
    texture coordinate ranges ;) (? Hmm ;))

    I already tested what happens when large texture coordinates are passed to
    vertex and pixel shader they come through just fine... not sure what happens
    when clamping is enabled ? and tex2d is done ? me-to-find-out ;) :)

    Bye,
    Skybuck.
     
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Squigmont
    Replies:
    0
    Views:
    402
    Squigmont
    Feb 12, 2006
  2. Steven C \(Doktersteve\)

    Dell and shipping and confusion and little white lies.

    Steven C \(Doktersteve\), Dec 6, 2003, in forum: Dell
    Replies:
    1
    Views:
    381
    WSZsr
    Dec 6, 2003
  3. Mr. Big
    Replies:
    8
    Views:
    356
    Bostjan
    Oct 20, 2003
  4. Product Solution
    Replies:
    0
    Views:
    746
    Product Solution
    Dec 9, 2004
  5. Replies:
    0
    Views:
    271
Loading...

Share This Page