|
|
On 20/11/2022 21:07, Bald Eagle wrote:
> "Bald Eagle" <cre### [at] netscapenet> wrote:
>
>> Sure - I think you could take something like a gradient pigment pattern, apply
>> that color mapping to it, and then use that as a function. Then you could pass
>> in a space coordinate with a vector component parallel to that gradient, and the
>> function would return the interpolated color vector as a result.
>> You would of course, have to write / generate 3 functions - one for the .r, .g,
>> and .b components.
>
>
>
> Like this:
> ...
Waouh, impressive !!!
Based on your brilliant example, here is the macro :
// -------------------------------------------------------------------
#macro GetColor(thisColorMap, thisEntry)
#local index = max(0.0, min(thisEntry, 1.0));
#local Gradient = pigment { gradient x color_map { thisColorMap } }
#local GradientFunction = function { pigment { Gradient } }
#local R = GradientFunction (index, 0, 0).red;
#local G = GradientFunction (index, 0, 0).green;
#local B = GradientFunction (index, 0, 0).blue;
rgb <R, G, B>
#end
// -------------------------------------------------------------------
And used like that :
sphere {
<XX, 0, 0> 5
pigment { GetColor(MyColorMap, XX/image_width) }
translate -x*image_width/2
}
--
Kurtz le pirate
Compagnie de la Banquise
Post a reply to this message
|
|