1 / 92

POVRAY Tutorial

POVRAY Tutorial. 204481 Foundation of Computer graphics Pradondet Nilagupta. What is POV-Ray?. POVRAY = Persistence of Vision Ray-Tracer POV-Ray is a high-quality, freely available ray-tracing software package that is available for PC, Macintosh and UNIX platforms. POV-Ray is no toy.

ivo
Download Presentation

POVRAY Tutorial

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. POVRAY Tutorial 204481 Foundation of Computer graphics Pradondet Nilagupta

  2. What is POV-Ray? • POVRAY = Persistence of Vision Ray-Tracer • POV-Ray is a high-quality, freely available ray-tracing software package that is available for PC, Macintosh and UNIX platforms. • POV-Ray is no toy. • POV-Ray is what is known as a "rendering engine".

  3. Written POV-Ray language • Describing scenes to POV-Ray is fairly simple • Give POV-Ray a file containing a description of every object in the scene. POV-Ray takes this file and generates a picture, which you can then view.

  4. Object description of POVRAY • What type of object you want (one of POV-Ray's simple objects or one you've created yourself. • Various attributes of the object (its color, how it reflects light, etc).

  5. What is ray-tracing? • Ray-tracing is a method of creating visual art in which a description of an object or scene is mathematically converted into a picture. • ray-tracing is the process of mathematically generating near-photorealistic images from a given description of a scene via geometrical modeling of light rays.

  6. POV-Ray's Coordinate System • The coordinate system that POV-Ray uses, then, is called a three-dimensional (or 3D) Cartesian coordinate system. • The axis we have drawn is not fixed in POV-Ray -- the way the axis looks (in terms of which axes are which) really depends on where you place your camera in POV-Ray.

  7. Vectors in POV-Ray • The term vector refers to any group of numbers describing a certain thing -- there are color vectors and normal vectors. • vectors are surrounded by angle brackets (that's < and >). • For example, to specify the origin in terms that POV-Ray understands, we would say <0,0,0>

  8. How to describe color: RGB and RGBF Vectors • In describing a color, each element of the vector corresponds to the amount of a primary color -- red, green and blue. Such a vector is called a RGB vector (for redgreenblue vector). • In a RGB vector, the numbers should be between 0.0 and 1.0. • For example, the color black, is described by the color vector <0,0,0>. And color white, is specified by the color vector <1,1,1>.

  9. Normal Vectors • normal vectors are used to specify an orientation, not a distance.

  10. Normal Vector (cont.) • POV-Ray is kind enough to automatically define three normal vectors for you • x (corresponding to <1,0,0>), the normal vector for a plane lying along the y and z axes • y (corresponding to <0, 1, 0>), the normal vector for a plane lying along the x and z axes, • z (corresponding to <0, 0, 1>), the normal vector for a plane lying along the x and y axes.

  11. POV-Ray Source Code • There are three things you need to know about POV-Ray source code • POV-Ray source code is case sensitive • POV-Ray ignores whitespace • Ordering is unimportant

  12. Source Code (cont.) camera { location <0, 2.25, -35> direction <0, 0, 10> up <0, 1, 0> right <1, 0, 0> look_at <0, 0, 90> } camera { location <0, 2.25, -35> direction <0, 0, 10> up <0, 1, 0> right <1, 0, 0> look_at <0, 0, 90>}

  13. Comments in POV-Ray Source Code • Comments can be enclosed in /* and */, or, for single-line comments, can be prefixed with a //. • Example • // this is a single-line comment • /* this is • another comment. it can be as long as you want it to be */

  14. Including files • Including files is a feature of many languages that makes re-using code easier • Adding the string #include "filename" to the beginning of your file. • Example • #include "colors.inc"

  15. Creating simple objects • The building blocks of all POV-Ray objects and scenes are called primitives. Primitives are objects that POV-Ray already knows about, and all you have to do is describe a few attributes. POV-Ray primitives are usually simple geometric shapes such as spheres, cubes, and cones.

  16. Describing primitives Object_Name { Object_Parameters Some_Simple_Attribute Some_Other_Simple_Attribute Some_Complex_Attribute { Some_Attribute Some_Other_Attribute }

  17. Example sphere { <0, 0, 0>, 5 pigment { color rgb <1, 0, 0> } }

  18. The Camera • This example defines a camera located at <2,5,-10> and pointing at the origin. camera { location <2,5,-10> look_at <0,0,0> }

  19. Light sources • There are a few different types of light sources in POV-Ray. We will concentrate here on the most simple (and useful): the point light source. A point light source can be thought of as an infinitely small object that emits light. light_source { <0,10,-10> color rgb <1,1,1> }

  20. First POVRAY • // Persistence of Vision RayTracer version 2 Scene description file • // File: Lesson_1.pov • // Description: Chrome Sphere on checkers • // Date: January 5, 2000 • // Author: Pradondet Nilagupta • // • #include "shapes.inc" • #include "colors.inc" • #include "textures.inc" camera { location <0, 2.25, -35> direction <0, 0, 10> up <0, 1, 0> right <1, 0, 0> look_at <0, 0, 90> } //Key Light light_source {<50, 100, -80> color White} //Back Light light_source {<100, 50, 80> color Blue}

  21. First POVRAY • First we'll place our plane into the picture. At the end of your source file, type: object { plane {y, 0} pigment {color rgb <1, 1, 1>} }

  22. First POVRAY • Now let's add the sphere. Type: object { sphere {<0, 1.5, 1> 1.5} pigment {color rgb <1, 1, 1>} }

  23. Camera Again • The camera defines what you exactly you see when you render an image. camera { location<loc> sky<sky vector> up<up vector> right<right vector> direction<direction vector> look_at<target> /* translations, rotations, and scales */ }

  24. Camera Again • When declaring a camera, components that appear should do so in this order. This is because some later components modify previous ones, and putting them in the wrong order may result in your camera not doing exactly what you expect. • Location is pretty self evident; it tells POV-Ray where in space to locate the camera. It takes an <x, y, z> vector of the location.

  25. Camera Again • Sky is used to tell the camera which way is up. Modifying this value can be used to roll the camera around its central axis. • Up, right, and direction are used to modify the field of view and aspect ratio of the image. • Direction and look_at are used to point the camera at a specific point in the scene. Direction is more typically used with up and right to define field of view then to position the camera, though.

  26. Location • The location keyword tells POV-Ray where to position the camera. • This parameter must always be specified. • It takes an <x, y, z> vector which tells the location of the camera.

  27. Up Vector • The up vector is used to define the height of the viewing pyramid • The default value of the up vector is "up <0, 1, 0>". • This, together with the value "right <4/3, 0, 0>" (also default) defines the aspect ratio of the rendered image to be (4/3) / (1) = 4/3.

  28. Right Vector • The right vector controls the width of the view. • The angular width of the viewing pyramid can be found with the following equation. width = 2 * atan(|right| / |direction|)

  29. Direction • The direction vector is primarily used in conjunction with up and right to define the field of view. • Increasing the magnitude of the direction vector "stretches" the viewing pyramid and creates a telephoto sort of effect. • Decreasing the magnitude of the direction vector "compresses" the viewing pyramid and gives the effect of a wide-angle camera.

  30. Direction direction <0, 0, 1> direction <0, 0, 0.5> direction <0, 0, 2> direction <0, 0, 4>

  31. Look At • The look_at parameter controls the orientation of the camera. It is by far the easiest way to get the camera to point at the thing you want it to point at. • One thing to keep in mind when using look_at is that the location and look_at points should never be set so that the camera is looking directly down (parallel to the y-axis).

  32. Sky • The vector tells the camera which way is up. • This is not to be confused with the up vector which defines the aspect ratio. • The default sky vector is <0, 1, 0>. By modifiying this value, you can roll the camera around its central axis. • The sky vector, if specified, must appear before the look_at point is specified.

  33. Sky • The first image below is rendered with "sky <2, 1, 0>", and the second with "sky <0, -1, 0>".

  34. Common Object Types • plane, sphere, torus, box, cylinder, cone, lathe, prism (extruded shape), blob, and text.

  35. The Plane • The plane consists of only two values; which of the 3 major axis it crosses, and it's position on that axis. The plane will be perpendicular to the axis declared object { plane {y, -1.5} //{axis, location} pigment {color rgb <.5,.5,.5>} }

  36. Sphere • The sphere also consists of only two values; the location, and the radius. • The location defines the center of the sphere. object { sphere {<0, .5, 0> 1} //{<location> radius} pigment {color rgb <1,1,1>} //scale <2,1,1> //scale to make an elipse }

  37. Torus • The torus definition consists of two radius statements. The first, or major radius extends from the center of the torus to the mid-line of the rim. The second, or minor radius defines the radius of the cross section of the rim. object { torus {1.75, .5} //{outer radius, rad. of cross section} pigment {color rgb <1,1,1>} translate <0,.5,0> //must use translate to move } //its location.

  38. Box • POV defines boxes as two points. The points form opposite corners of the box such as lower back right and upper front left. object { box {<-1, -1, -1> // first corner position < 1, 1, 1>} // second corner position pigment {color rgb <1,1,1>} }

  39. Cylinder • A cylinder consists of 4 values. The first three, first point, second point, and radius are mandatory. The fourth, open, is optional. object { cylinder {<0,-1,0>, <0,1,0>, 1 //{<1st point>, <2nd point>, radius //open //uncomment to make it a tube } pigment {color rgb <1,1,1>} }

  40. Cone • A cone is very similar to a cylinder; the difference being that you can define the radius of both ends. The first point defines one end of the cone. The first radius defines the radius of the cone at this point. The second point and its radius define the center of the other end of the cone object{ cone {<0,-1,0>, 1.0, //{<1st point>, 1st radius <0,1,0>, 0.0 //{<2nd point>, 2nd radius //open //uncomment to make it open ended } pigment {color rgb <1,1,1>} }

  41. Color and Texture object { sphere {<0, 1.5, 1> 1.5} pigment {color rgb <1, 1, 1>} } object { sphere {<0, 1.5, 1> 1.5} texture {PinkAlabaster} }

  42. Pigment object { plane {y, 0} pigment {checker color rgb <0,0,1> color rgb <0,1,0>} scale 2 } • The pigment is defined as checker, and is given two colors. You could also use textures instead of colors to make, say, a black marble and white marble tile floor. • The statement scale 2 scales the size of the squares.

  43. Finish • the term "finish" refers to the quality of the surface (shiny, dull, reflective, etc.). There are some pre-defined finishes in the colors.inc file. object { sphere {<0, 1.5, 1> 1.5} pigment {color rgb <1, 1, 1>} finish { ambient .2 } } ambient has to do witht he amount of light on the "shaddow" side of the object. Is it completely dark (black) or slightly lit? .2 is pretty dark, but not black.

  44. Diffuse and Specular • diffuse refers to the way the light changes from sark to light. A high number means the light changes from light to shaddow very gradually; conversely, a low number (like 0.1) would have a very abrupt change from light to shaddow. • specular is the small round highlight on the surface. A small number will create a tiny "dot" of "pure" light; a large number will create a larger highlight.

  45. Diffuse and Specular object { sphere {<0, 1.5, 1> 1.5} pigment {color rgb <1, 1, 1>} finish { ambient .2 diffuse .5 } } object { sphere {<0, 1.5, 1> 1.5} pigment {color rgb <1, 1, 1>} finish { ambient .2 diffuse .5 } specular .25 }

  46. Reflection object { sphere {<0, 1.5, 1> 1.5} pigment {color rgb <1, 1, 1>} finish { ambient .2 diffuse .5 } specular .25 reflection 1 } reflection is just that: reflection. 1 means the objects is 100% reflective (liek a mirror); 0 means there is no reflection.

  47. Transparency object { sphere {<0, 1.5, 1> 1.5} pigment {color rgbf <1,1,1,.75>} finish { ambient .1 diffuse .5 specular .5 } }

  48. Finish Reference finish { ambientambient lighting brilliancebrilliance crandcrand amount diffusediffuse lighting iorindex of refraction metallic phongphong highlighting phong_sizephong size reflectionreflected light refractionrefract toggle roughnessroughness specularspecular highlighting }

  49. Finish • The sum of the values of ambient, diffuse, and reflection should be about 1.0. Much higher, and your colors will saturate and look flat. Much lower, and your colors will appear dark. • Objects with reflection and refraction (actually, any object with a nonzero filter) will increase your rendering time. Reflection requires an extra ray to be traced to determine the reflected color, while with transparent objects, an extra ray must be traced to determine the color that is being filtered.

  50. Finish • You usually don't need both phong and specular highlights. • The argument to refraction should be 1 or 0 only.

More Related