# What is correct calculation for normals on procedural geom

I have a procedurally generated cube and the vertices for the top face are

``````    pt1 = [-1,-1,1]
pt2 = [1,-1,1]
pt3 = [1,1,1]
pt4 = [-1,1,1]
``````

I add the vertices and normals like this:

``````    vertex.addData3f(*pt1)

normal.addData3f(Vec3(2 * pt1[0] - 1, 2 * pt1[1] - 1, 2 * pt1[2] - 1))
normal.addData3f(Vec3(2 * pt2[0] - 1, 2 * pt2[1] - 1, 2 * pt2[2] - 1))
normal.addData3f(Vec3(2 * pt3[0] - 1, 2 * pt3[1] - 1, 2 * pt3[2] - 1))
normal.addData3f(Vec3(2 * pt4[0] - 1, 2 * pt4[1] - 1, 2 * pt4[2] - 1))
``````

The lighting doesn’t work quite right when I play around with it using .place().
My suspicion was that it was because of the normal calculations. What is the right way to do this?

You’re generating smooth normals, pointing outwards from the vertices. But you might actually be wanting to use flat shading.

You need to make sure to add four separate vertices for each face (rather than using 6 vertices and reusing them for each face). Each vertex on that face should have the same normal vector, pointing outwardly from the face.

So for the top face, you should want to set (0, 0, 1) on all four vertices.

Ohh okay I understand,
Thank you thank you