Jump to content
  • Advertisement
Sign in to follow this  
Magogan

Random Sky Pixels Shine Through Between Triangles

This topic is 854 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi,

 

I'm developing a voxel game and I have noticed that the sky randomly shines through between blocks. I fixed this by making the blocks a little bit bigger so they intersect each other, but this doesn't look good either, especially when displaying a selection box for a voxel. Is there any fix beside that?

 

- Magogan

Share this post


Link to post
Share on other sites
Advertisement

If your voxels exactly line up, the sky shouldn't show through. How are you calculating the vertices of the voxels? If adjacent vertices/edges use the exact same calculations, things should line up perfectly.

Edited by phil_t

Share this post


Link to post
Share on other sites

They exactly line up with the same coordinates for the vertices of adjacent blocks. However, the sky is still visible randomly. As far as I can see this only happens at edges (where adjacent triangles/faces are not on the same plane).

 

They sometimes don't line up for I do some optimizations and combine some blocks to reduce the number of vertices. So you have something like this:

_____

|____|

|__|__|

 

A------B

C--E--D

F--G--H

 

So you have the rectangles ABCD, CEFG and EDGH (with two triangles each). The coordinates are exact, but they get messed up because of floating point precision limits when transformed and projected.

Edited by Magogan

Share this post


Link to post
Share on other sites

It's common practice to not have intersections like that, you would 'stitch'.

This is height map based but the need to stitch is the same. Every big triangle has subdivisions to match the smaller neighbours. If you just moved the smaller ones to be in line with the big triangles there would be errors like you describe

 

WireFrame.jpg

Share this post


Link to post
Share on other sites

Yeah, T-junctions are a thing to avoid, because floating-point inaccuracy means that you cannot guarantee that the junction point (E in your example) is actually collinear with the other two points (C and D), especially after transformation. In practice, you would also want to emit triangle CDE specifically to cover up any gaps arising due to this.

Share this post


Link to post
Share on other sites
If you use rectangles I don't think there are any solutions. If you can also use triangles, the solution I like is making the criterion for refinement a property of the edge. So the same criterion will be applied to the edge when considering it on both sides, and the tessellation will be consistent by design.

Share this post


Link to post
Share on other sites

I use 2 triangles per rectangle. However, there is a solution for rectangles: You can just add the "missing" triangles for every T-junction. But this solution is not trivial for cuboids in 3 dimensions, there are many cases you have to consider when designing an algorithm for this problem. I'm still working on it.

 

Does anyone know a solution/tutorial for this issue?

Edited by Magogan

Share this post


Link to post
Share on other sites
Have you tried whether the optimization makes sense at all? Because if you can do without collapsing adjacent cubes, there just aren't any T-junctions, so... problem gone. It's good to be conservative, as saving is a virtue. But modern GPUs should not have too much trouble being thrown at with another few thousand triangles. They generally worry more about bad batching and loads of overdraw (yes, smaller triangles do cause more redundant quad processing, which is a "kind of" overdraw, but it's probably still worth trying).

Share this post


Link to post
Share on other sites

No, turning off optimization reduces FPS to about 60% of the FPS with optimization. However, this may change when T-junctions are handled correctly...

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!