projects

Thursday, September 01, 2005

Problems with normals... sucks

I was having lots of problems with normals. The back face culling was not working properly and the color was not distributed along the object properly. It took me one whole day to find out where the problem was...there was a small error in calculating the cross product of two vectors!! The y component of the normal was not correct. I had to render the normals of each face in order to find that the problem was with normals..Now its fixed and the pictures below show normals correctly :)

A geosphere showing average normals. I found a very easy way of calculating the average normals after the face normals have been calculated. The average normals are required when I want shade smooth object with phong shading... such as this geosphere will be rendered like a true sphere. If face normals (shown below) are taken then the edges of the polygon will be visible and it will not be a perfect sphere!! However average normals are not always desirable... for example a box should be rendered with the face normals instead of the average normals. Applying phong shading with avg normals will make the corners of the box look curved instead of being pointed... and therefor the shading would make the box look like a sphere (something else).

The face normals of each triagle drawn from the vertex.

0 Comments:

Post a Comment

<< Home