Calculate vertex normals for correctly lighting sharp features in a voxel terrain

Started by
0 comments, last by _Silence_ 6 years, 10 months ago
I have an indexed triangle mesh generated by Dual Contouring.
I need to duplicate vertices lying on sharp features (i.e. corners and edges) and assign correct vertex normals ('flat' normals of the faces referencing those sharp vertices).
Otherwise, lighting will look incorrect: the objects look odd and 'blobby', see the first picture below, where each vertex is shared by more than one face.
[attachment=36223:lighting sharp features.png]
Currently, I build from the triangle mesh a vertex <-> face adjacency table,
duplicate each sharp vertex (its feature dimension (corner,edge,plane) is known from Dual Contouring)
for each face referencing this vertex and assign face normals to new vertices (the third picture in the row; there are also lighting seams across chunks, but that's a different problem).
This is fast and easy, but leads to artifacts on sharp edges, where adjacent vertices in smooth regions shouldn't be split, as in the following image:
[attachment=36224:sharp edges - lighting bug.png]
I guess, I should identify and split crease edges instead of sharp vertices, but, unfortunately, meshes generated by Dual Contouring are not always 2-manifold
(e.g. they often have singular vertices (hourglass-like shape) and edges shared by four polygons).
How can vertex normals be calculated for correctly lighting sharp features in this case? Is there a quick & dirty, simple and fast solution instead of a generic one for non-manifolds?
(For 2-manifold meshes I can quickly build a compac (half-)edge adjacency table using a linear scan and sorting.)
Advertisement

An easy mean is to simply interpolate each normal at a vertex with the normals of all the faces sharing this vertex. And to do it for all vertices.

This topic is closed to new replies.

Advertisement