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.
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!