Funky normals with ofMesh

Hey folks!

I’m porting over some 3D ribbon code that was working normally in version 0.74 – the ribbons are generated in 3D using perlin noise and use quaternions to calculate the normals. In 0.8, the lighting appears to be working, except for black banding that occurs from time to time – depending on orientation of the curvature (they twist).

Here’s a snapshot:

For comparison, I’ve drawn a sphere (using ofDrawSphere) and I am not getting the same dark areas.

Needless to say, I’m a little stumped by this problem.

And here’s a lil’ snippet of the ribbon vertex and normal calculation:

   // get the pt and the quaternion
   ofVec3f pathPt = vertices[i];
   ofQuaternion quat = angles[i];

   float angle;
   ofVec3f axis;
   ofVec3f vec;
   quat.getRotate(angle, axis);

    // calculate path pts (-5/+5)
    ofVec3f p1 = pathPt + ofVec3f(0, -5, 0).getRotated(angle, axis);
    ofVec3f p2 = pathPt + ofVec3f(0, 5, 0).getRotated(angle, axis);
    ofVec3f normal(0, 0, 1);
    normal.rotate(angle, axis);

Any thoughts on what might be causing this?

++thanks in advance,


i think there was a problem with lighting in 080 but it’s fixed. can you try with latest master or with a nightly build?

Thx Arturo, I’ll give it a whirl and will report back soon

So, it is still be an issue with the latest master. I disabled the oF lighting functionality in my app, enabled GL_LIGHTING and the lighting is rendered as expected. I’ll dig a little bit deeper and see if I can spot anything.

@arturo looks like the problem was on my end …

i wasn’t using materials for the ribbons. as soon as i specified a shininess value and specular color for a material, the banding went away.

GLfloat white[] = {1.f, 1.f, 1.f, 1.f};
GLfloat mat_shininess[] = { 28.0 };
glMaterialfv( GL_FRONT, GL_SPECULAR, white );
glMaterialfv( GL_FRONT, GL_SHININESS, mat_shininess );

Perhaps there were some default material values set in 0.74 …