Skip to main content
gamedev.net
🔒 Locked

surface normal calculations

Started by RenderCache 2 replies 1.8k views
Original Post
RenderCache
RenderCache
hi! I am trying to find out how to compute a surface normal such that the normal points "outwards" of the mesh. So far i simply take 3 vertices of a triangle and compute a planar normal, but tis normal could potential point inwards or outwards. any one can help? thx! RC
jonnyfish
jonnyfish
As long as all the vertices are in the same order (CW or CCW, it doesn't matter which), then this is easy.

If you have clockwise A, B, C, then (A-B) x (C-B) will be outward. If CCW, (C-B) x (A-B) will be outward.

Remember the right hand rule: take your right hand and extend the fingers forward with your thumb 90 degrees to them (on the same plane as your palm), almost like you are about to give a high five. If your thumb is in the direction of u and your fingers are in the direction of v, then your palm is in the direction of u x v.
RenderCache
RenderCache
thx!
looks like i need to recheck my vertices again then
snoozeman
snoozeman
just a small hack to avoid rechecking vertices,if your object is centered
on a point called Center and the surface is convex, you can simply do a dot product between the normal you calculated N, and V=position_of_vertex-Center :
if (V dot N)>0 then Normal is going out of the object, otherwise normal is going in.
However this won't work in most cases.
snoozeman

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.