Jump to content
  • Advertisement
Sign in to follow this  
Conoktra

OpenGL Terrain Tile Seams

This topic is 2941 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello. I am the lead programmer for an open source RTS game. We are getting close to our first big release, and as such the code needed to be ported to windows (32-bit XP).

It originally ran on Linux using a NVIDIA card (9500 GT). It looks great running on Linux! But, when porting the code to Windows a hideous problem emerged in the terrain system.

drum role please.....

There are nasty seams between the terrain tiles!!! I am running the code on the same computer, only under Windows XP rather than Linux. Same drivers, same hardware, etc.

Here are a couple of pictures to help illustrate the problem.
The Linux port: http://img84.imageshack.us/img84/2686/noseamsscreenshot.jpg
The Windows port: http://img269.imageshack.us/img269/9443/seamsscreenshot.jpg

As you can see there are nasty seams in between the tiles when running it on Windows. The Linux port, however, does not suffer from this issue.

The terrain system works in a similar way to Warcraft 3's. Each tileset has a base texture, then a series of transitioning tiles. The engine chooses the appropriate tile depending on the adjacent tiles, and layers them if necessary.

I have encountered this problem before, but was able to fix it (or suppress it, more likely) by breaking each sub-tile in each tileset into a separate texture, rather than keeping the sub-tiles tiled in a single texture. I then hand each texture as a layer in a texture array to OpenGL.

This suggests to me that there is a texture wrapping problem, and that OpenGL is tiling the texture(s) ever-so-slightly at the edge of the tiles, resulting in the seams.

So, I set the texture parameters to GL_CLAMP as such:

glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_WRAP_T, GL_CLAMP);


But, that only made the problem worse.

Here is the relevant code (pertaining to texture wrapping):

GLenum internalFormat = GL_RGBA;
GLenum format = GL_RGBA;
s32 w = 128;
s32 h = 128;
s32 d = numberOfTilesets * 16;
u8 * Pixels = new u8[w * h * d * 4];

glBindTexture(GL_TEXTURE_2D_ARRAY, textureID);

glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_WRAP_T, GL_CLAMP);
glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_GENERATE_MIPMAP, GL_TRUE);

glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, internalFormat, w, h, d, 0, format, GL_UNSIGNED_BYTE, Pixels);


Has anybody here encountered problems like this before, and know a (preferably) quick and easy fix?

Thanks beforehand!

P.S: Yes, the bright orange Lava is animated! :D

Share this post


Link to post
Share on other sites
Advertisement
Firstly, that looks pretty cool!

Secondly, have you tried this:

glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);

Share this post


Link to post
Share on other sites
They don't look like seams so much as cracks -- a geometry artifact rather than a pixelfill one.

Are you sharing the verticies at the corners between the tiles? If you're not then there can be pixel errors in the rasterisation for each quad which would lead to that effect. The errors could differ substantially between driver implementations which would explain why the same code works OK on linux.

Share this post


Link to post
Share on other sites
Quote:
Original post by AndyEsser
Secondly, have you tried this:

glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);


I had completely forgotten about GL_CLAMP_TO_EDGE! *sigh*. Well, that was definitely a quick and easy fix, thank you!

Quote:

Original post by AndyEsser
Firstly, that looks pretty cool!


Thanks! Yah, the project is completely open source and free. We are going to make our first landmark release here soon, but want to stay, err, secluded until we are ready to amaze the open source world. :D

@Katie: Thanks for your input as well! :D

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!