Re: approximation to pow(n,x)?
Jon Watte <[email protected]>
| Newsgroups | gmane.games.devel.algorithms |
|---|---|
| Message-ID | <[email protected]> |
Nathaniel Hoffman wrote:
> lowly cosine power - it's not completely physically meaningless. If you
> are using Blinn-Phong (N dot H, which is much to be preferred over
> original Phong - R dot L), then using a cosine power is equivalent to
>
Except you already have the reflection vector for your environment
mapping, so why not re-use it?
As far as I can tell, cos(half-vector dot) behaves the same as cos(0.5 +
reflection-vector dot), so you can make them equivalent by just
adjusting the dot product value you put into the power function. Why do
you think that the half vector is preferable?
When it comes to approximating the power function for a specular
highlight, you can go with a texture lookup -- 0 .. 1 on one axis, and 0
.. 200 on the other, for example. Or you can do the cheapest of the cheap:
float cheap_pow(float x, float n)
{
x = saturate(1 - (1 - x ) * (n * 0.333));
return x * x;
}
Not very accurate, but very cheap, and still creates a soft-ish diffuse
highlight shape, which tends to be slightly narrower towards the edges.
It also gets worse below power 5 or so.
Sincerely,
jw
--
Revenge is the most pointless and damaging of human desires.
------------------------------------------------------------------------------
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