We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now


Phong Shading

n1875621 asked
Medium Priority
Last Modified: 2008-02-20
Im sick and tired all textbook answers to phong shading, has anyone got a simple explanation on how do phong shade a polygon?
Watch Question

I don't think there is a simple answer.  If you haven't read it, try this address

Can you explain in what environment you need to implement Phong Shading ? I mean what programming language.

I can explain it, but it requires some more information.

I have looked up your info.

So pascal or C++

Do you use Delphi ?

Phong shading can easily be described by comparing it with other technics like Gouraud shading. What you normally are doing is to calculate the color of your polygon's vertices depending on their normal vectors, distance to the lights etc.

Now comes the difference. To render your polygon you can either interpolate the calculated colors of your vertices (Gouraud shading) or you can interpolate the normal vectors of your vertices along the scanlines and redo the color calculation for each pixel based on the interpolated normal vector (Phong shading). The latter requires more calculation time, but leads to better results. In particular specular highlights look more realistic.

Is this answer simple enough?

Ciao, Mike


yes, its to simple - for 200 points ill need some c++ code

Oh, unfortunately I do my programming in Delphi and assembler and the code is a bit *bit* more complex than my answer. I wish you luck getting someone writing you this code.

Ciao, Mike

I find Lischke's answer perfectly acceptable given your initial request. If C/C++ source code is what you want, have a look at http://www.ssec.wisc.edu/~brianp/Mesa.html. Mesa implements something very close to OpenGL and you can get the complete source (C/C++) code for it. You will find code for a great deal of graphics algorithms if you are willing to dig.
If you want a simple way to understand how it's done, to the extent that you can implement it yourself, you might not want to be burried in the details of a full implementation. Given a minimum mathematical background and the willingness to use your brains, Lishke's answer should point you in the right direction. As clancyo exemplified, there's lots of info on the internet you can look at, but in the end, it's simple and easy in the textbooks.
Unlock this solution and get a sample of our free trial.
(No credit card required)

Hi euclid, ironheartd

thanks for your support :-), but don't care about this. I gave an answer and it wasn't enough, so n1875621 has to look elsewhere to find another one.

Let's take it easy...

Ciao, Mike
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.