Sample code for raytracer with notes:
#include "colors.inc" gives
access to a separate file composed entirely of colors, a shortcut which lets
me avoid writing the numbers representing red, green, and blue inputs to each
hue
camera { location <0, 12, -1>
look_at 0 }
light_source { <-1, 12, 3>
color White
area_light <5, 0, 0> <0, 0, 5>, 5,5
adaptive 1 jitter } helps during rendering, smoothing
and refining
Scene has been set with camera and lights. Now come the objects. Each shape is defined, then its color and finish, then modifications to its position and size:
plane { y, 0
pigment { rgb <0.95, 0.95, 0.95> } rgb = red, green, blue
values
normal { dents 1 scale .01 } }
union { cylinder { <-7, 1, 0>, <7, 1, 0>, .15
pigment { rgb <0.94, 0.93, 0.83> }
finish { ambient .25 diffuse .65 brilliance 6 reflection .45 phong 1 phong_size
100 metallic } phong = plastic finish
rotate -90*y
translate -2.75*x move position of object along xyz axes
scale <.85, 1, .65> }
cylinder { <-7, 1, 0>, <7, 1, 0>, .15
pigment { rgb <0.94, 0.93, 0.83> }
finish { ambient .25 diffuse .65 brilliance 6 reflection .45 phong 1 phong_size
100 metallic }
rotate -90*y
translate -2.5*x
scale <.65, 1, .38> }
cylinder { <-7, 1, 0>, <7, 1, 0>, .15
pigment { rgb <0.94, 0.93, 0.83> }
finish { ambient .25 diffuse .65 brilliance 6 reflection .45 phong 1 phong_size
100 metallic }
translate <.35, 0, -.7>
scale <.95, 1, 1> }
cylinder { <-7, 1, 0>, <7, 1, 0>, .15
pigment { rgb <0.94, 0.93, 0.83> }
finish { ambient .25 diffuse .65 brilliance 6 reflection .45 phong 1 phong_size
100 metallic }
translate -1.05*z }
superellipsoid { < .8, .8>
pigment { rgbf <0.578824, 0.439216, 0.856471, 0.8> }
finish { ambient 0.1 diffuse 0.1 reflection .25 specular 1 roughness .001 }
interior { ior 1.5 fade_distance 5 fade_power 1 caustics 2 } interior
settings give the appearance of transparency, such as glass, water, diamond.
translate <-2, 1, 2>
scale .75*z }
translate -2.25*x }
This code can be written in any text editor, like Notepad, Textpad, etc, or with the editor that accompanies the raytracing engine.