PDA

View Full Version : NV_evaluators and two-sided lighting?



Xmas
01-11-2002, 06: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?

mcraighead
01-11-2002, 11:54 AM
Please send me your app...

- Matt

j
01-11-2002, 03:27 PM
About using one bezier patch to calculate the normals for another:

I usually see it done by taking two bezier patches, which represent the tangent vectors of the patch which you want the normals for, calculating their values at the vertex, and doing a cross product.

However, I think it's possible to just take the cross products of the _control points_ for those two patches, and then use those values as the control points for a patch which evaluates to the normal you want.

I've done it for triangular bezier patches, and the results were perfectly accurate. I don't see why this wouldn't work for rectangular bezier patches too.

j

Xmas
01-20-2002, 09:06 AM
Doh, I found out why it doesn't work...I used
glFrontFace(GL_CCW);
in my App, so all the normals were pointing in the wrong direction. You have to use glFrontFace(GL_CW) to get correct lighting.

But I have another question. MAX_EVAL_ORDER is 8 and MAX_RATIONAL_EVAL_ORDER_NV is 4 with current drivers. But up to which order is the tessellation done in hardware on a GeForce3 card?

V-man
01-20-2002, 06:11 PM
GL_CCW fixes the problem? I dont see why since you are using 2 sided lighting.

>>>
But I have another question. MAX_EVAL_ORDER is 8 and MAX_RATIONAL_EVAL_ORDER_NV is 4 with current drivers. But up to which order is the tessellation done in hardware on a GeForce3 card?<<<

The GL evaluator may be done in software. I beleive the idea of the NV evaluator is to have it done in hardware and efficiently. The docs about GF3 probably contain this info.

V-man

mcraighead
01-20-2002, 07:03 PM
Please send me the app, the FrontFace problem is quite likely a legitimate bug.

- Matt

Xmas
01-21-2002, 03:06 AM
sent...