PDA

View Full Version : standard graphics lerp



zed
03-28-2005, 01:44 PM
whats the standard graphics way of describing a lerp?
texenvcombine uses a*X + b*(1-X) but both glsl and cg use a*(1-X) + b*X

ARB_texture_env_combine INTERPOLATE_ARB
Arg0 * (Arg2) + Arg1 * (1-Arg2)
-------------------------------
glsl genType mix (genType x,genType y,genType a)
Returns x * (1 a) + y * a
-------------------------------
cg lerp(a,b,f)
(1-f)*a + b*f

ps/ why has the glsl spec got 1 a there that should be 1.0 - a, tsk tsk, naughty boys :)

ScottManDeath
03-28-2005, 04:46 PM
between = from + (to - from) * factor; // with one '*' less ;)I think the CG/GLSL formulas are the reference because they yield 'from' when the factor is 0.0f and 'to' when the factor is 1.0f;

As the hw for ARB_texture_env_combine is quite restricted, the used formula could be a consequence of the hw design?

Just my 0.02

V-man
03-29-2005, 07:37 AM
And ARB_fp defines it as

LRP dst, src0, src1, src2;

and src0 is the weight
src0 * src1 + (1-src0) * src2

so it's really a matter of operand order. There is no standard.

There is also the 3 operation version
src2 + src0 * (src1 - src2)