0
votes

I'm making a voxel engine dividing the world in chunks with 32 x 32 x 32 blocks each. I've been implementing many rendering optimizations such as not rendering faces covered by solid voxels or face merging for same looking neighbour voxels.

The thing is that I want to implement a per-vertex ambient occlusion, calculating the occlussion from the CPU and passing it to the shaders, just like that image. It works almost fine but the face merging makes bigger gradients on larger faces because of the linear interpolation OpenGL makes to the final color of the fragment.

I would like to now if there is a way to fix that problem, by telling the fragment shader how far is a fragment from the vertex or something like that.

1
Google "Greedy Meshing"Krythic

1 Answers

1
votes

It would be better to ditch your "face merging" system altogether. Though not just because it would let you do this occlusion stuff more effectively.

One problem with your face merging system is that renderers only guarantee that edges between two triangle will not have gaps only if the two shared positions are binary identical values. Your face merging system has many triangles that partially share edges. GPUs don't guarantee anything about edges in those cases; this can lead to cracks being visible between the edges.