weird lighting on 3d mesh

i have very simple code for loading and drawing a head from a ply file:

  
  
#pragma once  
#include "ofMain.h"  
#include "ofxAssimpModelLoader.h"  
class testApp : public ofBaseApp {  
public:  
	void setup();  
	void update();  
	void draw();  
	ofxAssimpModelLoader model;	  
	ofEasyCam cam;  
	ofMesh mesh;  
	ofLight light;  
};  
  

  
  
#include "testApp.h"  
void testApp::setup() {  
	model.loadModel("head-only.ply");  
	mesh = model.getMesh(0);  
	glShadeModel(GL_SMOOTH);  
	glEnable(GL_NORMALIZE);  
	glEnable(GL_DEPTH_TEST);  
	light.enable();  
	ofEnableSeparateSpecularLight();  
}  
void testApp::draw() {  
	cam.begin();  
	mesh.drawFaces();  
	cam.end();  
}  
  

i’ve attached an image of the result in OF, and the original in meshlab. i’ve also attached the model (head-only.ply).

i’ve tried some different combinations of the lighting and shading models, but nothing seems to work. GL_NORMALIZE doesn’t help. i’m really not sure what’s wrong. any ideas?

head-only.ply.zip

![](http://forum.openframeworks.cc/uploads/default/1876/Screen shot 2011-10-07 at 6.20.09 PM.png)

![](http://forum.openframeworks.cc/uploads/default/1877/Screen shot 2011-10-07 at 6.25.44 PM.png)

hi @kylemcdonald, i 'll take a look in the model and in the code, maybe a issue with the normals…

the reason of this artifacts is because vertex normals aren’t reoriented. You can see in mesh lab(see the picture) .In meshlab just select all the vertex and then apply the reorient normals.take a look in the model the zip file
cheers

head-only_reoriented.zip

aha! that totally did it. i don’t know why i didn’t think of that sooner :slight_smile:

to summarize: it’s not a problem with OF or GL or assimp. it’s just that the vertex normal orientation is very important when you have smooth shading enabled, because opengl needs to interpolate between the normals. thanks kalwalt!

i think it is a way to reorient the vertex normals(via code) but i’haven’t a clear and safety idea how to do it. ::slight_smile:
Anyway Mesh lab is very useful!