#version 3.7;

global_settings {
  adc_bailout 0.0039216
  assumed_gamma 1.5
  max_trace_level 8
  noise_generator 1
  
  photons {
    count 60000
    gather 10, 100
    media 60000, 1e-06
    autostop 1
  }
  ambient_light rgb<2, 2, 2>
}

#macro lightdef(pos,rad,col)
light_source {
  pos
  color rgb col
  area_light <5, 0, 0>, <0, 0, 5>, 5, 5
  //spotlight
  adaptive 1
  photons {
    refraction on
    reflection on
  }
}
sphere {
  pos * 2,rad
  texture {
    pigment {
      color rgb 1
    }
    finish {
      ambient 2
      //diffuse 0
      //ambient .3
      //diffuse 1
    }
  }
}
#end

lightdef(<20, 40, 80>,20,12)
//lightdef(<-2000, 4000, 8000>,200,<6,6,6>)
//lightdef(<0, 400, -400>,20,<2,2,2>)
//lightdef(<400, 400, -200>,20,<2,2,0>)


plane {
  <0, 1, 0>, 0
  
  /*finish {
  reflection {
  rgb <0.2, 0.2, 0.2>
  }
   }*/
  
  pigment {
    checker
    color rgb .1
    color rgb .17
  }
  scale 1
  rotate <0, 0, 0>
  translate <0, 0, 0>
}

#macro glassball(pos,col)
sphere {
  pos,1//<0, 1, 0>, 1
  texture {
    pigment {
      color rgb col//<1,.1,.1>
      //transmit .9
      filter 1
    }
    finish {
      reflection {
        rgb <.1,.1,.1>
      }
      ambient 0
      diffuse 0
      //ambient .3
      //diffuse 1
    }
  }
  interior { ior 1.5 }
  photons {
    target
    collect off
  }
}
#end

// see Jupyter notebook "spheres_graphics_alignment_center"

#declare az = 1.1547005383792515; // positive Z coordinate
#declare bz = 0.577350269189626; // negative Z coordinate
#declare cz = 2.63299316185545; // top ball Y coordinate

glassball(<-3,1,2>,<1,.1,.1>) // red
glassball(<-1,1,2>,<.1,1,.1>) // green
glassball(<1,1,2>,<.1,.1,1>) // blue
glassball(<3,1,2>,<1,0,1>) // purple

//glassball(<0,1,0>,<1,1,1>) // test

camera {
  perspective
  location <20, 30, -40>
  sky <0, 1, 0>
  direction <0, 0, 1>
  right <1.333, 0, 0>
  up <0, 1, 0>
  look_at <0, 0, 0>
  angle 12
  rotate <0, 0, 0>
}