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.
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:
[ul][li]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. [/ul][/li]
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.