POV-Ray : Newsgroups : povray.general : color (pigment) as an absolute function of coordinates : Re: color (pigment) as an absolute function of coordinates Server Time
2 Aug 2024 08:13:38 EDT (-0400)
  Re: color (pigment) as an absolute function of coordinates  
From: Gert  Van den Eynde
Date: 23 Nov 2004 10:43:44
Message: <41a35ab0@news.povray.org>
Gert  Van den Eynde wrote:

> Thies Heidecke wrote:
> 
>> "Gert Van den Eynde" <gvd### [at] hotmailcom> schrieb im Newsbeitrag
>> news:41a1cef1@news.povray.org...
>>> Hi all,
>> Hi,
>> 
>>> Is there a good way to have the pigment dependent on the absolute
>>> (x,y,z) position? I want to create a height-field and a sphere where the
>>> pigment
>> is
>>> determined as a function of the <x,y,z,> vector....
>> As a first short answer, have a look at the POV-Documentation at
>>   '3.4.11.15  Function as pattern'
>> If you have more questions feel free to ask!
> 
> thanks, missed that one.
> 
> note to self: rtmom (read the manual once more)

hmm, did that and it isn't really clear to me how to proceed. Below is (in
Octave) my color function. The variable v in the script is to be the height
of the height-field (y-value). vmin and vmax are 0 and 1 in the case of a
height_field, no? How do I put this function in povray and have it used as
the pigment of my heightfield?

thanks for any tips,
gert 

function [r,g,b] = mapcolor(v,vmin,vmax)

if (v < vmin),
    v = vmin;
end

if (v > vmax),
    v = vmax;
end

dv = vmax-vmin;

r = 1; g = 1; b = 1;

if (v < (vmin + 0.25 * dv)),
    r = 0.0;
    g = 4.0*(v-vmin)/dv;
elseif (v < (vmin + 0.5*dv)),
    r = 0.0;
    b = 1.0+4.0*(vmin+0.25*dv-v)/dv;
elseif (v < (vmin +0.75*dv)),
    r = 4.0*(v-vmin-0.5*dv)/dv;
    b = 0.0;
else
    g = 1.0+4.0*(vmin+0.75*dv-v)/dv;
    b = 0.0;
end


Post a reply to this message

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