CLAMP, CLAMP_TO_EDGE and CLAMP_TO_BORDER

I cant understand the difference betwen this three methods (I’ve read the opengl 1.3 specification a lot of times), CLAMP uses the border texels, but what happens is I set the border value to 0 at glTexImage2d?

Thanks in advance

If you use GL_CLAMP, which uses the border texels, and the border is 0 (black), then in bilinear (and above) filtering, it will sample the black border, when calculating texel values for the edge of the texture.

If you have a skybox for instance, or a cubemap, this is seen as black lines appearing between textures.

You wont actually see this on GF3, because GF3 treats GL_CLAMP as GL_CLAMP_TO_EDGE.

CL_CLAMP_TO_EDGE, forces it to only sample pixels from the actual texture, not the border, so you dont get this black line sympton.

As far as GL_CLAMP_TO_BORDER goes, I dont know what this extension does.

Hope this helps a bit,

Nutty

CLAMP_TO_BORDER causes OpenGL to only take the border color at the edge of the texture rather than the average of the border color and texture edge texels. This allows for a perfect border around the texture.

I believe the question he tries to ask is: “what is the color of the border when I specify a 0 sized border”

My guess is it is undefined, though I was too lazy to look it up for real :slight_smile:

[This message has been edited by jwatte (edited 01-19-2002).]

I believe when the border parameter is 0, it still samples from a black border, when texels taken for a filter are outside of the current texture.

WRT the CLAMP_TO_EDGE and CLAMP distinction, we have a little test app which illustrates this to some degree. Note that many implementations don’t get GL_CLAMP right, but this matters little in games since the GL_CLAMP_TO_EDGE behavior is what the overwhelming majority of developers expect when using GL_CLAMP. TRIBES, for example, shipped with this wrong and had to issue a patch using the GL_CLAMP_TO_EDGE extension to eliminate the black grid lines that showed up on their terrain on implementations which did GL_CLAMP right.

-Jason

On NVIDIA hardware correct clamping needs to be enabled in the registry. It’s kind of strange but GL_CLAMP_TO_EDGE does not work correctly unless you set OGL_TexClampBehavior to 1 in the registry.

There was a topic on this some time ago and the NVIDIA guys said that enabling this by default would break a lot of applications.

That is, they said that correct GL_CLAMP behaviour could not be enabled by default but why GL_CLAMP_TO_EDGE isn’t handled correctly is strange.

[This message has been edited by PH (edited 01-20-2002).]