POV-Ray : Newsgroups : povray.advanced-users : Simple colour_map question Server Time
25 Nov 2024 09:29:00 EST (-0500)
  Simple colour_map question (Message 1 to 7 of 7)  
From: Andrew Coppin
Subject: Simple colour_map question
Date: 15 Feb 2003 10:26:39
Message: <3e4e5c2f@news.povray.org>
Suppose I declare a colour_map. Is there a way to read a colour out of the
map? In other words, is there a way I can feed in a nindex value and find
the corresponding colour?

The docs say I can fetch the colour of a point out of a texture, but what
I'm asking for is one step simpler than that... Any ideas folks?

Andrew.

PS. Yes, I *know* it's possible to do the linear interpolation manually, but
it's a pain to keep typing this stuff...


Post a reply to this message

From: Mike Williams
Subject: Re: Simple colour_map question
Date: 15 Feb 2003 11:01:04
Message: <rIOCOCA2HmT+Ewdl@econym.demon.co.uk>
Wasn't it Andrew Coppin who wrote:
>Suppose I declare a colour_map. Is there a way to read a colour out of the
>map? In other words, is there a way I can feed in a nindex value and find
>the corresponding colour?
>
>The docs say I can fetch the colour of a point out of a texture, but what
>I'm asking for is one step simpler than that... Any ideas folks?

Well, you could go one step more complicated than that, and declare an
object that has a pigment something like
  pigment { function{ nindex } colour_map {[...
(where nindex is a declared constant) and then fetch the colour off any
point on that object.

If you want to be able to process many nindex values from the same
colour map in one scene, then you could declare an object that has a
pigment like
  pigment { function{ x } colour_map {[...
then fetch the colours off that object at points where the x co-ordinate
is equal to the nindex values you are interested in.

-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

From: Christopher James Huff
Subject: Re: Simple colour_map question
Date: 15 Feb 2003 12:42:20
Message: <cjameshuff-BBAE17.12411515022003@netplex.aussie.org>
In article <3e4e5c2f@news.povray.org>,
 "Andrew Coppin" <orp### [at] btinternetcom> wrote:

> Suppose I declare a colour_map. Is there a way to read a colour out of the
> map? In other words, is there a way I can feed in a nindex value and find
> the corresponding colour?
> 
> The docs say I can fetch the colour of a point out of a texture, but what
> I'm asking for is one step simpler than that... Any ideas folks?

Untested, but:

#macro make_cmap_fn(CMap)
    #local CFn =
    function {
        pigment {function {x}
            color_map {CMap}
        }
    }
    function (tVal) {CFn(tVal, 0, 0)}
#end

#macro eval_cmap(T, CMap)
    #local CFn =
    function {
        pigment {function {T}
            color_map {CMap}
        }
    }
    (CFn(0, 0, 0))
#end


#declare CFn = make_cmap_fn(MyCMap)
#declare CVal = CFn(0.35);

#declare CVal = eval_cmap(0.35, MyCMap);

-- 
Christopher James Huff <cja### [at] earthlinknet>
http://home.earthlink.net/~cjameshuff/
POV-Ray TAG: chr### [at] tagpovrayorg
http://tag.povray.org/


Post a reply to this message

From: Tim Nikias
Subject: Re: Simple colour_map question
Date: 15 Feb 2003 14:44:45
Message: <3e4e98ad@news.povray.org>
Just write yourself a macro which interpolates the
indices and colors according to the indices.
You might want to do this using two arrays, one filled
with the colors, the other with the index-values.
Then you just write a macro which runs off with a given
index, searches the two closest (above and below the
given one), and interpolates appropriately using the colors
given by the other array.
This only works with simple linear colormaps, poly_wave
etc would have to undergo postprocessing on the index
values in the array (or the given one) to handle the change
in colorshifts...

--
Tim Nikias
Homepage: http://www.digitaltwilight.de/no_lights/index.html
Email: Tim### [at] gmxde

> Suppose I declare a colour_map. Is there a way to read a colour out of the
> map? In other words, is there a way I can feed in a nindex value and find
> the corresponding colour?
>
> The docs say I can fetch the colour of a point out of a texture, but what
> I'm asking for is one step simpler than that... Any ideas folks?
>
> Andrew.
>
> PS. Yes, I *know* it's possible to do the linear interpolation manually, but
> it's a pain to keep typing this stuff...
>
>


Post a reply to this message

From: Andrew Coppin
Subject: Re: Simple colour_map question
Date: 15 Feb 2003 16:25:05
Message: <3e4eb031@news.povray.org>
Well, I suppose ultimately that's what I do... It's just that POV-Ray's
existing colour_map{} syntax is clearer and easier than two seperate arrays
(and remembering to keep them the same size). Plus I didn't really want to
reinvent the wheel.

Ah well - it can be done. Just wondered if there was Another Way...

Thanks.
Andrew.

---BEGIN RANDOM QUOTATION---
"Please... there must be another way..."
"There IS no 'other way'... I must bid you good evening Mrs...?"
"Brisby."
---END RANDOM QUOTATION---


Post a reply to this message

From: Christopher James Huff
Subject: Re: Simple colour_map question
Date: 15 Feb 2003 16:26:14
Message: <cjameshuff-7E875D.16251015022003@netplex.aussie.org>
In article <3e4e98ad@news.povray.org>, "Tim Nikias" <tim### [at] gmxde> 
wrote:

> Just write yourself a macro which interpolates the
> indices and colors according to the indices.

That would work, but is probably the hardest and most complicated way of 
doing it, as well as being slow to parse. See my other message for a 
better way.


> This only works with simple linear colormaps, poly_wave
> etc would have to undergo postprocessing on the index
> values in the array (or the given one) to handle the change
> in colorshifts...

Waveforms are attributes of patterns, not color maps.

-- 
Christopher James Huff <cja### [at] earthlinknet>
http://home.earthlink.net/~cjameshuff/
POV-Ray TAG: chr### [at] tagpovrayorg
http://tag.povray.org/


Post a reply to this message

From: Tim Nikias
Subject: Re: Simple colour_map question
Date: 15 Feb 2003 16:32:41
Message: <3e4eb1f9@news.povray.org>
> Waveforms are attributes of patterns, not color maps.

Hm, you're right. Stupid me. :-)

It might be slower to parse, but maybe one could extend the
features, e.g. adding new colors with indices later on, calculating
waveforms on the colormaps, etc. At least for some color-macros
this might come useful. But I guess thats based on individual taste
and ability.


--
Tim Nikias
Homepage: http://www.digitaltwilight.de/no_lights/index.html
Email: Tim### [at] gmxde

>
> > Just write yourself a macro which interpolates the
> > indices and colors according to the indices.
>
> That would work, but is probably the hardest and most complicated way of
> doing it, as well as being slow to parse. See my other message for a
> better way.
>
>
> > This only works with simple linear colormaps, poly_wave
> > etc would have to undergo postprocessing on the index
> > values in the array (or the given one) to handle the change
> > in colorshifts...
>
> Waveforms are attributes of patterns, not color maps.
>
> --
> Christopher James Huff <cja### [at] earthlinknet>
> http://home.earthlink.net/~cjameshuff/
> POV-Ray TAG: chr### [at] tagpovrayorg
> http://tag.povray.org/


Post a reply to this message

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