Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

calculate the vertex normals of a sphere

Tags:

opengl

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?

like image 430
Trt Trt Avatar asked Nov 06 '11 02:11

Trt Trt


1 Answers

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.

like image 179
Nicol Bolas Avatar answered Sep 24 '22 02:09

Nicol Bolas