Math behind Graph Bias adjustment 2003-11-20 - By Helmar Gerhardt
Back Thanks for the help. Really appreciated.
Regards,
Helmar
-- -- Original Message -- -- From: "stephan mantler" <step@(protected)> To: <maya-dev@(protected)> Sent: Thursday, November 20, 2003 12:45 AM Subject: Re: Math behind Graph Bias adjustment
> Helmar Gerhardt wrote: > > Hi, I'm trying to figure out the mathematics behind Maya's ramp graph > > input bias adjustment. (...) If the input bias is 0.0 then a value of > > 0.5 will map to the exact middle of the opacity curve. > > i can imagine a number of ways to achieve this, but standard > gamma correction seems like a good starting point: > > in : 0 <= x <= 1; gamma > 0 > out: 0 <= f(x) <= 1 > > f(x, gamma) = x^(1/gamma) > > > now, since you would like to specify a bias instead of gamma: > (note that we can assume -0.5 < bias < 0.5...) > > f(0.5,gamma) = bias + 0.5 > > 0.5^(1/gamma) = bias + 0.5 > > or, after a quick excursion into algebra, > > gamma = log(0.5)/log(0.5+bias) > > which can then be plugged back into our original formula: > > f(x, bias) = x^(1/(log(0.5)/log(0.5+bias)) or, equally, > > f(x, bias) = x^(-log(0.5+bias)/log(2)) > > greetings, > -stephan > > ps. hope the math is correct ;-) > > -- > stephan mantler | mail - step@(protected) > -- ---- ---- ---- ---- -----| icq - 799434 > It's not an adventure | fone - +43 (676) 308-5342 > until something f--ks up. | web - www.stephanmantler.com > > > -- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- --- > List-help: <mailto:listar@(protected)?Subject=help> > List-archive: <http://www.highend3d.com/maya/devarchive/> > >
-- -- Original Message -- -- From: "Kelly Brock" <Kerby@(protected)> To: <maya-dev@(protected)> Sent: Thursday, November 20, 2003 10:09 AM Subject: RE: Math behind Graph Bias adjustment
> I can see two possibilities here, unfortunately the description is > relatively vague since it says "most" values will shift. Anyway, the first > one is the easier one, remap the range of the curve to the range 0 to > 1-bias. This does not "sound" like the answer but you can check it > relatively simply I imagine. > > The other, more useful version that I can think of is the bias/gain > functionality described by Ebert (think it was Ebert at least, may be > Musgrave, no references around here to double check it): > > const float LOGP5 = -0.693147f; > > const float Bias(const float value, const float bias) > { > return powf( value, logf(bias)/LOGP5 ); > } > > const float Gain(const float value, const float gain) > { > if( value < 0.5f ) > return Bias(2.0f*value, 1.0f-gain) / 2.0f; > return 1.0f-Bias(2.0f-2.0f*value, 1.0f-gain) / 2.0f; > } > > This is very similar to the other suggestion of using a gamma function, and > in fact may give identical results in certain ranges of inputs. Graph the > equation for 0, .25, .5, .75 and 1 to get an idea of the shape. It's a very > useful function in this sort of "tweaky" area, though you may need to remap > the bias range to match their definition. Of course they may be using > something completely different, it's worth a try though.. > > Kelly Brock > The Sims Console Group > Maxis - Electronic Arts >
-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- --- List-help: <mailto:listar@(protected)?Subject=help> List-archive: <http://www.highend3d.com/maya/devarchive/>
|
|