POV-Ray : Newsgroups : povray.general : radial colour gradient : Re: radial colour gradient Server Time
31 Jul 2024 18:28:53 EDT (-0400)
  Re: radial colour gradient  
From: Nicolas
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.