GL_CLAMP_TO_EDGE problem

Started by
15 comments, last by krez 14 years, 11 months ago
I'm having problem with figuring it out. I'm using in this example 4 quads that are connected and I'm using one tile texture. I used GL_CLAMP before, then switched to GL_CLAMP_TO_EDGE and the other problem appeared. The pixels on border doesn't fit in with pixels with other pixels in the quad that is near it. I've tried with couple of versions of glext.h, none worked. I've read numerous threads about solving this problem and what I found in them that this won't solve problem. Is that wrong, how can I use tiles differently, since I'd like to use them to make a terrain map. This is a picture of this problem: http://i437.photobucket.com/albums/qq91/CTPAX216/slika.png
Advertisement
Why dont you render 1 large quad and repeat the texture over it 4 times?
Sig: http://glhlib.sourceforge.net
an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhLoadIdentityf2(matrix);
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhRotateAboutXf2(matrix, angleInRadians);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);
I see my example is little bit confusing. I want to make a terrain, so I'll use small quads with different textures. I've used only one here to see that they don't fit in, but I've got some textures ready that mixes different kind of terrain(grass with mud) so the terrain can get it's final look.
Is there anyone who know solution to this? Or is it too trivial task to explain? I think it's not trivial, I need your help to solve it.
You haven't made clear what the issue is but I'm sure it has nothing to do with
GL_CLAMP_TO_EDGE. For all I know, the problem is the artwork itself that doesn't tile well.
Sig: http://glhlib.sourceforge.net
an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhLoadIdentityf2(matrix);
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhRotateAboutXf2(matrix, angleInRadians);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);
It's not problem with artwork... I've tried a couple of them.. If you do picture offset in Photoshop you should be able to see if the picture can not be tiled. I've read somewhere that there's problem with GL_CLAMP_TO_EDGE and Mipmaps, but there's problem with plain linear filtering, and what I read didn't make much sense... I guess nobody here can answer me this...
Quote:Original post by CTPAX
I guess nobody here can answer me this...

I would, but my reply would be on an outdated method which probably has a better alternative already. The problem you have is that the last texel in one texture doesn't get filtered with the first texel of the next texture - so the former gets extended and then the latter appears sudden of all, without any blending at all.

I wonder if that helps at all.
Don't pay much attention to "the hedgehog" in my nick, it's just because "Sik" was already taken =/ By the way, Sik is pronounced like seek, not like sick.
Quote:Original post by Sik_the_hedgehog
Quote:Original post by CTPAX
I guess nobody here can answer me this...

I would, but my reply would be on an outdated method which probably has a better alternative already. The problem you have is that the last texel in one texture doesn't get filtered with the first texel of the next texture - so the former gets extended and then the latter appears sudden of all, without any blending at all.

I wonder if that helps at all.

That is my guess as well. For the two tiles next to each other to blend seamlessly, the filtering in the borders needs access to the texels from the neighboring tiles to blend with. Can be solved by replicating the tile data from adjacent tiles into other tiles. For example, if a tile is 32x32 texels, make it 34x34, where the outer border corresponds to the texel values of the neighboring tiles. Texture coordinates can then select the center 32x32 tile, while keeping filtering proper in the border case.
Thanks for the reply, guys, but it didn't help.. It's updated method of course, if you have a better way, please help me... GL_CLAMP_TO_EDGe is version 1.3 I think...
Maybe I'm missing something here, but why don't you just use GL_REPEAT? That would blend the edges with the opposite sides.
--- krez ([email="krez_AT_optonline_DOT_net"]krez_AT_optonline_DOT_net[/email])

This topic is closed to new replies.

Advertisement