wyy
wyy

Reputation: 545

Modified meshes lighting doesn't look right

I'm adding planes next to each over, and modify vertices a bit. After that the lighting doesn't look right between the connection points. Why does this happen?

enter image description here

Upvotes: 0

Views: 31

Answers (1)

manthrax
manthrax

Reputation: 5016

It's a bit complicated but here goes:

Each vertex has a normal.. the normal is computed as the weighted average of all the neighboring vertex normals.

The neighbors on the edge of the first patch aren't lining up with the second patch, and don't know what the neighboring patches vertex normals are, 1 face in from the edge. So one solution is to create patches that overlap by 2 cells, so that each patch has a ring of shared faces around it, then recompute their normals, then remove the outer ring of faces, (since those will have incorrect normals).

So if your patch is 16x16 faces.. make patches of 18x18, and make their edges overlap.. modify the vertices of each patch using the same noise function based on the world space x/z of the vertices (simplex or perlin noise is good), and then recompute face/vertex normals, then do the outer ring removal from the face list. It's complicated but works.

Upvotes: 1

Related Questions