FYP Part 5 – Fixing things!

Jacob Keane Blog

While progress is going well, I need to step back and fix a few of the issues in my project. One of these issues is lack of continuity on the surface normals. Another, different but related issue is holes in the mesh. Both of these happen between the different mesh segments.

Seam issues

Issue 1 – Mesh holes caused by two meshes at different resolutions next to each other.
Issue 2 – Shading seam caused by lack of normal continuity between meshes

So far, I’ve fixed the second issue by rewriting unity’s normal calculation code. Since the normals were calculated per mesh, the neighbouring mesh’s edge vertices weren’t taken into account when generating that edge, resulting in the seam.


Threading bugs!

Set things to used before starting a thread, not once the thread starts! In the time taken for the thread to start, something else might try to acquire it as well.

View distance!

If the near plane is too far away from the camera, when you’re near the surface, nearby terrain will not be drawn. However, if the near plane is set to closely, when you’re far away, Z buffer accuracy is lost, resulting in Z-fighting of the water and the planet.

To have the view distance set up correctly, and not get Z-fighting, a dynamic near / far plane system had to be implemented. When far away from the planet, the near plane was moved further away from the camera, and when nearer the planet, the far plane was drawn in towards the camera.