Jump to content
  • Advertisement
Sign in to follow this  
svnstrk

normal interpolation

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, im trying to simulate a phong shading in my scene. i already able to calculate the vertex normal but i cant find the way to interpolate it to find a normals in every pixel. i got this link: http://www.vhml.org/theses/usher/node31.html but i cant understand what the value of alpha and beta should be. any1 have an idea? thanks in advance

Share this post


Link to post
Share on other sites
Advertisement
That is how you interpolate anything on a triangle (color and texture coordinates in particular). alpha and beta are the barycentric coordinates of the point in the triangle.

If you are using that code to implement Phong shading, you should know that a weighted average of vectors with length 1 doesn't have length 1 (it's actually a little shorter). You'll have to renormalize or find some approximation to the renormalization that can be computed fast.

Share this post


Link to post
Share on other sites
sorry im a little bit lost. so this is what i did:

i calculate normal on each vertex, which is the sum of the normals of adjacent polygon divided by the number of of the polygons. then i use bilinear interpolation:

http://en.wikipedia.org/wiki/Bilinear_interpolation

to calculate the normal according to Y, then to X ( since my scanline is botom-top then left right). but what i got is a wrong normal. when calculated with light vector, its very small almost zero.


any1 can help me where i did wrong?


ps:how can i use code tag in here?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!