I have been working on getting proper shading on a model viewer I have made for a custom format. The first time I enabled lighting and set the lights and stuff, the model was completely white, unlike models in tutorials I saw, so I looked at the code for glutSolidCube to find that it uses normals.

In my PLY to my format converter, I made it multiply normals by 255 for X, Y, and Z normals (for the sake of saving space). In my renderer, I simply divided by 255.

glNormal3f(xn,yn,zn);

Where xn, yn, and zn are each normals between -1 and 1. Between 0 and 1 for this test, actually.

Surprisingly, the result had the same shading on every face (dark gray). I looked at the code for glutSolidCube again and noticed that X, Y, and Z normals do not each have a value. If X is 1, the others are 0. If Y is 1, the others are 0. If Z is 1, the others are 0. I modified my converter to write Normal*255 for whichever one was the greatest and 0 for the others. Then, there was a mixture of solid white and solid black faces. I have tried calling glNormal3f both per-vertex and per-face.

With that said, I am pretty mixed up on normals and shading in general. I would like to render shading on my 3D models and think it has to do with normals, but I'm not sure how to properly calculate them. If someone could help me figure out how, I would be grateful. Thank you for taking the time to read!

Put simply, the normal to a surface is the vector that is perpendicular to that surface. So, for example, if I have a triangle (0,0,0), (1,0,0), (0,0,1), then one normal could be (0,1,0). Yes, lighting calculations do use normals. The simplest model, for instance, calculates lighting intensity as the normal dotted with the light's direction.

But anyway, it sounds like you need to do some more research. Try to find something explaining OpenGL 2's lighting model.

And a Unix user said rm -rf *.* and all was null and void...|There's no place like 127.0.0.1|The Application "Programmer" has unexpectedly quit. An error of type A.M. has occurred.

Yeah the Normal is perpendicular to its surface. It is needed in lighting calculations so it can be compared to a lights direction and determine that surfaces lit value. You could search for Blinn-Phong shading. This website also has a pretty good explanation under "OpenGL Directional Lights 1"