filtering between two textures

Started by
4 comments, last by MasterWorks 19 years, 2 months ago
Is it possible to let the 3D card filter between the sides of two textures so that you can't see a joint between two different textures that are tileable to each other? I hate these joints especially between two textures of a skybox.
Advertisement
Yes, by using multitexturing and appropriate texture coordinates. Alternatively, by using overlapping geometry and multipass blending. both can be used in eg. terrain rendering for smooth tile texture transitions.

BUT: if you get visible edges on a skybox, then this is a bug in your code. Skybox joints are 100% avoidable without resorting to any kind of blending or multitexture tricks, simply by applying accurate texture coordinates and borders.
If your textures are perfectly tilable then I think that you need to set how your card handles the edges of a texture. IIRC for OpenGL this is GL_CLAMP_TO_EDGE.

I'm not 100% sure. It's been a while for me

<hr />
Sander Marechal<small>[Lone Wolves][Hearts for GNOME][E-mail][Forum FAQ]</small>

Yeah, as Sander said, I think you will need to make sure your tiling is set to clamp mode. If it is in some kind of "tile" or "wrap" mode, the bilinear filtering will cause the texels at the left edge of the texture to be blended in to the texels at the right edge, as you approach U coordinate 1.0, for instance. At U 1.0, a pixel would be rendered with a 50/50 mix of the left and right edges - if you are using a tile mode. Unless you have made both the left and right edges of your texture tile very well with the second texture, you'll see a seam.

Probably it's better to use a clamp mode. If you get your coordinates lined up perfectly, you should be able to avoid a seam, but I think you will also see extra "redundant area" of a constant color at the edges that may be visually noticeable. For terrain, you might also consider switching to a more flexible system using some kind of alpha blending, so that you don't have to worry about these issues and you don't have to work really hard to make different textures tile against one another. For a skybox, you can probably make it work acceptably with clamp; you could also consider using a cube map, and just selecting a texel based on the direction. If you do that you don't need to worry about generating texture coordinates and you can use any geometry.
CLAMP_TO_EDGE is not sufficient to remove all seams. Basically, you need to create a 1 texel border around each side of the skybox, and fill it with the values from the respective opposite connected edge. Then, adjust the texcoords in such a way, that this extra border is just outside of the box geometry edges. Now, bilinear filtering will smoothly interpolate accross edge boundaries, without leaving the slightest seam.
In Direct3D (at least) I know a lot of us cheat by doing texture coordinates (.01,.01) -> (.99,.99) on a skybox instead of (0,0) -> (1,1). Sloppy but it WORKS!

This topic is closed to new replies.

Advertisement