cg-old
cg-old copied to clipboard
Getting the normal from a point on a surface
Lets say you have a single point on a surface, and you want to get its normal. The surface is generated procedurally.
What would be the proper way to get the normal of a point if you can sample nearby positions and get their position on the surface?
-
If your surface is defined explicitly with a C1 function f(u,v) -> x,y,z you can simply take the cross product of its 2 two partial derivatives (df/dx cross df/dy)
-
If 1 does not apply, you can sample a few nearby points, fit a plane in the least square (http://stackoverflow.com/questions/1400213/3d-least-squares-plane) and then use the normal of the plane. In this case, you have to be careful to always pick a consistent orientation for all your normals.
thank you, that helped!