How to make pictures using raytracing with povray (part 1) ----------------------------------------------------------------------------- Raytracing is a general technology to create a picture from a three-dimensional scene. This technology is implemented in a number of programs, we will use povray because of its wide availability. ----------------------------------------------------------------------------- The scene is presented in the scene description language, that files is then read by povray, which then renderrs the scene and produces the picture. The default format of the picture is png. Describing a scene is different from programming: no action takes place, we just describe what is currently there. ------------------------------------------------------------------------------ The coordinate system is: x coordinate to the right, y coordinate up, z coordinate to the back. Coordinates are enclosed in < >, so point <2,1,-3> is 2 units to the right, 1 unit high, and 3 units to the front. ------------------------------------------------------------------------------ We first give the background color, which is started by the key word background then a block enclosed in braces, stating the color, in the rgb model. Other color models are available, if we include the file "colors.inc", there are predefined colors Red, Blue, Pink, etc. background {color rgb <0, 0.3, 0.1> } sets the background to a dark green ------------------------------------------------------------------------------ Then we place our viewpoint, and the direction we are looking. This is done by the keyword camera, followed by a block in braces which contains the position of the camera, and the point it looks at. camera { location <0, 0, -3> look_at <0, 0, 2> } places a camera 3 units towards us, in the middle, and looks at the point 2 units further to the back from the center, als in the middle. ------------------------------------------------------------------------------ Then we place an object. The simplest object is a ball or sphere. sphere { <0, 1, 2>, 1 texture{ pigment {color rgb <1, 0.8, 0> } } } declares a sphere centered at point <0,1,2>, of radius 1, whose surface is just uniformly opaque colored with color rgb <1, 0.8, 0>, which is yellow with slight red. Other surface textures are available later. ------------------------------------------------------------------------------ And we need some light in the scene, otherwise it stays dark: light_source { <5, 0, 0> color rgb <1,1,1> } places a light source to the right, at position <5,0,0>, whose color is rgb <1,1,1>, which is white ---------------------------Example pov1---------------------------------------- background {color rgb <0, 0.3, 0.1> } // dark green camera { location <0, 0, -3> look_at <0, 0, 2> } sphere { <0, 1, 2>, 1 texture{ pigment {color rgb <1, 0.8, 0> } } // yellow-orange } sphere { <0, -1, 2>, 1 texture{ pigment {color rgb <0.8, 1, 0> } } // yellow-green } light_source { <5, 0, 0> color rgb <1,1,1> } // white light on the right ------------------------------------------------------------------------------ Another simple object type is the cylinder: cylinder { <-1,0,0> <1,0,0> 0.4 open texture{ pigment{ color rgb <1,1,1> }}} makes a cylinder left to right, whose axis starts at <-1,0,0> and goes to <1,0,0> and has radius 0.4. It is an open sylinder, no caps, and colored white.