POV-Ray : Newsgroups : povray.general : radial colour gradient Server Time
31 Jul 2024 16:28:58 EDT (-0400)
  radial colour gradient (Message 1 to 9 of 9)  
From: Dav shef
Subject: radial colour gradient
Date: 18 Oct 2006 05:25:00
Message: <web.4535f1f1ae8bc416699678ae0@news.povray.org>
Hi All,

I am trying to get a sphere with a radial colour gradient.
For example, a red sphere that gradually becomes white in its center.
Is there a way to do that ?

Cheers

Dav


Post a reply to this message

From: Penelope20k
Subject: Re: radial colour gradient
Date: 18 Oct 2006 05:59:28
Message: <4535fb00@news.povray.org>
sphere {center,radius_sphere

pigment {rgbt a // exterior colour with transparency set to 1
}
interior {ior 1 fade_color B fade_power 1 fade_distance radius_sphere}

}

should works with appropriate value





news:web.4535f1f1ae8bc416699678ae0@news.povray.org...
> Hi All,
>
> I am trying to get a sphere with a radial colour gradient.
> For example, a red sphere that gradually becomes white in its center.
> Is there a way to do that ?
>
> Cheers
>
> Dav
>
>


Post a reply to this message

From: Chris B
Subject: Re: radial colour gradient
Date: 18 Oct 2006 17:53:34
Message: <4536a25e$1@news.povray.org>
"Dav_shef" <nomail@nomail> wrote in message 
news:web.4535f1f1ae8bc416699678ae0@news.povray.org...
> Hi All,
>
> I am trying to get a sphere with a radial colour gradient.
> For example, a red sphere that gradually becomes white in its center.
> Is there a way to do that ?
>
> Cheers
>
> Dav
>

Hi Dav,

Here's something that does what I think may be what you're asking for:
I've done a difference so you can see the white center.

light_source { <10, 20,-30> color rgb<1, 1, 1>}
camera {location <1, 1, -3> look_at <0,0, 0>}

difference {
  sphere {0,1}
  box {0,<1,1,-1>}
  pigment {onion
    color_map {
      [0 color rgb <1,1,1>]
      [1 color rgb <1,0,0>]
    }
  scale 1.001}
}

Regards,
Chris B.


Post a reply to this message

From: Alain
Subject: Re: radial colour gradient
Date: 18 Oct 2006 20:30:29
Message: <4536c725$1@news.povray.org>
Dav_shef nous apporta ses lumieres en ce 18/10/2006 05:20:
> Hi All,

> I am trying to get a sphere with a radial colour gradient.
> For example, a red sphere that gradually becomes white in its center.
> Is there a way to do that ?

> Cheers

> Dav


You can use the spherical pattern. It goes from a value of 1 at the origin and 
drop to zero at a radius of 1 then stay there.
Use it with  color_map{[0 Red][1 White]} and scale that to your spgere radius.
The onion proposed by Chris B is similar but repeats itself each unit radius.
If your sphere is transparent, you can use the same pattern, but use it to 
madulate the density of a media filling the sphere. Don't forget to add hollow 
to your sphere so that it can actualy contain the media.

-- 
Alain
-------------------------------------------------

Did you know that Al Capone's business card said he was a used furniture dealer.


Post a reply to this message

From: Dav shef
Subject: Re: radial colour gradient
Date: 19 Oct 2006 05:05:00
Message: <web.45373ea1fd7ce4e699678ae0@news.povray.org>
"Penelope20k" <pen### [at] caramailfr> wrote:
> sphere {center,radius_sphere
>
> pigment {rgbt a // exterior colour with transparency set to 1
> }
> interior {ior 1 fade_color B fade_power 1 fade_distance radius_sphere}
>
> }
>
> should works with appropriate value
>


I've tried this :

sphere {<0,0,0>,1.0
pigment {rgbt <1,0,0,1> // exterior colour with transparency set to 1
}
interior {ior 1 fade_color <1,0,0> fade_power 5 fade_distance 1.8}
}


it works, but it givese exactly the opposite of what I wanted: Red inside
faing to white on the outside. What I am trying to get is a red sphere with
white inside.


Post a reply to this message

From: Dav shef
Subject: Re: radial colour gradient
Date: 19 Oct 2006 05:05:01
Message: <web.45373f02fd7ce4e699678ae0@news.povray.org>
"Chris B" <c_b### [at] btconnectcomnospam> wrote:
> "Dav_shef" <nomail@nomail> wrote in message
> news:web.4535f1f1ae8bc416699678ae0@news.povray.org...
> > Hi All,
> >
> > I am trying to get a sphere with a radial colour gradient.
> > For example, a red sphere that gradually becomes white in its center.
> > Is there a way to do that ?
> >
> > Cheers
> >
> > Dav
> >
>
> Hi Dav,
>
> Here's something that does what I think may be what you're asking for:
> I've done a difference so you can see the white center.
>
> light_source { <10, 20,-30> color rgb<1, 1, 1>}
> camera {location <1, 1, -3> look_at <0,0, 0>}
>
> difference {
>   sphere {0,1}
>   box {0,<1,1,-1>}
>   pigment {onion
>     color_map {
>       [0 color rgb <1,1,1>]
>       [1 color rgb <1,0,0>]
>     }
>   scale 1.001}
> }
>
> Regards,
> Chris B.


Thanks Chris, but that's not really what I was looking for.
but your code is quite cool, might use it for later on

cheers

Dav


Post a reply to this message

From: Dav shef
Subject: Re: radial colour gradient
Date: 19 Oct 2006 05:10:01
Message: <web.453740b2fd7ce4e699678ae0@news.povray.org>
Alain <ele### [at] netscapenet> wrote:
> Dav_shef nous apporta ses lumieres en ce 18/10/2006 05:20:
> > Hi All,
>
> > I am trying to get a sphere with a radial colour gradient.
> > For example, a red sphere that gradually becomes white in its center.
> > Is there a way to do that ?
>
> > Cheers
>
> > Dav
>
>
> You can use the spherical pattern. It goes from a value of 1 at the origin and
> drop to zero at a radius of 1 then stay there.
> Use it with  color_map{[0 Red][1 White]} and scale that to your spgere radius.
> The onion proposed by Chris B is similar but repeats itself each unit radius.
> If your sphere is transparent, you can use the same pattern, but use it to
> madulate the density of a media filling the sphere. Don't forget to add hollow
> to your sphere so that it can actualy contain the media.
>

Yeah, but do I exactly use this spherical pattern ? can you give me a short
example ?

Cheers

Dav


Post a reply to this message

From: Alain
Subject: Re: radial colour gradient
Date: 22 Oct 2006 16:16:21
Message: <453bd195$1@news.povray.org>
Dav_shef nous apporta ses lumieres en ce 19/10/2006 05:09:
> Alain <ele### [at] netscapenet> wrote:
>> Dav_shef nous apporta ses lumieres en ce 18/10/2006 05:20:
>>> Hi All,
>>> I am trying to get a sphere with a radial colour gradient.
>>> For example, a red sphere that gradually becomes white in its center.
>>> Is there a way to do that ?
>>> Cheers
>>> Dav

>> You can use the spherical pattern. It goes from a value of 1 at the origin and
>> drop to zero at a radius of 1 then stay there.
>> Use it with  color_map{[0 Red][1 White]} and scale that to your spgere radius.
>> The onion proposed by Chris B is similar but repeats itself each unit radius.
>> If your sphere is transparent, you can use the same pattern, but use it to
>> madulate the density of a media filling the sphere. Don't forget to add hollow
>> to your sphere so that it can actualy contain the media.


> Yeah, but do I exactly use this spherical pattern ? can you give me a short
> example ?

> Cheers

> Dav

As a pigment: pigment{spherical color_map{[0 rgb<1,0,0>][1 rgb 1]}scale Some_Scale}
It won't be visible unless you cut out part of the object with a difference or 
intersection.
As a media density:
interior{media{emission 1 density{spherical color_map{[0 Red][1 White]}scale 
Some_Scale}}}
Sample using emissive media, but you can also use absorbing or scattering media.
The pattern is centered around the origin or <0,0,0>.

-- 
Alain
-------------------------------------------------

about it.


Post a reply to this message

From: Nicolas
Subject: Re: radial colour gradient
Date: 14 May 2013 15:10:00
Message: <web.51928905fd7ce4edd09a49f0@news.povray.org>
Hey, I have a similar question. I have a shape that is a lateral extrusion of a
hemisphere, and I want to color it in with a radial gradient. I'd like to make
it look like a colorful foggy media is inside, instead of the solid colors that
I'm using right now, but can't get it to look quite right. If you look at my
code, I'm referring to the "resonant slice." I've been trying to get it right
literally for days! (Its a figure for a paper I'm writing). Any help would be
much appreciated.




#include "colors.inc"
#include "textures.inc"
#include "glass.inc"
#include "golds.inc"
#include "transforms.inc"
#include "shapes.inc"
#include  "finish.inc"

//---------------------------------------------

// Photons //

global_settings {
max_trace_level 10
}

//------------------------------------------

light_source {
   <0,2,-30>
   //<100,8,-15>
   color 1.6*White
   spotlight
    radius 50
    falloff 20
    tightness 1
    point_at <0,2,0>
  //  shadowless

   media_interaction off
   media_attenuation off
   photons { reflection off refraction off }
}


light_source {
   <20,3,0>
   color 1*White
   spotlight
    radius 50
    falloff 20
    tightness 1
    point_at <0,3,0>
    shadowless
   media_interaction off
   media_attenuation off
   photons { reflection off refraction off }
}


camera {

   location<1,1,-2.2>
   look_at <0,0,0>

}

//--------------------------------

background { rgb < 0, 0, 0 > }


//--------------------------------------------------
// Coil//

#declare coil_y=-2;
#declare n=3.5;
#declare R=5;
#declare dL=(2/3)*R;
#declare r=R/10;

#declare begin=1;
#declare x1=(0.25-n/2)*dL;
#while(x1<=(n/2-0.25)*dL)
 #declare theta=2*pi*(x1/dL+n/2);
 #declare p2=<x1,R*sin(theta),-R*cos(theta)>;
 sphere{p2,r texture{Chrome_Metal} rotate <0,90,180> translate <-1,coil_y,11.5>
photons { collect off }}
 #declare begin=0;
 #declare p1=p2;
 #declare x1=x1+0.005*dL;
#end

//--------------------------------------------------
//Resonant Slice


#declare NumberOfSteps=10;
#declare StepNumber=0;
#declare r=1;
#declare oscillationamplitude=0.5;
#declare separation=oscillationamplitude/NumberOfSteps;

#while(StepNumber<NumberOfSteps)
  #declare xcoordinate= StepNumber*separation;

   difference{isosurface{function { sqrt(pow(x-xcoordinate,2) + pow(y,2) +
pow(z,2)) - r} contained_by { box { <-20,-20,-20>,<20, .001,20> }}
                         texture{pigment{color red
abs(sin(pi*StepNumber/NumberOfSteps)) green 0 blue
abs(cos(pi*StepNumber/NumberOfSteps))}
                                 normal { bumps 0.01 scale 0.1 }
                                 finish { phong 1 } }}
                         sphere{<xcoordinate,0,0>,r-separation
                         }
             }
   sphere{<xcoordinate,0,0>,r-separation clipped_by{plane{y,0}}
           texture{pigment{color red abs(sin(pi*StepNumber/NumberOfSteps)) green
0 blue abs(cos(pi*StepNumber/NumberOfSteps))}
                   normal { bumps 0.1 scale 0.1 }
                   finish { phong 1 } }}

   isosurface{function { sqrt(pow(x-xcoordinate,2) + pow(y,2) + pow(z,2)) -
(r+separation/5)}  clipped_by{plane{y,0}}
                         texture{pigment{color red 0 green 0 blue 1}
                                 normal { bumps 0.01 scale 0.1 }
                                 finish { phong 1 } }}



  #declare StepNumber=StepNumber+1;
#end






//-------------------------------------------------------
 //Substrate //

  box{ <-6, -2, -6>, <7, -0.001, 3>
        material{
   texture{ T_Glass3

   finish {
    ambient .6
    diffuse .5
     reflection {0.1}
        }
     }
     }
   interior { //I_Glass
      ior 1

    }
         photons { collect off }
        }

   light_source{
      <-5,-1,-2>
      color 2*White
      shadowless
      media_interaction off
   media_attenuation off
   photons { reflection off refraction off }
     }


Post a reply to this message

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