![](/i/fill.gif) |
![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
Hello,
Let's assume that we have a colors map :
#declare MyColorMap = color_map {
[ 0.00 rgb < 1.00, 0.00, 0.00> ]
[ 0.50 rgb < 1.00, 1.00, 0.00> ]
[ 1.00 rgb < 0.00, 0.00, 1.00> ]
}
Is there a way to recover the color for specific index ?
Something that looks like : GetColor(MyColorMap, index)
--
Kurtz le pirate
Compagnie de la Banquise
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
kurtz le pirate <kur### [at] gmail com> wrote:
> Hello,
>
> Let's assume that we have a colors map :
> #declare MyColorMap = color_map {
> [ 0.00 rgb < 1.00, 0.00, 0.00> ]
> [ 0.50 rgb < 1.00, 1.00, 0.00> ]
> [ 1.00 rgb < 0.00, 0.00, 1.00> ]
> }
>
> Is there a way to recover the color for specific index ?
> Something that looks like : GetColor(MyColorMap, index)
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.
https://wiki.povray.org/content/Reference:Color_Map
Alternatively, you could roll your own and use a spline function to do the
interpolation, in case there something special that the above can't handle.
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
"Bald Eagle" <cre### [at] netscape net> 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:
#version 3.8;
global_settings {
assumed_gamma 1.0
}
#include "math.inc"
#declare E = 0.000001;
#declare Camera_Orthographic = true; //
<----################################################################################
#declare Camera_Position = <0, 0, -20>; // front view
#declare Camera_Look_At = <0, 0, 0> ;
#declare Fraction = 1; // functions as a zoom for the orthographic view: 4
zooms in 4x, 8 zooms in 8x, etc.
#declare Aspect = image_width/image_height;
// ###########################################
camera {
#if (Camera_Orthographic = true)
orthographic
right x*image_width/(Fraction)
up y*image_height/(Fraction)
#else
right x*image_width/image_height
up y
#end
location Camera_Position
look_at Camera_Look_At}
// ###########################################
sky_sphere {pigment {rgb 1}}
light_source {<0, 0, -image_width> color rgb 1}
#declare MyColorMap = color_map {
[ 0.00 rgb < 1.00, 0.00, 0.00> ]
[ 0.50 rgb < 1.00, 1.00, 0.00> ]
[ 1.00 rgb < 0.00, 0.00, 1.00> ]
}
#declare Gradient = pigment {gradient x color_map {MyColorMap}}
box {<0, image_height/3, 0>, < image_width, 2*image_height/3, 0.01> pigment
{Gradient scale image_width} translate -x*image_width/2}
#declare GradientFunction = function {pigment {Gradient}}
#for (XX, 16, 640-16, 16)
#local R = GradientFunction (XX/image_width, 0, 0).red;
#local G = GradientFunction (XX/image_width, 0, 0).green;
#local B = GradientFunction (XX/image_width, 0, 0).blue;
sphere {<XX, 0, 0> 5 pigment {rgb <R, G, B>} translate -x*image_width/2}
#end
Post a reply to this message
Attachments:
Download 'colormapinterpolation.png' (18 KB)
Preview of image 'colormapinterpolation.png'
![colormapinterpolation.png](/povray.general/attachment/%3Cweb.637a8917f841873a1f9dae3025979125%40news.povray.org%3E/colormapinterpolation.png?ttop=443780&toff=150&preview=1)
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
On 20/11/2022 21:07, Bald Eagle wrote:
> "Bald Eagle" <cre### [at] netscape net> 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
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
kurtz le pirate <kur### [at] gmail com> wrote:
> On 20/11/2022 21:07, Bald Eagle wrote:
> > "Bald Eagle" <cre### [at] netscape net> 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
> // -------------------------------------------------------------------
>...
Hi Kurz
I don't know if it was your intention to not extract the filter and
transmit components of the color.
If you write the macro like this:
#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 Color = color GradientFunction(Index, 0, 0);
Color
#end // macro GetColor
- then it will extract all the color components.
You'll also get a faster macro because of only one call to the pigment
function instead of three.
The value returned from the pigment function is a rgbft vector, so if all
of the components are of interest then there's no need to disassemble it
and then reassemble it.
--
Tor Olav
http://subcube.com
https://github.com/t-o-k
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
On 22/11/2022 13:11, Tor Olav Kristensen wrote:
>
> Hi Kurz
Hello
> I don't know if it was your intention to not extract the filter and
> transmit components of the color.
Yes, in this case, I am not interested in the values of t and f.
I want to use the color_map as a lookup table to draw the julia sets.
> If you write the macro like this:
>
>
> #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 Color = color GradientFunction(Index, 0, 0);
>
> Color
>
> #end // macro GetColor
>
>
> - then it will extract all the color components.
>
> You'll also get a faster macro because of only one call to the pigment
> function instead of three.
Well seen !
Thanks
--
Kurtz le pirate
Compagnie de la Banquise
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |