Coloring lags

Started by geakstr, February 28, 2015, 09:00:39

Previous topic - Next topic

geakstr

Hello. I implemented lighting in my voxel engine (just calculate light level for each block), but I have problem ââ,¬â€ non-illuminated triangles appear shimmering white dots. When camera moving dots appear in other places. I attached gif for demonstrate this. What could be the problem? I disabled textures and draw only with colors filling ââ,¬â€ problem remains.

https://dl.dropboxusercontent.com/s/n7e3a145wrrrelb/screencast_2015-02-28_11-32-38.gif?dl=0

UPD. Hmmm, when I disable culling face all is well... Can I do something to keep him?

UPD2. With disable backface culling I look white dots inside chunk.

Kai

The "cracks" in your mesh are due to floating point inaccuracies.
Can you show how you setup the geometry of the boxes? Best would be if the same vertex is shared by all boxes using that vertex.
You probably build each box for itself with all its 8 vertices maybe by using some three nested for-loops over x,y and z and then use some floating point arithmetic to compute the final vertex position.
This is where the error happens.

The reason everything "seems to be" well with backface culling disabled and looking from outside onto the mesh is that you now see the backsides of other boxes through the cracks of the boxes in front of you.
And the reason you see those cracks again with backface culling disabled, while you are inside of a box, is probably because that particular box is at the edge of the mesh and you see the white from outside.

geakstr

All vertices for box described as 0 and 1 coords there: AABB.java

Translate box to place there: Chunk.java

Yes, I describe each box as 8 vertices...

If I move from float to int for boxes ââ,¬â€ this solve problem?

UPD. No, integers do not help

UPD2. I do not understand why the holes appear only on unlit areas.

Kai

Do not describe each box as 8 independent vertices, but instead define the grid/lattice of vertices encompassing all boxes in your mesh in a VBO and then use indexes (i.e. index/element buffer) to index into that grid/lattice of vertices for all boxes.

geakstr

Ok, I'll try to do this.

geakstr

I implemented shared vertices (almost all the white dots are gone, but sometimes they still appear). But... As it is now texturing? I use texture atlas, specify texture coordinates for each side and "crop" and "repeat" this in fragment shader. But with shared vertices I do not know how do this.