#### Archived

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

# Why use normals?

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

## 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 on other sites
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 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 on other sites
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 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.

1. 1
Rutin
44
2. 2
3. 3
4. 4
5. 5

• 10
• 28
• 20
• 9
• 20
• ### Forum Statistics

• Total Topics
633409
• Total Posts
3011705
• ### Who's Online (See full list)

There are no registered users currently online

×