Random Sky Pixels Shine Through Between Triangles

Started by
7 comments, last by Beosar 7 years, 8 months ago

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

Advertisement

Do adjacent blocks share vertices? Try that.

-potential energy is easily made kinetic-

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.

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.

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

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.

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.

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?

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).

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

This topic is closed to new replies.

Advertisement