Memo by Michikazu Kobayashi
povray

PovRay memo

  • Sphere

                    sphere{
                      <x,y,z>, // center
                      r // radius
                      pigment{}
                      finish{}
                    }
  • Cylinder

                    cylinder{
                      <x,y,z>, // bottom coordinate
                      <x,y,z>, // top coordinate
                      r // radius
                      open // Adding this removes both end faces
                      pigment{}
                      finish{}
                    }
  • Cone (used to make the tip of an arrow)

                    cone{
                      <x,y,z>, // bottom coordinate
                      r // bottom radius
                      <x,y,z>, // top coordinate
                      r // top radius
                      open // Adding this removes both end faces
                      pigment{}
                      finish{}
                    }
  • Line segment (used to connect multiple spheres)

                    object{
                      sphere_sweep{
                        linear_spline, // How to connect spheres. There are also cubic_spline and b_spline
                        n, // number of spheres
                        <x,y,z>, // sphere 1 coordinate
                        r // sphere 1 radius
                        <x,y,z>, // sphere 2 coordinate
                        r // sphere 2 radius
                        ...
                        pigment{}
                      }
                      finish{}
                    }
  • Isosurface

                  object{
                    isosurface{
                      function{f(X,Y,Z)} // f(X,Y,Z)=0 is plotted
                      contained_by{box{<x1,y1,z1>,<x2,y2,z2>}}, // plotting region
                      open // Adding this makes open surface
                      accuracy // accuracy
                      max_gradient // maximum slope
                      pigment{}
                    }
                    finish{}
                  }
  • Surfaces with mediating variables

                  object{
                    parametric{
                      function{x(u,v)},
                      function{y(u,v)},
                      function{z(u,v)},
                      <u1,v1>,<u2,v2>
                      contained_by{box{<x1,y1,z1>,<x2,y2,z2>}}, // plotting region
                      accuracy // accuracy
                      max_gradient // maximum slope
                      pigment{}
                    }
                    finish{}
                  }
  • Color handling

    • color rgbf <red,green,blue,filter (lets through colors close to the original color, but not away from it) >
    • color rgbt <red,green,blue,transparency (let all colors through) >
    • color rgbft <red,green,blue,filter,transparency>
  • Finish handling

    • ambient n([0:1]) : brightness or color (rgb <r,g,b>) can be specified for each texture
    • diffuse n([0:1]) : diffuse reflectance
    • brilliance n([0:1]) : gloss
    • crand n([0:1]) : roughness
    • phong n([0:1]) : intensity of bright areas (highlights) where the light source is reflected by specular reflection
    • phong_size n([1:250]) : highlight size
    • specular n([0:1]) : specular highlight intensity
    • roughness n([0.0005:1]) : specular highlight size
    • metallic n([0:1]) : intensity of metallic surface highlights
    • There are also reflection, refraction, irid (iridescence), but I have never used them
  • Commonly used color mappings

                    pigment{
                      function{f(X,Y,Z)} // 0 < f < 1
                      color_map{[0 color Blue] [0.33 color Green] [0.66 color Yellow] [1 color Red]}
                    }
  • make background image transparent and png output

                    background{rgbt<0,0,0,1>}
    and add +FN and +UA at output. For example
                    povray hoge.pov +FN +UA
  • Specify size of output image

    For example, for a 500x400 image
                    povray hoge.pov +H500 +W400
  • Example of repetitive syntax

                  #declare Q=0;
                  #declare dQ=0.01;
                  #while (Q<100)
                    #declare P=Q*dQ;
                    something with P
                    #declare Q=Q+1;
                  #end
  • Shadows bother me

    In Povray, depending on the position of the light source and object, the shadow of one object may be cast on another object. If this is a concern, you can prevent the shadow from being cast by giving no_shadow to the object that casts the shadow.
  • Aligning camera aspect ratio

                  location <camera position>
                  look_at <look at position>
                  right <0,1,0>
                  up <0,0,1>