Vertex normals

Lo there.
Bit of a rookie question today.
I’m reading through the section of the manual titled “Advanced operations with Panda’s internal structures” and I’m a little confused about normals.

First of, are normals just the direction pointing away from the surface? So that on a flat plane, the vertex normal would point straight up?

How to calculate them? I see them calculated in the cube sample, but some other source code, and the manual just sets them all to (0,0,1). I assume in those cases the author IS drawing a flat plane and IS pointing the normal straight up like my earlier example.

for a face-normal this would be correct. but most of the time you would work with vertex normals (to get a more smooth-looking shading instead of the flat shaded look)

there are different ways to calculate them. the internet is full of “normal calcultaion algorithms”

gouraud shading is all-time-popular. thought there is phong shading which usualy looks better when its supported. … eport.html

its mostly about shadeing itself but at the beginning they compute the normals.
in one sentence. a vertex normal is calculated as average of the orthogonals , standing on the lines connecting it to other vertices.

I didn’t know there were different ways to calculate them :smiley:

well in some special cases you would even want to use totaly different calculations. for exmaple if you have grass-meshes with planes+grastexture applied. you most likely want you vertex normals to point straight upwards.

You can run your models through a panda utility (I believe egg-trans) which can generate normals automatically.
Also, you can also specify to automatically generate normals in any of the something2egg converters.