Skip to main content
GameDev.net gamedev.net
🔒 Locked

specular reflection: HalfAngle vs. ReflectionVector

Started by quasty Jul 18, 2006 at 9:04 AM 7 replies 5.7k views
Original Post
quasty
quasty
Hi, when looking through implementations of specular reflection I usually find to ways to handle it: The HalfAngle approach calculates the HalfAngle (EyeDir + LightDir) and then dot(HalfAngle, Normal). The Reflection approach calculates the Reflection Vector reflect(LightDir, Normal) and then dot(Reflection, EyeDir). Which one is better? :) And why / how? thank you
jbarcz1
jbarcz1

I think the half-vector approach might be a little faster because its easier to compute the half vector than the reflection vector, but if you actually sit down and think about how the math works, they do the same thing.
Joshua Barczak3D Application Research GroupAMD
SimmerD
SimmerD
The reflection vector interpolates better than the half-angle across triangle, and can have more stable specular highlights. The half-angle was used traditionally b/c it was possible to combine diffuse & half-angle specular on older gf3 type hw, whereas reflection vector style requires more tradeoffs or more passes.
Lotuspec
Lotuspec
You may be interested in this . It might explain the 'more stable specular highlights' wich (according to these folks) are not so close to reality.
quasty
quasty
Hi,

Thank you all. But I'm afraid I havn't understood this BRDF-Validation article. :( Are they saying HalfAngle-approach is better than ReflectionVector-approach? Where do they come to that conclusion and why - cause the reflection vector way seems more logical to me.
Dirge
Dirge
Don't worry about BRDFs, it's a red herring :-)

Half-angle = faster
reflection = more accurate

With the half-angle you'll need to exaggerate your specular power values to overcompensate for the slight discrepency in results. If you concern is saving as many pixel shader insruction cycles as possible, go with half-angle and adjust accordinly. If it doens't matter to you or you need the utmost visual fidelity, go with reflection vector. Whatever you do don't base an entire game off of one then switch at the last minute. Your artists will want to gauge your eyes out with their pencils.

p.s. it's been hinted that cards in the future will natively support some kind of reflection insruction, which would make it the preferrable choice. If you decided to put anything to this you could just use the 'reflect' Cg or HLSL intrinsic function and it might magically just be faster one day.
"Artificial Intelligence: the art of making computers that behave like the ones in movies."www.CodeFortress.com
Lotuspec
Lotuspec
The article I posted just shows what the real difference between the HalfAngle and ReflectionVector approach is (see slide 44-end): in the first case the highlights will be increasingly elongated along one axis at grazing angles where in the latter case the highlights will always be circles. According to their experiments the 'deformed' highlights of the HalfVector approach are more realistic.

Conclusion:
Half-angle = faster and more accurate
reflection = slower and less accurate
Dirge
Dirge
I stand corrected, even as an approximation it coincidentaly offers more accurate results (something I'm sure even Blinn wasn't aware of). Baffling.

Also a good reference:
http://en.wikipedia.org/wiki/Blinn-Phong_shading_model
"Artificial Intelligence: the art of making computers that behave like the ones in movies."www.CodeFortress.com
cpiasminc
cpiasminc
The half-angle approach is actually based on a microfacet model, whereas the reflection vector approach is not. Technically, the half-angle approach is more correct, while it's the reflection approach which is actually an approximation based on the assumption that a surface that exhibits specular highlights is essentially a not-so-perfect reflective surfaces. Though it should be noted that using the idea of a dot product raised to some n power is also inherently an approximation.

A more generic form of a specular highlight is Ward's model where the dot product of the half-angle vector with respect to the tangents is scaled by some factor (a sort of inverse of the specular exponent) and used as the parameter in a Gaussian. The explicit computation is hefty, but can be simplified by taking out a lot of constant factors. For shader-world, though, I find Ashikhmin's model to be a lot easier for anisotropic speculars --

kU = (Half.tangent)^2 * specularExponentU;
kV = (Half.binormal)^2 * specularExponentV;
Specular = (Half.Normal) ^ (kU + kV);

You can find more here --
http://en.wikipedia.org/wiki/Specular_highlight
Light travels faster than sound. This is why many people appear very bright until they speak.

Topic Locked

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

Sign in to reply to this topic.