Jump to content
  • Advertisement
Sign in to follow this  
Max_Payne

Evil Phong Shading

This topic is 4526 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

I'm trying to implement phong shading in my renderer but there is something I simply don't understand... So apparently, phong shading works with this kind of equation: I = Ia*ka*Oda + fatt*Ip[kd*Od(N.L) + ks(R.V)^n] And these variables: * Ia is the ambient intensity * ka is the ambient co-efficient * Oda is the colour for the ambient * fatt is the atmospheric attenuation factor, ie depth shading * Ip is the intensity of the point light source * kd is the diffuse co-efficient * Od is the objects colour * ks is the specular co-efficient * n is the objects shinyness * N is the normal vector * L is the lighting vector * R is the reflection vector * V is the viewing vector What I'm actually trying to achieve are specular highlights on objects, but it doesn't work. I personally always thought phong shading was associated with specularity but... Typically, for specular surfaces you want to gather irradiance from the reflected view vector... Yet phong seems to use the reflected light vector... And this kind of screws up with my irradiance calculations, because I'm using a very generic function of the form: Color3 SampleIrradiance(Point, Normal, Direction, Cosine) This function is meant to gather the irradiance in a conical sector on the unit hemisphere defined by the direction vector and the max cosine... Normal is used to cosine-weight every incoming ray. The function handles direct and indirect irradiance sampling, caching and optimizations. Yet it seems that to implement such phong shading, I would have to hack up this function to stick a phong term in every irradiance sample I make, which seems kind of wrong. Is there a better alternative, or should I be looking to modify my shaders to add a second function to actually be able to not only specify what sampling should be done, but also work on each individual sample?

Share this post


Link to post
Share on other sites
Advertisement
i'm not sure but wouldnt the dot product between the reflected light vector and the view vector be equal to the one between the reflected view vector and the light vector? since the angle of a reflected vector with the normal is the same as the original vector...

anyway, it may make a difference in how you collect irradiance in more physically correct methods, but for phong you just care about the angle between the two.

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!