PDA

View Full Version : Vertex Normals and Sharp Edges: How to Correct?



JCDClark
04-12-2012, 11:32 PM
Hi folks,

So recently I've been playing around with loading in models from Blender in .OBJ format and applying some simple lighting to them. In order to improve the lighting, I calculated the vertex normals for the model and used these. For a sample model of a foot, this worked great. For a simple cube I created myself however, the result wasn't great, with strange lighting at the edges as Shown below (the cube on the left is drawn using GLUT). I also subdivided the mesh in Blender so it has lots of vertices.

http://img221.imageshack.us/img221/4138/cubesh.jpg

Thinking about it, I realised that this would be the case for any polygon with sharp edges as some of the adjacent face normals would be in the light and some wouldn't be. The vertex normal would then be an average of this, causing this gradual blurring of colour.

Looking around the internet I haven't found too much information but what I have found scattered around has been this:


Create the Model in Blender with duplicate vertices at Sharp Edges. Detect the angle between surface normals of adjacent triangles. If greater than a certain value, programatically duplicate the vertices. Somehow switch to flat shading when encountering a sharp edge.

I guess I'm asking how I should approach this? Is this typically the modellers job and it's up to them to duplicate vertices for sharp edges and/or fix normals themselves? If I should do this within the application, how should I go about it? It seems like a bit of a task for big models that may have a few sharp edges.

Thanks

menzel
04-14-2012, 11:08 AM
Hello,

the vertices should get dublicated, thats the work of the artist.

If you use normal maps instead of vertex normals, you'll have much more normals per surface area. In that situation these artifacts on sharp edges will not be visible that obvious. You might ignore this problem then.

JCDClark
04-14-2012, 07:19 PM
Thanks for the reply Menzel. Yeah I went back into Blender and duplicated the vertices (via the edge split modifier) and it worked fine. Glad to know it's not my problem haha!

I'll look into normal maps further down the road.