Skip to main content
GameDev.net gamedev.net
🔒 Locked 🎮 Unity

Ugly seams in cube terrain

Started by NewtonsBit Feb 23, 2012 at 6:25 PM 3 replies 1.4k views
Original Post
NewtonsBit
NewtonsBit
I'm currently trying to generate procedural terrain from instanced cubes and I'm running into a serious problem: there are sporadic ugly seams 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.


// 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);




Any ideas on how I can get rid of the seams?
Waterlimon
Waterlimon
[s]No idea[/s] (i realized that this actually was an idea), but try checking if the winding order of the vertices is right.
o3o
NewtonsBit
NewtonsBit

[s]No idea[/s] (i realized that this actually was an idea), but try checking if the winding order of the vertices is right.


Culling counterclockwise at the moment. Changing this doesn't help.
SimonForsman
SimonForsman
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 ?
[size="1"]I don't suffer from insanity, I'm enjoying every minute of it.
The voices in my head may not be real, but they have some good ideas!
NewtonsBit
NewtonsBit

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 ?


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

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.