POV-Ray : Newsgroups : povray.newusers : Is it possible to have color_map values depend on distance from a point ? Server Time
5 Nov 2024 11:21:14 EST (-0500)
  Is it possible to have color_map values depend on distance from a point ? (Message 1 to 6 of 6)  
From: Bernard Hatt
Subject: Is it possible to have color_map values depend on distance from a point ?
Date: 18 Nov 2003 17:35:01
Message: <web.3fba9d39f0c1c7f425bdb9a40@news.povray.org>
I'm trying to put a coloured bozo 'splodge' on an object, where the
color_map threshold varies from the center to the edge.

At the center of the splodge it should be:
     bozo color_map [0.0 rgbf 1] [0.0 Red ]   ie. all Red
Halfway towards the edge it should be
     bozo color_map [0.5 rgbf 1] [0.5 Red ]   ie. half and half
and at the edge
     bozo color_map [1.0 rgbf 1] [1.0 Red ]   ie. all background

The best approximation I have to this is:

box { <-2,-2,0> <2,2,1 >
    texture { pigment {Green}}
#declare i=0;
#while (i<1.0)
    texture {
        pigment {
            object {
            sphere { 0 i }
                pigment { rgbf 1 }
                pigment {
                    bozo scale .025
                    color_map {
                        [i rgbf 1]  [i Red]
                    }
                }
            }
        }
    }
#declare i=i+0.02;
#end
}

Which looks OK at at distance, but you can see the bands for the layers
if you are close. Is there a better way to create this effect ?

Thanks,

Bernard


Post a reply to this message

From: Christopher James Huff
Subject: Re: Is it possible to have color_map values depend on distance from a point ?
Date: 18 Nov 2003 21:47:24
Message: <cjameshuff-C7AE9D.21441218112003@netplex.aussie.org>
In article <web.3fba9d39f0c1c7f425bdb9a40@news.povray.org>,
 "Bernard Hatt" <bmh### [at] arkadydemoncouk> wrote:

> I'm trying to put a coloured bozo 'splodge' on an object, where the
> color_map threshold varies from the center to the edge.

There are several options. You could create a pigment map with the 
spherical pattern...basically what you did with layered textures, but 
far more efficient. However, with the example you gave, it would be 
simpler to just use a function pattern. Something like this:

box { <-2,-2,0> <2,2,1 >
    texture {
        pigment {
            function {
                select(f_noise3d(x/0.025, y/0.025, z/0.025) > f_r(x, y, 
z), 1, 0)
            }
            color_map {
                [0.5 color Green]
                [0.5 color Red]
            }
        }
    }
}

If the noise function (which is just what the bozo pattern is) is less 
than the distance, the pattern has a value of 1, otherwise it is 0. You 
may also get good results with something like:

function {f_noise3d(x/0.025, y/0.025, z/0.025)*max(0, 1 - f_r(x, y, z))}

This is essentially the same as multiplying bozo and the spherical 
pattern. The value of the noise gets scaled down to 0 as the distance 
from the origin approaches 1.

-- 
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: Bernard Hatt
Subject: Re: Is it possible to have color_map values depend on distance from a point= ?
Date: 19 Nov 2003 12:35:01
Message: <web.3fbba93a2591b98225bdb9a40@news.povray.org>
Christopher James Huff wrote:
>In article <web.3fba9d39f0c1c7f425bdb9a40[at]news.povray.org>,
> "Bernard Hatt" <bmh### [at] arkadydemoncouk> wrote:
>
>> I'm trying to put a coloured bozo 'splodge' on an object, where the
>> color_map threshold varies from the center to the edge.
>
>There are several options. You could create a pigment map with the
>spherical pattern...basically what you did with layered textures, but
>far more efficient. However, with the example you gave, it would be
>simpler to just use a function pattern. Something like this:
>
>box { <-2,-2,0> <2,2,1 >
>    texture {
>        pigment {
>            function {
>                select(f_noise3d(x/0.025, y/0.025, z/0.025) > f_r(x, y,
>z), 1, 0)
>            }
>            color_map {
>                [0.5 color Green]
>                [0.5 color Red]
>            }
>        }
>    }
>}
>
>If the noise function (which is just what the bozo pattern is) is less
>than the distance, the pattern has a value of 1, otherwise it is 0. You
>may also get good results with something like:
>
>function {f_noise3d(x/0.025, y/0.025, z/0.025)*max(0, 1 - f_r(x, y, z))}
>
>This is essentially the same as multiplying bozo and the spherical
>pattern. The value of the noise gets scaled down to 0 as the distance
>from the origin approaches 1.
>
>Christopher James Huff <cja### [at] earthlinknet>
>http://home.earthlink.net/~cjameshuff/
>POV-Ray TAG: chr### [at] tagpovrayorg
>http://tag.povray.org/
>

Great, I had a feeling there was a simple solution :-)

Your example with the select() seems to need a value that can be +ve or -ve
to work:
eg.
    function {select( f_noise3d(x/0.025, y/0.025, z/0.025) - f_r(x, y,z), 0,
1)}
but the multiplying bozo and the spherical pattern also produced a nice
result:
    function {f_noise3d(x/0.025, y/0.025, z/0.025)*max(0, 1.5 - f_r(x, y,
z))}

Thanks for your help,

Bernard


Post a reply to this message

From: Christopher James Huff
Subject: Re: Is it possible to have color_map values depend on distance from a point= ?
Date: 19 Nov 2003 22:16:06
Message: <cjameshuff-55CA0B.22111019112003@netplex.aussie.org>
In article <web.3fbba93a2591b98225bdb9a40@news.povray.org>,
 "Bernard Hatt" <bmh### [at] arkadydemoncouk> wrote:

> Your example with the select() seems to need a value that can be +ve or -ve
> to work:
> eg.
> function {select( f_noise3d(x/0.025, y/0.025, z/0.025) - f_r(x, y,z), 0, 1)}

Er, oops...


> but the multiplying bozo and the spherical pattern also produced a nice
> result:
> function {f_noise3d(x/0.025, y/0.025, z/0.025)*max(0, 1.5 - f_r(x, y, z))}

Note that the f_noise3d() function returns a maximum of 1.0, and by 
changing the "max(0, 1 - f_r(x, y, z)" to "max(0, 1.5 - f_r(x, y, z))", 
you increase the maximum of that factor to 1.5...so the function ranges 
from 0 to 1.5, which will be wrapped when used as a pattern. If you want 
to change the radius, you should scale the result of the f_r() function 
instead:

function {f_noise3d(...)*max(0, 1 - f_r(x, y, z)/1.5)}

You may want to play around with different falloff rates as well...think 
about what various n^2 or sqrt(n) do in the range 0..1, or what sin() 
does in the ranges 0..pi/2 and -pi/2..pi/2. Or combine several of 
these...a cos() function for a ripple effect and a quadratic falloff. 
Use atan2() to vary things with angle...

-- 
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: Bernard Hatt
Subject: Re: Is it possible to have color_map values depend on distance from a point=
Date: 20 Nov 2003 13:55:00
Message: <web.3fbd0dccbe538fb825bdb9a40@news.povray.org>
Christopher James Huff wrote:
>Note that the f_noise3d() function returns a maximum of 1.0, and by
>changing the "max(0, 1 - f_r(x, y, z)" to "max(0, 1.5 - f_r(x, y, z))",
>you increase the maximum of that factor to 1.5...so the function ranges
>from 0 to 1.5, which will be wrapped when used as a pattern. If you want
>to change the radius, you should scale the result of the f_r() function
>instead:
>
>function {f_noise3d(...)*max(0, 1 - f_r(x, y, z)/1.5)}

I see what you mean, I had just been trying to increase the 'density'
of the pattern in the middle.

>You may want to play around with different falloff rates as well...think
>about what various n^2 or sqrt(n) do in the range 0..1, or what sin()
>does in the ranges 0..pi/2 and -pi/2..pi/2. Or combine several of
>these...a cos() function for a ripple effect and a quadratic falloff.
>Use atan2() to vary things with angle...

If only I could remember all the maths that I learnt years ago :-) , I
did manage to play around and produce a spirally thing:

function{f_noise3d(x/0.025,y/0.025,z/0.025)
    *(1+cos(7*atan2(x,y)+15*f_r(x,y,0)/2))
    *max(0, 1.0 - f_r(x, y, z)/2.0)}


Thanks,

Bernard


Post a reply to this message

From: Christopher James Huff
Subject: Re: Is it possible to have color_map values depend on distance from a point=
Date: 21 Nov 2003 15:15:06
Message: <cjameshuff-D3E750.15094821112003@netplex.aussie.org>
In article <web.3fbd0dccbe538fb825bdb9a40@news.povray.org>,
 "Bernard Hatt" <bmh### [at] arkadydemoncouk> wrote:

> I see what you mean, I had just been trying to increase the 'density'
> of the pattern in the middle.

Hmm...a better way of doing that would be to just adjust the minimum of 
the range of the noise function until its minimum and maximum are 1. 
Um...

f_noise3d(...)*min(1, f_r(...)) + 1 - min(1, f_r(...))

At r = 0, noise will be multiplied by 0 and the function result will be 
1. At r >= 1, the function will be pure noise. Or flip it around, making 
a porous hole in an otherwise solid function:

f_noise3d(...)*max(0, 1 - f_r(...)) + min(1, f_r(...))

Or simpler, use the adj_range() function in math.inc:
adj_range(f_noise3d(...), min(1, f_r(...)), 1)

This might actually be faster, because of one less evaluation of 
f_r()...it depends on how much overhead the function call takes.
Here's an interesting version I came up with:
function {adj_range(f_crackle(x*5, y*5, z*5), cos(pi*max(0, 1 - f_r(x/5, 
y/5, z/5)))/2 + 0.5, 1)}


> If only I could remember all the maths that I learnt years ago :-) , I
> did manage to play around and produce a spirally thing:

Well, I find the most important thing is to just remember what the 
various functions look like when graphed, and figure out what they "look 
like" when combined.

-- 
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.