I was wondering how I could takes each sphere's vertex stored in my buffer, and calculate the normal to each of them separately. Is it possible to do it in OpenGL?
OpenGL is typically used to render meshes, not compute them. And normals are part of a mesh's data. It is usually the responsibility of the builder of the mesh to supply normals.
In the case of a sphere, normals are dead simple to compute perfectly. For a given vector position P on the sphere who's center is C, the normal is norm(P - C)
, where norm
normalizes the vector.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With