Sign in to follow this  
CTPAX

GL_CLAMP_TO_EDGE problem

Recommended Posts

CTPAX    122
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

Share this post


Link to post
Share on other sites
CTPAX    122
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.

Share this post


Link to post
Share on other sites
CTPAX    122
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.

Share this post


Link to post
Share on other sites
V-man    813
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.

Share this post


Link to post
Share on other sites
CTPAX    122
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...

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Brother Bob    10344
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.

Share this post


Link to post
Share on other sites
CTPAX    122
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...

Share this post


Link to post
Share on other sites
krez    443
Maybe I'm missing something here, but why don't you just use GL_REPEAT? That would blend the edges with the opposite sides.

Share this post


Link to post
Share on other sites
CTPAX    122
GL_NEAREST solves the problem, but it looks really ugly with grass... And the problem is solved because GL_NEAREST doesn't sample pixels at all, so it doesn't matter to him if you set GL_WRAP, GL_CLAMP, GL_CLAMP_TO_EDGE...

Share this post


Link to post
Share on other sites
Quote:
Original post by Brother Bob
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.

That would work if it is guaranteed that the surrounding tiles have always the same exact textures. I don't think it's his case though (remember he said he'd expand on it to generate larger meshes).

Quote:
Original post by CTPAX
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...

Er, what I was gonna say was using texture borders and GL_CLAMP, that's what they were made for XD But then again, I bet there's a better method now. My knowledge is mostly from 1.1, I seriously need to relearn the API, but I don't have time x_x

Quote:
Original post by krez
Maybe I'm missing something here, but why don't you just use GL_REPEAT? That would blend the edges with the opposite sides.

That would blend against the edges of the opposite side of the texture of that same tile. He needs it to blend with the edge of the texture of the tile next to it. Using GL_REPEAT will just make it look worse.

Share this post


Link to post
Share on other sites
CTPAX    122
The problem with the borders is that they are black... You can set the border color, but the result will be very ugly... You could see from an airplane where the texture ends... I don't know why they did it like that...

Share this post


Link to post
Share on other sites
Brother Bob    10344
Quote:
Original post by Sik_the_hedgehog
Quote:
Original post by Brother Bob
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.

That would work if it is guaranteed that the surrounding tiles have always the same exact textures. I don't think it's his case though (remember he said he'd expand on it to generate larger meshes).

You have to design your tiles so all borders can connect. You just don't make this work with any arbitrary set of tiles. It is a problem that must be solved, and ensuring adjacent tiles connect is something you must design. I don't see that as unrealistic to have tile borders of the same kind to be identical.

Share this post


Link to post
Share on other sites
Fiddler    860
How about making the tiles slightly overlapping and blending between the textures on the transitions? I've read a tutorial that implements this, but I can't seem to find the link...

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this