Advertisement

Smooth Shading

Started by April 09, 2002 01:14 PM
4 comments, last by hooded_paladin 22 years, 10 months ago
Using the cross product to get a normal, depending on the ordering you can get normals that face in or out. If I want to smooth shade them, do I need to make sure they all face out (or in) before I average them? Or does it matter? ______________________________ Pretty guy for a white fly.
______________________________Pretty guy for a white fly.
If two vertices have the same normal, but one points in and the other points out, then the average will be the null vector...
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
Advertisement
Of course, any opposite vectors would end up 0, but if you have two vectors- one of a polygon facing in and one of another, non-parallel polygon facing out- will this be correct?

______________________________
Pretty guy for a white fly.
______________________________Pretty guy for a white fly.
Sounds like this isn''t a valid polygon. Why not just have all the normals facing the same way?


Helpful links:
How To Ask Questions The Smart Way | Google can help with your question | Search MSDN for help with standard C or Windows functions
Depending on your API, you have to define your vertices in a specific order (clockwise or CCW) if you want your polygons to be visible. Hence, you don''t have to check everytime if the normal is facing outside the polygon. I mean, try it, and if it is still not working, you might want to post this question in a forum discussing graphical issues.

Cédric
I think you don''t understand his question. You want normals to face out. To do this, the two vectors that you are calculating the cross product for must be in clockwise order. If you have this:

^ (vec1)
|
|
|
-------> (vec2)

To get a vector that is facing towards the screen, do
D3DXVec3Cross(output, vec1, vec2);

I hope this helps.
“[The clergy] believe that any portion of power confided to me, will be exerted in opposition to their schemes. And they believe rightly: for I have sworn upon the altar of God, eternal hostility against every form of tyranny over the mind of man” - Thomas Jefferson

This topic is closed to new replies.

Advertisement