# Calculate normals from neighbours

helo,

i checked the search but couldnt find a proper answer, but im sure this question was solved before…
…anyway:

i have a grid and want to have the normal of the gridpoints. (see attached pic)

can anyone give me a hint how calculate this.

i already tried to recalculate the normals according to this:
tutorial effects normals
but i got strange results?

and no i am not working with shaded objects - its all cpu.

the pic

Can’t help on the brains, but you should be able to grab the normals from a vertex buffer split. If your mesh does not have normals you might need to attach a normals(exGeo) before the split.

and just regarding your illustration, then the normals are not located in the vertices, but perpendicular to the surface defined by each triangle in the mesh.

@everyoneishappy:
i have no mesh - just a lot of ordered vectors. and yes i can simulate a gridmesh and split the vertexbuffer to get the indices. and then feed the inputpin of the vertexbuffer(join) with my ordered vectors and then mesh(join) and then normals - ok - and then again vertexbuffer(split).
(see attached patch)
but i think there is a better way of calculating the normals without the vertexbuffers/meshes/normals - nodes. a kind of mathematical way. because i am not working with a mesh anyways…

getnormals.v4p (5.6 kB)

http://www.lighthouse3d.com/opengl/terrain/index.php3?normals

maybe this can help you

you could use Tangent (Spreads) for each row and respectively for each column. then Multiply (3d Cross) those and you have the normals

the way through the normals node isn’t bad at all. i would say, that the dx algorithm is much faster than patching it, because you have to calc all surface normals and then average the surface normals on the vertices to get the vertex normals. the mesh join/split operation is not a big deal… but how many points do you have?

ok will do it with the mesh spli/join procedure. teh performance is still pretty good.
the grid is between 60x60 and 120x120

thank you everybody