TokisanGames/Terrain3D

Occluder generation misses some holes

TokisanGames opened this issue · 5 comments

Description

@tcoxon The occluder generation at lod4 misses the hole on the left in the demo. When the player runs through the tunnel, he disappears for a moment when the capsule is on one side of the occluder and the camera is on the other.

image

I must not have fully thought it through when making the older occlusion code work with the newer holes. There's no difference between a hole and a face when it comes to occlusion. The way the occluder baking works at the moment simply won't work with holes.

Someone will need to check how the engine does occlusion culling to determine whether putting an infinity or NaN in the mesh vertex will work. If that does work, that'll be the simplest fix. Otherwise, the baker will need to divide the occlusion mesh in two for every hole in the terrain.

I'm not sure when I will get time at the moment. It may be a good idea to document that occlusion doesn't work with holes.

The hole on the right, shown in the picture, does work. I thought that was intentional.

Oh, I missed that there was supposed to be a hole on the left. Does the ArrayMesh baker put a hole there?

Regarding my previous comment about the hole on the right: if the hole on the right behaves correctly at runtime and doesn't cull too much, then my comment was mistaken. It would seem like occlusion considers a face with more than 3 vertices a hole. However there may still be an issue if there's a hole in the terrain smaller than the space between occluder mesh vertices. So I think I will still investigate that. A workaround users can do in the meantime is baking occlusion with a lower LOD (but that won't help with the hole on the left).

Like the occluder, the array mesh baker puts a hole on the right, not on the left.

I must not have fully thought it through when making the older occlusion code work with the newer holes. There's no difference between a hole and a face when it comes to occlusion. The way the occluder baking works at the moment simply won't work with holes.

I've confirmed that I was wrong about this. Occlusion meshes are built from triangles, not points, so where there are no triangles (in holes), there's no occlusion.