Texture has seam

Started by
5 comments, last by Jernej.L 18 years, 9 months ago
Hi, I have a problem with textures: If I draw a textured quad at the size of 512x512 with a texture of 256x256 it gets a seam around it. Only solution so far is to disable texture interpolation (GL_LINEAR). I googled for a while now but it seems I'm the only one who has this problem? The texure is part of a 512x512 texture. Regards Thomas
Advertisement
When you load your texture, use 0 for the border.

glTexImage2D

Hope that works.
I know ATI cards have an option to enable "Alternate Pixel Center", but that's only for Direct3D. The problem might be with your graphics card specifically. What graphics card do you have?
@Mark: Thanks, but I already used 0...

@evanofsky: It's a GF4... It looks like the last row of the image and the next line in the bigger texture (currently just a yellow color) get interpolated together (that seems reasonable because normally you would continue to use the texture on the next polygon).
Quote:Original post by TrueTom
@Mark: Thanks, but I already used 0...

@evanofsky: It's a GF4... It looks like the last row of the image and the next line in the bigger texture (currently just a yellow color) get interpolated together (that seems reasonable because normally you would continue to use the texture on the next polygon).


Well in that case, try altering the clamp mode for the texture glTexParameteri

GL_TEXTURE_WRAP_T/GL_TEXTURE_WRAP_S with GL_CLAMP

Of course I read somewhere you should suck in the pixel uvs by 0.32xxx or some strange value to compensate for filtering. I personally never liked doing that, and instead add 0.5 to the x,y vertex coordinates. (this seems to work in directx too)
I already tried GL_CLAMP but also doesn't work, because it interpolate the borlder with the pixel line of the opposite side border...

It's seems CLAMP_TO_EDGE_EXT would do the job but I can't try it out at the moment (Opengl 1.2)...
then your opengl probably supports gl_clamp_to_edge_sgis extension? the constant is same as gl_clamp_to_edge.. otherwise just live with seams and make gl_clamp_to_edge work properly on better opengl implementations.

edit:

use clamping texture edges like this:

procedure ClampBorders(const yes: boolean);
begin
if yes = false then begin
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
end else begin
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
end;
end;

this works tested on Geforce 4 mx440...
do this for every texture while creating it.

btw, geforce 4 supports opengl 1.5 at least, get new drivers from nvidia.

Projects: Top Down City: http://mathpudding.com/

This topic is closed to new replies.

Advertisement