Jump to content
  • Advertisement
Sign in to follow this  

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.

If you intended to correct an error in the post then please contact us.

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 this post

Link to post
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.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!