POV-Ray : Newsgroups : povray.general : Change color based on number and color_map Server Time
28 Dec 2024 05:35:37 EST (-0500)
  Change color based on number and color_map (Message 1 to 5 of 5)  
From: worldbuilder
Subject: Change color based on number and color_map
Date: 9 Mar 2012 15:50:01
Message: <web.4f5a6ce8fe198feb8f6b920@news.povray.org>
I have a variable that can be set to a temperature and I am trying to get it to
control the color. My current setup is to use a color_map to get the range of
color needed, then map a pattern to that gradient. The only problem is that I
can't use color_map with a solid color, and if I try first mapping some bozo to
a gray value determined by STemperature and then to my color_map it maps the
temp gradient directly to the noise, bypassing the effort to make it one solid
color.


Post a reply to this message

From: Anthony D  Baye
Subject: Re: Change color based on number and color_map
Date: 9 Mar 2012 16:20:01
Message: <web.4f5a72eca14f3928d7f39bd00@news.povray.org>
"worldbuilder" <nomail@nomail> wrote:
> I have a variable that can be set to a temperature and I am trying to get it to
> control the color. My current setup is to use a color_map to get the range of
> color needed, then map a pattern to that gradient. The only problem is that I
> can't use color_map with a solid color, and if I try first mapping some bozo to
> a gray value determined by STemperature and then to my color_map it maps the
> temp gradient directly to the noise, bypassing the effort to make it one solid
> color.

I've never found any way to convert from temperature to color, but something you
could try is creating an array of an arbitrary size, and then fill it with color
vectors taken from your gradient using eval_pigment.

once you have the array filled you can grab the color from your array by passing
it an index.

if your gradient is an image you can turn it into a pigment by using an image
map and scaling it appropriately.

Regards,

A.D.B.


Post a reply to this message

From: Alain
Subject: Re: Change color based on number and color_map
Date: 11 Mar 2012 13:52:30
Message: <4f5ce65e$1@news.povray.org>

> I have a variable that can be set to a temperature and I am trying to get it to
> control the color. My current setup is to use a color_map to get the range of
> color needed, then map a pattern to that gradient. The only problem is that I
> can't use color_map with a solid color, and if I try first mapping some bozo to
> a gray value determined by STemperature and then to my color_map it maps the
> temp gradient directly to the noise, bypassing the effort to make it one solid
> color.
>
>

Don't use a color_map, but a spline.
Have controll points for various temperatures and access it with the 
desired temperatures you want to represent.
Use the returned value as a plain pigment.


If you use many temperature samples, a linear spline may be enough, but 
a cubic_spline will give you a smooth regular curve.
This is a big advantage compared to an array. An array only allow you to 
have discreete values, and may need to be vary large, while a spline 
gives you a continously changing value and support non-integer indexes.
It's accessed in a way that is similar to an array.



Alain


Post a reply to this message

From: Le Forgeron
Subject: Re: Change color based on number and color_map
Date: 12 Mar 2012 11:12:33
Message: <4f5e1261@news.povray.org>
Le 11/03/2012 18:52, Alain a écrit :
> Don't use a color_map, but a spline.
> Have controll points for various temperatures and access it with the
> desired temperatures you want to represent.
> Use the returned value as a plain pigment.
> 
> 
> If you use many temperature samples, a linear spline may be enough, but
> a cubic_spline will give you a smooth regular curve.

IIRC:
If you are using a linear spline, I guess there is no gain from using a
color_map. linear Interpolation is performed on color_map when the value
is not found in the map.

Using a non-linear spline might be trickier: some points are used only
as control and will not ever appear. And such points vary with the kind
of spline. (cubic_spline eats the first and last points, for instance,
something that should be considered when doing mapping)

Also, the 3 other splines available (*) in povray are subject to provide
values outside the control points range. (it might surprise you to get a
blue component of 1.2 when all your blue controls were in the 0 to 1 range!)

*: cubic_spline, natural_spline and quadratic_spline.


Post a reply to this message


Attachments:
Download 'leforgeronspline11.png' (9 KB) Download 'leforgeronspline03.png' (8 KB) Download 'leforgeronspline09.png' (7 KB) Download 'leforgeronspline10.png' (8 KB)

Preview of image 'leforgeronspline11.png'
leforgeronspline11.png

Preview of image 'leforgeronspline03.png'
leforgeronspline03.png

Preview of image 'leforgeronspline09.png'
leforgeronspline09.png

Preview of image 'leforgeronspline10.png'
leforgeronspline10.png


 

From: Alain
Subject: Re: Change color based on number and color_map
Date: 14 Mar 2012 22:37:24
Message: <4f6155e4$1@news.povray.org>
Le 2012/03/12 11:12, Le_Forgeron a écrit :
> Le 11/03/2012 18:52, Alain a écrit :
>> Don't use a color_map, but a spline.
>> Have controll points for various temperatures and access it with the
>> desired temperatures you want to represent.
>> Use the returned value as a plain pigment.
>>
>>
>> If you use many temperature samples, a linear spline may be enough, but
>> a cubic_spline will give you a smooth regular curve.
>
> IIRC:
> If you are using a linear spline, I guess there is no gain from using a
> color_map. linear Interpolation is performed on color_map when the value
> is not found in the map.

A color_map values are limited to the 0..1 range, a spline can go from 
3000°K (IR) to 120000°K (UV) if you want/need to. You can use something 
like this:
pigment{BlackBodySpline[5700]} for a 5700°K colour.

>
> Using a non-linear spline might be trickier: some points are used only
> as control and will not ever appear. And such points vary with the kind
> of spline. (cubic_spline eats the first and last points, for instance,
> something that should be considered when doing mapping)

In this case, it's used to relate a colour to a temperature. Just 
prolong the range into IR and UV areas outside the visible range or 
untill it's no longer signifiant. You need to go farther in the high 
temperatues beyong the violet.

>
> Also, the 3 other splines available (*) in povray are subject to provide
> values outside the control points range. (it might surprise you to get a
> blue component of 1.2 when all your blue controls were in the 0 to 1 range!)
>
> *: cubic_spline, natural_spline and quadratic_spline.

Alain


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.