Sign in to follow this  
Daniel E

Vertex Texture Seams (DX9)

Recommended Posts

Daniel E    224
Hi

I'm desperately trying to align some heightmap textures in the vertex shader to create a seamless terrain.

When using a single texture for the heightmap, everything is fine:



But as soon as I try to do any sort of tiling, gross seams appear:



I've tried about everything I could think of:

- loading the tiles into one texture
- using a volume texture with one slice for each tile
- using one texture for each tile
- adding 1 pixel gutter border
- adjusting the UVs for bilinear filtering

This is the current vertex program (using one texture per tile):

pos.xy goes from 0 to 1.0
size of one tile is 64 pixel


VS_output vs_terr(VS_input input)
{
VS_output output;

float4 pos = { input.pos.x, 0, input.pos.y, 1 };

float2 uv = pos.xz * 63.0f;
uv += 0.5f;
uv /= 64.0f;

pos.y = tex2Dlod(heightMap, float4(uv, 0, 0)).x;

pos.xz *= SCALE;
pos.xz += offset.xy;

output.pos = mul(pos, MatWVP);

return output;
}



Fortunately I'm pretty positive that this can be done and has been done before :)

So any help would be highly appreciated.

edit: code was still using tex3Dlod

[Edited by - Daniel E on October 12, 2010 2:36:19 PM]

Share this post


Link to post
Share on other sites
Erik Rufelt    5901
Are you sure that the texture edges actually match up perfectly?

Usually when two adjacent heights are different, the triangle between them will add a slope between them. My guess is that with your tiling, you don't have any triangle between the edges of the tiles, but draw each tile separately. You need to either have one row of triangles between the tiles that correct this, or make sure that the heights are exactly the same at the edges of adjacent tiles.
If the edge heights are the same, try turning off bilinear filtering and make sure to use clamping for the texture edge address mode.

Share this post


Link to post
Share on other sites
Daniel E    224
Quote:
Original post by Erik Rufelt
Are you sure that the texture edges actually match up perfectly?

Usually when two adjacent heights are different, the triangle between them will add a slope between them. My guess is that with your tiling, you don't have any triangle between the edges of the tiles, but draw each tile separately. You need to either have one row of triangles between the tiles that correct this, or make sure that the heights are exactly the same at the edges of adjacent tiles.
If the edge heights are the same, try turning off bilinear filtering and make sure to use clamping for the texture edge address mode.


Oh, i think that might have completely escaped me. So a texture tile actually has to contain the borders of it's neighbours? Or did i get it wrong?

Share this post


Link to post
Share on other sites
Daniel E    224
Ok, I got it working by including the edges of the adjacent tiles. With bilinear filtering even. Thanks a lot!

Now i only have seams between different mip levels but i'm sure theres a solution for this as well.

Share this post


Link to post
Share on other sites
Daniel E    224
Hey it's me again.

I couldn't get rid of the seams between different mip levels after like 15 hours of trying :)

What i tried to do was including the texture borders of all mip levels below the current one. So the highest resolution tile contains n borders, the next one n-1 borders and so on. In the shader I chose the appropriate border based on the adjacent tiles. No success though.

So the tiles i create for the highest resolution looks like this:



The result is this:



Unfortunately i can't find any literature that addresses this, although i'm sure there is some.

Does anyone know how to handle this?

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