Game Development Community

Terrain Texture Tiling Problem

by Josh Albrecht · in Torque Game Engine · 07/27/2005 (11:31 am) · 12 replies

I'm sure many of you are familiar with this problem. I am referring to the lines that appear at the 'seams' of textures used for TerrainBlocks in Torque. I searched the site looking for a way to remove these lines, but could not find any solutions. I did see mention of a seemless terrain texture pack by BraveTree back in 2002, but have no idea how they did it.

Here are some images of the problem, in case you've never been lucky enough to witness it :)

img280.imageshack.us/img280/1636/screenshot005000013ew.pngimg280.imageshack.us/img280/6402/screenshot005000021ty.pngimg280.imageshack.us/img280/6987/screenshot005000039ju.pngimg280.imageshack.us/img280/2955/screenshot005000042fm.png
You'll notice that the problem dissapears as the camera moves away from the terrain, but it's visible for quite some ways, and looks terrible. We've tried using textures that tile, but the problem still happens. I tried blurring the edges of the detail texture (in case maybe the detail texture wasnt able to tile correctly or something), but that also did not remove the seams.

So I'm stumped. Does anyone know of any solutions? Does anyone have any other ideas for fixing this problem?

#1
07/27/2005 (11:41 am)
First thing, is the texture tileable?
Second, what size is your texture, I believe that you should have at maximum a 512x512 texture. To see the effects of this, draw a big red x over your texture, and then play your game, if it is hacked off at one side or in the middle or some such, then reduce the size of your texture in half or so.

Other then that, I haven't seen any of the same problems you are having with tileable textures.
#2
07/27/2005 (11:43 am)
You just need to make seamless textures... try downloading www.fileplanet.com/dl.aspx?/planetstarsiege/garagegames/VirtuallyInfiniteSystems... and giving them a try.
#3
07/27/2005 (11:52 am)
This rings a bell.
i think there may be some problem other than just a non-seamless texture.
search the forums/resources more..
#4
07/27/2005 (12:18 pm)
Thanks for the replies! Unfortunately, the problem still remains. :(

I am using seamless textures. I tried some of the textures (and some of the detail textures) in the pack, and they didnt work any better than the textures in the above images. I tried searching the forums and resources a few more times, but didnt find any solution to this problem. I am using 256x256 textures and a 256x256 detail texture.

Also, this exact same problem happens in the Torque Demo.

Any more ideas?
#6
07/27/2005 (12:52 pm)
Yep, that fixed it. Thanks a ton Orion!

I wonder why this isnt in the HEAD...
#7
07/27/2005 (1:36 pm)
Hmmm... I thought it had been.

Good question.
#8
07/27/2005 (6:18 pm)
Added to 1.4. #221.
#9
07/27/2005 (8:36 pm)
I'm unsure about the fix here. The proposed fix is to alter textures used for terrain. I would argue that the textures should not be unilaterally altered by the engine. Instead, there should be an option to enable anti-aliasing of textures to varying degrees. The artifacts being seen are likely caused by the stretching/manipulation of the texture when it is mapped. A single texel is likely sampled for each pixel on-screen, which can cause huge problems near the edges of a texture or pattern. If the engine were to sample multiple texels and anti-alias to compute the on-screen pixel value, then these artificts would probably disappear. This would have the added bonus of being the visually correct solution for all situations, including when different textures border each other.

-Raystonn
#10
07/27/2005 (8:42 pm)
Given the fact that OpenGL and Direct3D are handling this for Torque, the simplest way to implement an anti-aliasing technique across all hardware would be to render to an off-screen buffer that is twice as wide and tall as the actual screen buffer and then combine every 2x2 group of 4 pixels into a single pixel. This form of anti-aliasing is called super sampling. There is likely a way to get OpenGL and/or Direct3D to enable such anti-aliasing in hardware, but GPU hardware is not my specialty.

-Raystonn
#11
07/27/2005 (8:50 pm)
I'd also like to point out that part of the problem is lighting. Since each face being mapped has a slightly different orientation, and hence normal, neighboring terrain polygon faces may have different levels of brightness, which will make their borders quite obvious. While anti-aliasing reduces this effect to some degree, the proper fix is to calculate lighting on a per-pixel basis where the normal of each pixel is interpolated based on the normals of the closest polygon faces rather than using one normal for the entire polygon face. This gives the illusion of truly rolling hills as light will bounce off the hills as if they are true curves rather than blocky polygonal surfaces.

-Raystonn
#12
07/27/2005 (10:54 pm)
Actually, terrain is not lit normally (only lightmapped), and the issue is that the blender is not properly outputting texels in certain cases - the textures are always being modified, so what's a little more/less? This is a cheap startup fix, too, which doesn't cause many noticeable artifacts, since it isn't actually at the texel level... (More like the alphel.)