Sign in to follow this  
NewtonsBit

Ugly seams in cube terrain

Recommended Posts

I'm currently trying to generate procedural terrain from instanced cubes and I'm running into a serious problem: there are [url="http://i.imgur.com/oD2GS.jpg"]sporadic ugly seams[/url] between the instanced cubes. As far as I can tell, this is a floating point problem. But I have no idea how to fix it.


My vertex shader is quite simple, and takes input data in the form of bytes to generate the Position of the vertex.

[CODE]
// CALCULATE THE WORLD POSITION.
float4 position = float4(
(ChunkXLoc * 16.0f + input.CubeData.x + input.ChunkData.x) * 30,
(input.CubeData.y + input.ChunkData.y) * 30,
(ChunkZLoc * 16.0f + input.CubeData.z + input.ChunkData.z) * 30,
1.0f);


// TRANSFORM WORLD POSITION TO SCREEN SPACE.
output.Position = mul(position, ViewProj);
[/CODE]



Any ideas on how I can get rid of the seams?

Share this post


Link to post
Share on other sites
[quote name='Waterlimon' timestamp='1330021760' post='4915935']
[s]No idea[/s] (i realized that this actually was an idea), but try checking if the winding order of the vertices is right.
[/quote]

Culling counterclockwise at the moment. Changing this doesn't help.

Share this post


Link to post
Share on other sites
You could try to reduce the spread of the numbers involved by splitting your world into multiple sections where each section has its own coordinate system, this should reduce floating point inaccuracy problems.

Also, do the seems appear even if you zoom in on them and is that image showing the entire world or just a small part of it ?
If its only a small part of the world is it the center part or is it close to an edge of the world ?

What does the data you send to the shader look like ?

Share this post


Link to post
Share on other sites
[quote name='SimonForsman' timestamp='1330040979' post='4916025']
You could try to reduce the spread of the numbers involved by splitting your world into multiple sections where each section has its own coordinate system, this should reduce floating point inaccuracy problems.

Also, do the seems appear even if you zoom in on them and is that image showing the entire world or just a small part of it ?
If its only a small part of the world is it the center part or is it close to an edge of the world ?

What does the data you send to the shader look like ?
[/quote]

I fixed it by applying a depth bias based on slope. I don't think there's really any other solution at this point.

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