|
![](/i/fill.gif) |
In article <4023cb35$1@news.povray.org>,
"Dan P" <dan### [at] yahoo com> wrote:
> That's interesting -- I never use phong, but I would think they are the same
> thing, aren't they Chris? Maybe people who make the best scenes use phong
> because they are long-time users of POV-ray and phong used to be specular
> (or, was it, I'm not sure -- I don't have POV-ray at work).
>
> This is a really good question. If anybody will know the answer, it will
> definitely be Chris; he's got the internals down and then some :-)
Despite my lack of post-college experience?
Okay, here it goes:
They are definitely not the same thing. Phong is the older shading
method, and is very simple mathematically, computationally cheap, but
not very accurate. In terms of POV code, the equation used is:
phongAmt*surfaceColor*pow(vdot(reflectionVector, lightVector), phongSize)
The reflection vector is the direction a reflected ray would go, the
light vector is a vector pointing towards the light source. When the two
line up, their dot product equals 1, and the highlight is the brightest
where you would see a reflection of the light. When the two are
perpendicular, the result is 0, and the highlight drops to nothing.
Specular uses a different and more physically accurate highlight
function:
specularAmt*surfaceColor*pow(vdot(halfPt, normal), 1/roughness)
where halfPt is halfway between the ray origin and the light source. It
is also brightest at the points where the reflection of the light source
would be visible, but the falloff is different.
If metallic is specified, a Fresnel reflection function is used. It
takes the intensity part of the above calculation and adds some
additional calculations based on the angle of the surface to the light:
specIntensity = specularAmt*pow(vdot(halfPt, normal), 1/roughness)
F = abs(acos(vdot(normal, lightVector))/(pi/2))
F = 0.014567225/sqr(F - 1.12) - 0.011612903
F is then clamped to the range 0-1, and the final highlight color is:
lightColor*specIntensity*(1 + metallicAmt*(1 - F)*(surfaceColor - 1))
This function is based on actual measurements of real-world surfaces,
and is the most realistic highlight for metallic objects.
--
Christopher James Huff <cja### [at] earthlink net>
http://home.earthlink.net/~cjameshuff/
POV-Ray TAG: <chr### [at] tag povray org>
http://tag.povray.org/
Post a reply to this message
|
![](/i/fill.gif) |