Advertisement

generating averaged normals...

Started by November 13, 2000 01:23 PM
2 comments, last by jason f 24 years ago
I''m doing a wee landscapey thing and have just added some nice lighting normals. Unfortunatly, you can now see almost every freakin triange in the mesh after the texture is applied. I read in the superbible about averaging normals, but how would that apply to a triangle mesh? for every triangle, do I have to average against every triangle with a shared edge? are there any tricks i can do to make it a cleaner process? it works fine in theory if you are just doing horizontal, or just vertical polys, but how about if you have a poly surrounded by others... help.
The bad news: You have to do it.

The good news: Do it once when you generate the model. Average the

normal[x][y] + normal[x-1][y] + normal[x+1][y] + normal[x][y-1] + normal[x][y+1] / 5

overload the + operator here to add the x, y, z values to each other.

Store the normals in the triangle class. Then rotate the normals by the same angle that you rotate the model. If it''s a landscape then this will not be necessary.

Later,
fs

http://www.CornflakeZone.com
//-- Modelling and animation in every dimension --//
Advertisement
d''oh! it''s a constantly evolving landscape using jelly functions that perturb the mesh based on surrounding points...I guess I''m stuck with doing it everytime through...

You''re stuck with it. I''d consider converting your normal calculations to use only integers by going to fixed point arithmetic. Floats are incredibly slow. Also if you really want to get good performance convert the calculations to assembler.
fs

http://www.CornflakeZone.com
//-- Modelling and animation in every dimension --//

This topic is closed to new replies.

Advertisement