View Full Version : Many Newbie Lighting Questions

08-02-2000, 09:43 PM
Hi ppl.

I am using Blender to create my simple model, and save it as an OBJ file (has only ASCII vertice data and face data)

It went well until I added lighting.
As the file does not have the Normals, I needed to calc them by hand (I made that by vectorial multiplication), and used GL_NORMALIZE to ease my work.

Then I noticed that some normals were working "inversed", lighting blocks where there should be shadow. Browsing the Forum, I found out about GL_LIGHT_MODEL_TWO_SIDE.

My doubts are :

Is there a cleaner way to get the normals than :

for (j=0;j<3;j++) {


(I know I should normalize them instead of using GL_NORMALIZE, but I'm too lazy to do that.)

What is the cleaner way, using GL_LIGHT_MODEL_TWO_SIDE with GL_FRONT_AND_BACK or using GL_FRONT without Gl_LIGHT_MODEL_TWO_SIDE?

I also want to know how to get my model Gouraud shaded (It is a rough model, with sharp edges, and just a few (125) vertices.).
I tried GL_SMOOTH, but the faces are still of uniform color.

Thanks in advance,

08-02-2000, 09:58 PM
To compute normal, no other way than compute a cross product... (and for normalisation, use a table to compute square root, hehe...)
to make gouraud, you will have to compute a normal for each vertex. To do it, you can make the average of the normal of the face around the vertex (but normalize them BEFORE).
for the problem of orientation, it is very strange, and comes from blender, sorry. You should used GL_FRONT to enable culling and speed up the rendering.

08-03-2000, 12:22 AM
It is maybe blender fault, if it is not coherent in the way vertices are described (clockwise and counterclockwise mixed), but I didn't play with it...

Do not use double sided lighting since it is very slow...

08-03-2000, 05:55 PM
I already had success making smooth shading... I just made the normals as for a sphere (Normal parallel to the 0->vertex line), and it got sufficiently good.

For the faces with reversed lighting, I don't think it is blender's fault. The way I calculate the normal does not give me *any* control of which side it will be pointing. It just occurs that for two or three faces I get the normal pointing *inside* my model.

As a test, I used GL_FRONT_AND_BACK with the spheric scheme of Normals, and it went okay, proving that _my_ old normals were in fault.

Also as a test, I applied some Materials only for the back of the polygons, and that resulted in *none* of the polygons being affected by the material. (all of them were facing out)

Thanks anyway