Calculate vertex normals of a sphere

I was wondering how I can take each spherical vertex stored in my buffer and calculate the normal for each of them separately. Can this be done in OpenGL?

+6
source share
1 answer

OpenGL is usually used to render meshes, not to compute them. And normals are part of the grid data. Typically, the grid builder is responsible for the delivery of normals.

In the case of a sphere, the normals are dead, just calculate fine. For a given vector position P on a sphere whose center is C, the normal value is norm(P - C) , where norm normalizes the vector.

+15
source

Source: https://habr.com/ru/post/900866/


All Articles