Skip to main content
gamedev.net
🔒 Locked

Surface Normal Interpolation

Started by Riskbreaker 4 replies 300+ views
Original Post
Riskbreaker
Riskbreaker
This is more a math question than anything else, but I figured I might as you guys since it''s a graphics question too. I''m writing a raytracer with OpenGL, and I''m trying to do Phong illumination for polygons. This means I have to tally the normals for each polygon and average them according to where I''m at on the polygon. Does anyone know the math behind doing this? Note that I''m not just averaging one surface normal for the whole polygon -- the normal is dynamic depending on the specific location you''re rendering on the surface. Any help greatly appreciated! Thanks!
--RiskbreakerCoding Soul
trainedmonkey
trainedmonkey
as i remember, phong shading interpolates between normals at vertex points of your polygon. this is why if you shade a dodecahedron (a 20 sided die) with normals that are perpendicular to each face, it looks faceted.

in order for the dodecahedron to look smooth, you have to interpolate the normals, which i assume is the question that you are asking.

this is not too dificult to do: you just want to make sure that every normal at each vertex has the same value as each of the other normals at the same vertex, and make sure all the angles between the adjacent faces and normal are the same. i believe on simple way to do this is to sum all of the normals at a given vertex, and average them.
Riskbreaker
Riskbreaker
Thanks for the post, but that isn''t quite the question I was asking. Say, for instance, you are initially given the normals at the vertices for proper Phong illumination. You are given these -- there is no need to find them. What I am asking is: I want to shade an exact point on the surface -- not one of the vertices. Remember, this is for a raytracer, so I''m shading pixel by pixel. That is why I need to find the exact normal for the given pixel. Each point in a polygon has a given set of vertices, and those vertices have the predetermined Phong vertex normals. I need to somehow average these normals proportionally for the exact pixel I''m currently on.

I hope that doesn''t sound too confusing -- I apologize, it''s really hard to explain!
--RiskbreakerCoding Soul
trainedmonkey
trainedmonkey
yep, you''re right, i misinterpreted your message.

i''m a bit rusty on all of this, but i found this link:
http://www.nbb.cornell.edu/neurobio/land/OldStudentProjects/cs490-95to96/guo/report.html


Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.