Xmas
01-11-2002, 05:02 AM
Hi,
I'm doing some stuff with curved surfaces. I recently got a GF3 so I'm trying to do some things with the NV_evaluators extension. Now, I encountered a problem with two-sided lighting. If I run this code
glEnable (GL_LIGHTING);
glEnable (GL_NORMALIZE);
glEnable (GL_LIGHT0);
glEnable (GL_AUTO_NORMAL);
glEnable (GL_EVAL_VERTEX_ATTRIB0_NV);
glMapControlPointsNV (GL_EVAL_2D_NV, 0, GL_FLOAT, 64, 16, 4, 4, GL_FALSE, points);
GLint tess[] = { 128, 128, 128, 128 };
glMapParameterivNV (GL_EVAL_2D_NV, GL_MAP_TESSELLATION_NV, tess);
glEvalMapsNV (GL_EVAL_2D_NV, GL_FILL);
everything is fine, but only one side of the patch is lit.
However, if I add this line
glLightModeli (GL_LIGHT_MODEL_TWO_SIDE, TRUE);
to it, the lighting is totally screwed. The patch is mostly black except for some areas that are seen at a very flat angle. It seems like auto normal generation suddenly takes tangents as normals. Additionally, these "lit" areas are still only on one side. The other side of the patch remains black.
If I generate my own normals (as vertex attribute 2), I get two-sided lighting, but the normals are not correct. Is there a way to calculate the normals of a bicubic patch with another bicubic patch?
I'm doing some stuff with curved surfaces. I recently got a GF3 so I'm trying to do some things with the NV_evaluators extension. Now, I encountered a problem with two-sided lighting. If I run this code
glEnable (GL_LIGHTING);
glEnable (GL_NORMALIZE);
glEnable (GL_LIGHT0);
glEnable (GL_AUTO_NORMAL);
glEnable (GL_EVAL_VERTEX_ATTRIB0_NV);
glMapControlPointsNV (GL_EVAL_2D_NV, 0, GL_FLOAT, 64, 16, 4, 4, GL_FALSE, points);
GLint tess[] = { 128, 128, 128, 128 };
glMapParameterivNV (GL_EVAL_2D_NV, GL_MAP_TESSELLATION_NV, tess);
glEvalMapsNV (GL_EVAL_2D_NV, GL_FILL);
everything is fine, but only one side of the patch is lit.
However, if I add this line
glLightModeli (GL_LIGHT_MODEL_TWO_SIDE, TRUE);
to it, the lighting is totally screwed. The patch is mostly black except for some areas that are seen at a very flat angle. It seems like auto normal generation suddenly takes tangents as normals. Additionally, these "lit" areas are still only on one side. The other side of the patch remains black.
If I generate my own normals (as vertex attribute 2), I get two-sided lighting, but the normals are not correct. Is there a way to calculate the normals of a bicubic patch with another bicubic patch?