• Advertisement
Sign in to follow this  

How to specify the normals of a cube ?

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi All I want to render a cube using 8 vertices and 36 indices. how the normals are specified with the fact that a single vertex is shared by more than one face.

Share this post


Link to post
Share on other sites
Advertisement
Vertices can only be shared if the entire vertex matches. This still reduces a cube (which is a fairly worst-case object) down to 24 vertices instead of 36 (two triangles on the same face can share two vertices, so 4 vertex * 6 faces).

Share this post


Link to post
Share on other sites
As Namethatnobodyelsetook said, you'll have to increase the number of vertices in order to get so called "sharp" lighting.

A cube isn't the best example, but in a lot of cases, people use "smoothing groups" so as to still share common vertices but have as little impact on lighting as possible. I think this gives a much better result when I write up terrain renderer's.

In the context of your cube, each of your 8 vertices is used by 3 different faces; if you were to calculate face normals for each of those, add them together, re-normalize (to maintain unit length) that would be a "smoothed normal". For a cube, you'd end up with an almost sphere-like shading pattern but with sharp sillouettes [smile]

hth
Jack

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement