Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Why use normals?

This topic is 6646 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

Just on curiosity, I was wondering why everyone uses normals and all the floating point math to figure out if a polygon is facing you or not. A long time ago I read an article by a guy that was writing a 3d engine for his 286. He just used this really nifty and REALLY FAST routine to figure out the orientation of the points - if they switched orientation (clockwise vs. counterclockwise), then it was turned away. This seems like it could seriously speed up some really high-poly scene unless there''s something I don''t know about in my ignorance. PS my history teacher calls me his bubble boy. -Ben Dilts

Share this post


Link to post
Share on other sites
Advertisement
To see if a triangle is facing the camera you only need to do the following:

VECTOR3D Camera, TriangleVertex, Normal;

if( DotProduct(Normal, TriangleVertex - Camera) >= 0 )
// The triangle is facing away from the camera
else
// Guess what?

This includes three subtracts + three multiplications + two additions + plus some assignments operations and the final test which is another subtraction. (Did I get everything?)

I don''t know of any faster way than this. If you or any other do then please enlighten me.

Share this post


Link to post
Share on other sites
spellbound is right, the dotproduct vector method is much faster. finding out if something is clockwise or counterclockwise would be more difficult. You''d have to step through all vertecies and somehow (through at least 3 compares and jumps per vertex) determine if the order is clockwise. how was this comparison done that would be so fast?

remember that math ops (addition,multiplication, and assignment) are faster than jumps (what you get in a typical if() statement.

*oof*

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Maybe it doesn''t need to be said (or maybe I''m beating a
dead horse), but the efficiency payoff in using normals
to extract the gross angular relation between the poly face
and the camera view assumes that one has pre-computed the
normals for all of the poly faces, yes?

-pauli

Share this post


Link to post
Share on other sites
Yes it does. Otherwise you would have to do a cross product for two of the edges, which would add 6 multiplications and 9 subtractions.

The above example is for backface culling before projection. You can also do the culling after projection, in which case you would compute the signed area of the triangle. The signed area is basically computed with a slightly modified crossproduct.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!