Skip to content

Instantly share code, notes, and snippets.

@Head-on-a-Stick

Head-on-a-Stick/glass.md

Last active Apr 8, 2018
Embed
What would you like to do?
Create the image with `povray -Iglass.pov -Oglass.png +A0.001 +R9 +Q11 +FN16 -geometry 3840x2160`

What a load of balls

glass.pov:

#include "colors.inc"
#include "glass.inc"
#include "finish.inc"

global_settings {
   max_trace_level 256
   photons {
      count 1000000
   }
}

camera {
   right x*image_width/image_height // normalise aspect ratio
   location<2,4,-3>
   look_at<0,1,0>
}

light_source {
   <0,10,0> rgb<1,1,1>
   shadowless
}

light_source {
   <10,0,-10> rgb<1,1,1>
   photons {
      refraction on
      reflection on
   }
}

sphere {
   <0,1,0>,1
   translate <0,0,-(1+(1/(3+(2*sqrt(3)))))> // Descartes theorem (kissing circles)
   texture {
      finish {F_Glass2}
      pigment {transmit 0.75} // "transmit" sets the opacity percentage
   }
   interior {
      ior 1.5 // refractive index of material
   }
   photons {
      target
      reflection on
      refraction on
   }
   rotate <0,-clock*360,0> // rotate around vertical axis (when animated)
}

sphere {
   <0,1,0>,1
   translate <0,0,-(1+(1/(3+(2*sqrt(3)))))>
   rotate <0,120,0>
   texture {
      finish {F_Glass2}
      pigment {transmit 0.75}
   }
   interior {
      ior 1.5
   }
   photons {
      target
      reflection on
      refraction on
   }
   rotate <0,-clock*360,0>
}

sphere {
   <0,1,0>,1
   translate <0,0,-(1+(1/(3+(2*sqrt(3)))))>
   rotate <0,240,0>
   texture {
      finish {F_Glass2}
      pigment {transmit 0.75}
   }
   interior {
      ior 1.5
   }
   photons {
      target
      reflection on
      refraction on
   }
   rotate <0,-clock*360,0>
}
 

plane { <0,1,0>,-1
   texture {
      pigment {checker rgb<1,1,1>, rgb<0,0,0>}
      finish {reflection{0.1}metallic}
   }
}

povray.ini:

Width=3840
Height=2160

Output_File_Type=N16 // PNG, 16 bits per colour (~281 trillion colours, great for image manipulation :-)

Quality=11
Antialias=true
Antialias_Threshold=0.001
Sampling_Method=1
Antialias_Depth=9
Output_Alpha=false

With those two files in the working directory the image can be rendered with povray glass.pov povray.ini (saved as glass.png).

To create a numbered sequence of images add these lines to povray.ini:

Initial_Frame=0
Final_Frame=377
Cyclic_Animation=true
Output_File_Name=img.png

Then use this command to make a movie with ffmpeg:

ffmpeg -framerate 60 -i img%03d.png glass.mp4

This should produce a clip showing one rotation at one radian per second :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.