M
Misu
Guest
I did a nice lighting system in 3D but my model's normals are flat instead of smooth. I'm drawing them with gm functions but don't know how to define the normals correctly. Can anyone explain how to achieve this?
Misu is talking about smoothing of the normals.What? You have normals or you don't have normals, that's it. I'm not sure i understand what you are asking.
What is your goal here? Are you talking about smooth (aka fragment based) lighting versus flat (aka vertex based) lighting?
This explanation helpped. Thanks a ton.1) Calculate the normal of the triangle facet using the 3 points that form the triangle with cross product
https://stackoverflow.com/questions/1966587/given-3-pts-how-do-i-calculate-the-normal-vector
2) Use that facet normal value for each point. Each will have this normal. that will result is a cheap ass lighting you are complaining about. do this for every facet of your model
3) loop through each point of the model, figure out which points share the same coordinate. add all their normals and average the result and change the normal of each point to that average