Pedro
Pedro

Reputation: 474

Strange shadowing after optimising mesh vertices

I'm generating a custom mesh out of a height map, and it works fine, except that after generating the mesh, there are a lot of duplicated vertices; duplicated in the sense that they occupy the same point in space.

In an attempt to optimise this, I run thru all of them and detect the ones in the same space and remove the duplication, and recalculate all the triangles.

This yields the same mesh, but now with 1 fifth of the vertices, the exact desired result.

However, in the unity editor, the visual changes. Some strange shadowing appears after I have optimised the mesh. See screenshots below.

This screenshot is before optimising the mesh.

BEFORE optimisation

This screenshot is the exact same mesh, but now with optimised vertices.

AFTER the optimisation has run

What can be the cause of this? I assume it's being done by the lightning of the scene, but no changes to the lighting has been made between the two screenshots.

Upvotes: 1

Views: 73

Answers (1)

Pedro
Pedro

Reputation: 474

Ok, so I figured it out. In optimising the mesh, I removed all overlapping vertices, but then I loose the hard edging, since every vertices only have one normal which is shared bu several triangles.

When the vertices are shared, the normal is interpolated across faces. I bet that is what is causing this effect.

Upvotes: 2

Related Questions