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

This topic is 563 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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.)

##### Share on other sites

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.

1. 1
2. 2
Rutin
19
3. 3
khawk
15
4. 4
5. 5
A4L
13

• 13
• 26
• 10
• 11
• 44
• ### Forum Statistics

• Total Topics
633743
• Total Posts
3013647
×