Re: approximation to pow(n,x)?

"Nathaniel Hoffman" <[email protected]>
Newsgroups gmane.games.devel.algorithms
Message-ID <[email protected]>
Robin is correct in that the problem with reflection-vector highlights is
the shape (the center of the highlight will be in the same location under
both formulations), and that the problem is most noticeable at grazing
angles. However, the images he gives don't show the effect as much as a
flat surface would.

Consider the following examples of real-life highlights:

* The "golden path" formed by the setting sun on the ocean
* Vertical streaks from car highlights on wet streets

And similar cases. Half-angle highlights will give you the correct shape.
Reflection-vector highlights will always stay circular - in these cases
you will get a large circular blob instead of the narrow vertical streak
you would get in real life.

The half-angle formulation is not just more physically correct than the
reflection-vector formulation, it is fundamentally more meaningful. This
affects things other than highlight shape, for example the correct way to
compute the Fresnel factor.

The half-vector comes from microfacet theory. Imagine that the surface is
actually a large collection of tiny flat mirrors when viewed under
magnification. Recall that a mirror only reflects light in the reflection
direction. For given light vector L and view vector V, only mirrors which
happen to be angled just right to reflect L into V will matter for the
purpose of shading. All other mirrors will be reflecting L into other
directions. The intensity of the reflection is proportional to the
percentage of mirrors that are angled "just right".

To be angled "just right" to reflect L into V, the surface normal of the
mirror has to be half-way between them - in other words the microfacet
normal needs to be equal to H. The question "what percentage of mirrors
are angled just right" becomes "what percentage of mirrors have a normal
equal to H".

The way to answer this question is to define a microfacet normal
distribution function, or NDF for the surface. You can plug into this
function any example direction, and it will tell you the percentage of
microfacets with normals pointing in that direction (I'm glossing over a
few mathematical details here). NDFs are defined in the local tangent
space of the surface. In isotropic NDFs the only parameter is the
elevation angle of the microfacet normal in tangent space - in other words
the angle between N and H.

Since in most cases surface microstructure results from random processes,
the NDF is a Gaussian-ish blob. The cosine raised to a power is simply an
approximation of this blob (there should also be a normalization factor,
which I don't discuss since this email is already too long).

When you calculate (N.H)^m, you are actually evaluating the NDF for the
case of microfacet normal equal to H, or in other words calculating the
answer to the question "what percentage of microfacets are participating
in the reflection of light from L to V". When you calculate (V.R)^m, you
aren't calculating anything with a physical meaning.

Understanding this helps with things like Fresnel. The Fresnel factor for
a mirror is a function of the angle between the mirror normal and the
light vector (or reflection vector). Since all microfacets participating
in the reflection have their microfacet normal equal to H, the angle for
Fresnel can be found by computing (L dot H) or (V dot H). This is the
cosine you should plug into the Shlick Fresnel approximation, for example
((V dot N) is correct for Fresnel applied to an environment map, but not
for specular highlights).

I hope this clears up some of the confusion. (begin shameless plug)There
is also a fairly detailed explanation of this in "Real-Time Rendering, 3rd
edition"(end shameless plug).

Naty Hoffman

> The difference is in the shape of specular highlights. Where
> Phong specular highlights at grazing angles are streched out
> moon shapes, the Blinn half-angle highlights retain a more
> circular shape. Real world photos of specular surfaces at
> grazing angles more closely resemble Blinn shapes than Phong,
> plus the Blinn model has some good physical reasoning behind
> it to do with reflection from distributions of microfacets.
>
> http://img22.imageshack.us/img22/7/blinn.jpg
> http://img526.imageshack.us/img526/758/phong.jpg
>
> - Robin Green.
>
> On Wed, Nov 4, 2009 at 10:14 AM, Jeff Russell <[email protected]>
> wrote:
>> Not to derail the conversation, but I've never really understood
>> why half vectors are preferable to an actual reflection vector,
>> either in terms of efficiency or realism. I've always just used
>> reflection, am I missing something?


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
GDAlgorithms-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gdalgorithms-list
Archives:
http://sourceforge.net/mailarchive/forum.php?forum_name=gdalgorithms-list
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.