|
![](/i/fill.gif) |
>Gert Van den Eynde" <gvd### [at] hotmail com> schrieb im Newsbeitrag
news:41a35ab0@news.povray.org...
> Gert Van den Eynde wrote:
>
> 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?
Hi,
i borrowed the average-pigment-idea by Slimes answer to the thread
'3d color function' in povray.newusers which looks like this:
pigment {
average
pigment_map {
[1 function {f_r(x,y,z)} color_map {[0 rgb 0][1 rgb <1,0,0>*3]}]
[1 function {f_g(x,y,z)} color_map {[0 rgb 0][1 rgb <0,1,0>*3]}]
[1 function {f_b(x,y,z)} color_map {[0 rgb 0][1 rgb <0,0,1>*3]}]
}
}
now you need the 3 functions for rgb;
i think the difficulty in converting your function to POV-SDL are the
if-else-constructs. These can be modeled in a function with the
'select'-function. Your function converted then looks like this:
#declare f_r = function(v)
{
select(
v-0.5,
0,
select(
v-0.75,
4*v-2,
1
)
)
};
#declare f_g = function(v)
{
select(
v,
0, // v<0
select( // v>0
v-1,
select( // 0<v<1
v-0.25,
4*v, // 0<v<0.25
select( // 1>v>0.25
v-0.75,
1, // 0.25<v<0.75
4-4*v // 1>v>0.75
)
),
0 // v>1
)
)
};
#declare f_b = function(v)
{
select(
v-0.25,
1,
select(
v-0.5,
2-4*v,
0
)
)
};
of course you can write this in one line if you want, i just
formatted it for better readibility.
For your specific rgb-function though i would do it with the
following functions, which do the same job, just a bit more
elegant:
#declare f_r = function(v) { min(max(4*v-2,0),1) };
#declare f_g = function(v) { min(max(2-abs(4*(v-0.5)),0),1) };
#declare f_b = function(v) { min(max(2-4*v,0),1) };
If you want to avoid the discontinuities at 0.25, 0.5 and 0.75
you'll have to use more smooth functions like the cosine.
> thanks for any tips,
no problem
> gert
Regards,
Thies
Post a reply to this message
|
![](/i/fill.gif) |