POV-Ray : Newsgroups : povray.general : Help filling in radial gradient colors : Help filling in radial gradient colors Server Time
29 Jul 2024 02:35:18 EDT (-0400)
  Help filling in radial gradient colors  
From: Nicolas
Date: 14 May 2013 15:25:00
Message: <web.51928ef4b3d76fcadd09a49f0@news.povray.org>
I have a shape that is a sideways extrusion of a hemisphere, and I want to fill
it in such that it goes blue-red-blue radially outward, looking like colorful
fog (media) is filling the shape. I've tried using the spherical density/color
map, but the colors overlap each other so that the blue-red-blue just ends up
looking like purple. I've resorted to using just solid colors, but am not happy
with the result. In my code I'm referring to the "sensitive slice." If you could
help me make this shape I'd much appreciate it, it's for a paper on magnetic
resonance force microscopy.

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