how to calculate vertex normal?

This topic is 3656 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

Can anyone help me on how to calculate the vertex normal, for instance if i want to calculate the vertex normal of each vertex of a cylinder, also if one can provide me some good articles/tutorials regarding lights in direct3d, as i have understood it is one of the toughest topics in game programming, it would be very helpful.

Share on other sites
Say your cylinder is y-axis-aligned (y pointing up), I mean, with the two disks being parallel to the xz-plane (so their surface normals point up/down), and the main axis of the cylinder going through the point (0,0,0), then the normal for each vertex is just it's position on the xz-plane, and then normalised: n = v(x,0,z) / length (v (x,0,z)). Plugging y into that formula gives you spherical normals.

If you are creating the cylinder using sin/cos methods, then make it on the fly like:
normal.x = cos (angle)normal.z = sin (angle)normal.y = 0x = radius * normal.xy = <some height>z = radius * normal.z

The normals of the disks are then (0,1,0) and (0,-1,0).

• What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 28
• 16
• 10
• 10
• 11
• Forum Statistics

• Total Topics
634103
• Total Posts
3015539
×