• ### What is your GameDev Story?

#### Archived

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

# vertex normal interpolation over a triangle?

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

## Recommended Posts

I''m trying create a basic programm involving a landscape. Now I''ve created the landscape as a simple heightmap and calculate the averaged vertex normal for each vertex in the map. Now I want to calculate a normal at any point even between vertices, but I want to do this in a smooth way to put something like a vehicle on the terrain and use the normal to make it move around the terrain smoothly. But what''s the best way to interpolate the normal over a terrain triangle? I tried to do it in a way by calculating the distances from the intersection point to all the nearest vertices and using these as a kind of weights, but this doesn''t really seem efficient and there seem to be small anomalies (though this might just be a bug). If anyone could help I would be very greatfull.

##### Share on other sites

Just add up all the edge normals and take the average?

##### Share on other sites
Calculate a weighted average of the three vertex''s normals. Use your distance from each vertex as the wieght.

Alan

##### Share on other sites
sounds like Phong interpolation to me!

you''re doing what AlanKemp said and that''s about all i know of.

Phong interpolation is notoriously slow...

unless you''re using huge polys, there shouldn''t be any noticeable difference between using the face normal and the interpolated normal... If you''re using huge polys to approximate a surface, then you SHOULD use the facet normal.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
I have no name that you may call me. I am merely Succinct.
~Succinct Demos Online~

-(Drop me a line here n''at)-

##### Share on other sites
Thanks for the replies!

I''m using it to create lightmaps and later to position vehicles on the terrain. I think just using the facet normals for the lightmaps would produce results that don''t look right, but since they are precalculated it doesn''t really matter to use a more ''labourous'' way.

Using the The Phong interpolation technique (like AlanKemp said) seemed to work, but I was still wondering, if all the terrain faces have about the same shape that''s like:
+----+
|.../|
|../.|
|./..|
|/...|
+----+

And if you keep the sides of equal length they are all the same and you basically keep repeating some of the same calculations over and over for each one, because it''s only the height of each vertex that changes, wouldn''t there be a way to precalculate some of it and have an easier (And more importantely) faster way of doing the rest?

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 9
• 34
• 16
• 11
• 10
• ### Forum Statistics

• Total Topics
634122
• Total Posts
3015644
×