Re: [Algorithms] approximation to pow(n,x)?
Brought to you by:
vexxed72
From: Jeff R. <je...@8m...> - 2009-11-04 18:14:30
|
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? On Wed, Nov 4, 2009 at 12:06 PM, Jon Watte <jw...@gm...> wrote: > 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 > GDA...@li... > https://lists.sourceforge.net/lists/listinfo/gdalgorithms-list > Archives: > http://sourceforge.net/mailarchive/forum.php?forum_name=gdalgorithms-list > -- Jeff Russell Engineer, 8monkey Labs www.8monkeylabs.com |