Quote from: CCC on August 17, 2009, 08:55:54 PM
That is insane. We really need a Photoshop like gradient shader. It would be easy to implement.
Thats why I have solved in another way:
1) multiply the 15 colors by the constants of x in (1+x)^14 i.e 1, 14, 91, ..., 3432, 3003, ... 14, 1
i.e multiply color1 by one color 2 by 14 e.t.c
This should be fast since it is all constants.
2 If s is the controlling variable (0..1) and c is the complement, generate all 15 powers of s and c where the sum of powers is 14.
This can be done in the following way
generate s^0 = 1
generate s^1 = s
multiply to get s^2
multiply s^1 and s^2 to get s^3
build vector vs2.1.0 from s^2 s^1 s^0
multiply this vector with s^3 to get vs5.4.3
continue this until you have vector vs14.13.12 (In total 5 vectors)
In the same way build vector vc0.1.2 vc 3.4.5 e.t.c (In total 5 vectors)
multiply vector vs2.1.0 and vc12.13.14 etc
extract the 15 components from these 5 resulting vectors (X to scalar, Y to scalar, Z to scalar)
multiply the 15 weigted colors from step 1 by these 15 variables.
3)
Add all the 15 results from step 2.
Thats all