|
|
On 2016-07-28 03:18 AM (-4), scott wrote:
> It's quite common in colour stuff to use a scale of 0-100 (per cent)
> rather than 0-1. It seems like this is what is happening here. You just
> need to divide by 100 to match the units of your image sampling.
>
> You definitely don't want to divide by 10, that is unrelated, and just a
> fudge that will happen to work because you are using 10nm bands (and
> 10*10=100). You need to multiply by the band width to get the correct
> result. For example, if you happened to use 5nm bands:
>
> #declare Acc = <0, 0, 0>;
> #for (I, 0, 70)
> #local Wl = 380 + I * 5;
> #declare Acc = Acc + CMF_xyz (Wl) * 5 * LEVEL; // Illuminant E
> #end
> #declare C = Acc / 100; // convert from % to 0...1 scale
>
> You should get the same answer (roughly) for any reasonable bandwidth
> you decide to use.
Since the macro I'm writing works on SpectralRender arrays, that 10 nm
is not going to change. Nevertheless, I will follow your advice for
clarity's sake. However, I'm moving the 10 outside the loop:
#declare Acc = <0, 0, 0>;
#for (I, 0, 35)
#local Wl = 380 + I * 10;
#declare Acc = Acc + CMF_xyz (Wl) * LEVEL; // Illuminant E
#end
#declare C = Acc * 10 / 100; // convert from % to 0...1 scale
(The production macro also loses the temporary variable Wl. It appears
in my example only because of a carryover from my debugging.)
Post a reply to this message
|
|