POV-Ray tutorial
Upcoming SlideShare
Loading in...5
×
 

Like this? Share it with your network

Share

POV-Ray tutorial

on

  • 1,323 views

 

Statistics

Views

Total Views
1,323
Views on SlideShare
1,323
Embed Views
0

Actions

Likes
0
Downloads
7
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

POV-Ray tutorial 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 r ed g reen b lue 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 &quot; filename &quot; to the beginning of your file.
    • Example
    • #include &quot;colors.inc&quot;
  • 15. Creating simple objects
    • The building blocks of all POV-Ray objects and scenes are called primitive s. 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 &quot;shapes.inc&quot;
    • #include &quot;colors.inc&quot;
    • #include &quot;textures.inc&quot;
    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 &quot;up <0, 1, 0>&quot;.
    • This, together with the value &quot;right <4/3, 0, 0>&quot; (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 &quot; stretches &quot; the viewing pyramid and creates a telephoto sort of effect.
    • Decreasing the magnitude of the direction vector &quot; compresses &quot; the viewing pyramid and gives the effect of a wide-angle camera.
  • 30. Direction direction <0, 0, 0.5> direction <0, 0, 1> 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 &quot;sky <2, 1, 0>&quot;, and the second with &quot;sky <0, -1, 0>&quot;.
  • 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 &quot;finish&quot; 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 &quot;shaddow&quot; 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 &quot;dot&quot; of &quot;pure&quot; 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: re fle ction. 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 {
    • ambient ambient lighting
    • brilliance brilliance
    • crand crand amount
    • diffuse diffuse lighting
    • ior index of refraction
    • metallic
    • phong phong highlighting
    • phong_size phong size
    • reflection reflected light
    • refraction refract toggle
    • roughness roughness
    • specular specular 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.
  • 51. Ambient
    • Them ambient finish controls how much of the color of a surface comes from ambient lighting.
    • Its parameter is a float value in the range 0.0 to 1.0 (typically).
    • The default value is 0.1
    • Low values mean that objects which are not directly lit will retain some of their color.
    • Higher values can make an object appear to glow
  • 52. Brilliance
    • Brilliance modifies the behavior of diffuse lighting.
    • Brilliance takes a float parameter which modifies how diffuse light bounces off an object. The default value is 1.0.
    • The flatter this angle is, the less the surface is illuminated. Higher brilliance values make the light illuminate less at flat angles
    • The first image was rendered with the default, the second with brillance 5, and the third with brilliance 0.2.
  • 53. Crand
    • Crand can be used to simulate very rough surfaces like concrete and sand which have grainy surfaces.
    • Crand takes a float parameter from 0.0 to 1.0. The default is 0.0
    • You should not use crand in animations.
    • the first image is again the default, while the second has crand 0.1 thrown in
  • 54. Diffuse
    • Diffuse light is basically light that comes from a light source and diffuses in all directions.
    • The value can range from 0.0 (no light from light sources) to 1.0 (very well lit). The default value is 0.6.
    • The first is the default, the second has diffuse 0.3, and the third has diffuse 0.9.
  • 55. Ior
    • This value controls the index of refraction for transparent objects which refract.
  • 56. Metallic
    • The metallic keyword is a modifier for the phong and specular highlights.
    • Metallic takes no parameter; either it's there or it's not.
    • The first was rendered with phong highlighting without metallic, and the second is with metallic
  • 57. Phong
    • The phong keyword creates a highlight on an object that is the color of the light source .
    • Phong takes a float parameter which expresses how bright the highlight should be.
    • The size of the highlight can be controlled with the phong_size parameter.
    • First image: no highlights, second image: phong 0.9
  • 58. Phong Size
    • The phong_size parameter is a modifier for the phong finish. It takes a float parameter (greater than zero) which defines how large the phong highlight will be. Typical values range from 1 (pretty dull) to 250 (very shiny).
    • The default is 40.
    • The images were rendered with &quot;phong_size 40&quot; (default), &quot;phong_size 4&quot;, and &quot;phong_size 180&quot;, respectively.
  • 59. Reflection
    • The reflection finish gives an object a mirrored or partially mirrored surface. This object will then reflect other objects in the scene.
    • A value of 0 turns off reflection for the object, a value of 1 gives the object a perfectly mirrored surface (almost).
    • The first scene has no reflection, the second has reflection 0.3.
  • 60. Refraction
    • Refraction only has meaning on objects that have at least a little bit of transparency. Refraction is the bending of light rays as they pass into a more dense or less dense medium
    • You can change the ior of a refracting object with the &quot;ior&quot; keyword. Some examples of indices of refraction are &quot;ior 1.000292&quot; (air) &quot;ior 1.33&quot; (water), and &quot;ior 1.5&quot; (glass).
    • The first image has no refraction, the second has &quot;ior 1.5&quot;, and the third has &quot;ior 2.0&quot;.
  • 61. Roughness
    • The roughness parameter controls the size of the highlight produced by the specular keyword. Typical values range from 1.0 (sand paper) to 0.0005 (polished glass). The default roughness is 0.05.
    • High values give very a very soft, very large highlight. Small values give a very small, tight highlight. 0 is a very bad number for roughness.
    • All use &quot;specular 0.9&quot;. The first uses the default roughness, the second uses &quot;roughness 0.75&quot;, the third &quot;roughness 0.001&quot;.
  • 62. Specular
    • The specular finish is similar to phong , but this one is more accurate as far as physical laws are concerned. It produces a highlight on the object where the reflection of the light source would be if the object were reflective
    • The size of the highlight can be controlled (to some extent) with the roughness parameter. Here's what specular (0.9) looks like.
  • 63. Normal Reference
    • Here's the general syntax for a bump map.
    • normal {
    • bump_map {
    • type &quot; filename &quot;
    • [bump_size size ]
    • [interpolate mode ]
    • [use_color]
    • [use_index]
    • [once]
    • [map_type map mode ]
    • }
    • }
  • 64. Normal
    • The normal component of a texture allows you to create effects on the surface of an object
    • Normals have three parts, the type, the modifiers, and then transformations.
    • A normal can only have one type, and that is one of bumps , dents , ripples , waves , or wrinkles . They each take a depth parameter between 0.0 (Flat) and 1.0 (Violent).
  • 65. Normal
    • here's a standard ripples normal and another with &quot;turbulence 0.7&quot;. Note the ripples have been translated to put their center on the top of the sphere.
  • 66. Bumps
    • The bumps normal creates a random bumpy pattern on the object.
    • The bumps normal takes a float parameter from 0.0 (Flat) to 1.0 (Mountainous) that describes the depth of the bumps.
  • 67. Dents
    • The surface appears to have dents (naturally enough) beaten into it. Dents takes a float parameter from 0.0 (Brand New) to 1.0
  • 68. Ripples
    • The ripples normal creates evenly space, smooth ripples which originate from 10 random locations inside the box with corners <0, 0, 0>, <1, 1, 1>. All the waves have the same frequency, so the ripple effect is smooth at a significant distance from the center.
  • 69. Waves
    • Waves are similar to ripples , except instead of creating smooth, even ripples, it creates more rough and tumble waves. Theoretically these look more like deep ocean waves. The waves normal takes the standard 0.0 (Becalmed) to 1.0 (Tsunami) parameter.
  • 70. Wrinkles
    • This normal specifier basically makes the object look like it had been wadded up and then stretched back out again.
  • 71. Declarations (variables)
    • Variables are a way to store and recall frequently used items. In POV variables (declarations) can store a number, a word, an entire object, or even an ent ire scene.
    • Example
    • #declare sizeOfSphere = 1.5
    • object {
    • sphere {<0, 1.5, 1> sizeOfSphere}
    • pigment {color rgb <1, 1, 1>}
    • }
  • 72. Declarations
    • Example
    • #declare MyPrettyWhite = rgb <1,1,1>
    • object {
    • sphere {<0, 1.5, 1> 1.5}
    • pigment {MyPrettyWhite}
    • }
  • 73. Declarations
    • #declare XPosition = 0
    • #declare ZPosition = 1
    • #declare MyPrettyWhite = rgb <1,1,1>
    • #declare MyRadius = .5
    • object {
    • sphere {< XPosition, .5, ZPosition > MyRadius}
    • pigment {MyPrettyWhite}
    • }
  • 74. Declarations
    • #declare WhiteBall = sphere {
    • < XPosition, MyRadius, ZPosition > MyRadius
    • pigment {MyPrettyWhite}
    • }
    • Now replace the code for each of the objects so that it looks like this:
    • object {WhiteBall}
  • 75. Declarations
    • #declare MyPrettyWhite = rgb <1,1,1>
    • #declare MyRadius = .5
    • #declare XPosition = 0
    • #declare ZPosition = 1
    • #include &quot;shapes.inc&quot;
    • #declare WhiteBall = sphere { < XPosition, MyRadius, ZPosition > MyRadius
    • pigment {MyPrettyWhite} }
    • camera { location <0, 2.25, -35> direction <0, 0, 10> up <0, 1, 0> right <1.25, 0, 0> look_at <0, 0, 90> }
    • //Key Light
    • light_source {<50, 100, -80> color MyPrettyWhite}
    • //Back Light
    • light_source {<100, 50, 80> color rgb <0,0,1>}
    • object { plane {y, 0} pigment {MyPrettyWhite} scale 2 }
    • #declare BallCount = 1
    • #while (BallCount < 21)
    • object {WhiteBall}
    • #declare MyRadius = MyRadius + .1
    • #declare XPosition = XPosition + .1
    • #declare ZPosition = ZPosition + 4
    • #declare WhiteBall = sphere { < XPosition, MyRadius, ZPosition > MyRadius pigment {MyPrettyWhite}}
    • #declare BallCount = BallCount + 1
    • #end
  • 76. Declarations
  • 77. Transformations
    • Transformations, in ray-tracing terms, are attributes that change the position, size or orientation of objects (and of the various attributes of the objects).
    • The most common types of transformations, and the ones that POV-Ray supports, are translations , rotations and scalings .
  • 78. Translation
    • A translation is a transformation that moves an object relative to its current position.
    • A translation of <-1,4,2> results in the cube being moved left one unit, up four, and back two.
  • 79. Rotation
    • A rotation is a transformation that changes the orientation of an object (the way that it's facing).
    • A rotation of <0,0,45> rotates the cube 45 degrees around the z axis,
  • 80. Rotation
    • if we translated the cube first, and then rotated it
    • if we rotated the cube first, and then translated it
  • 81. Scaling
    • Scaling changes the size of the object with respect to its current size.
    • If we scaled the object with the string scale <1,4,1>, we would get a result like this
  • 82. Example
    • torus {
    • 3, 11
    • pigment { color Yellow }
    • scale <1.5,1,1>
    • rotate <-45,0,0>
    • translate <0,2,0>
    • }
    • This code makes a yellow torus, slightly widened around the x axis, rotated -45 degrees around the x axis and with its center at <0,2,0>.
  • 83. Constructive Solid Geometry
    • The five types of CSG are: Union Merge Intersection Difference Inverse
  • 84. Union
    • Union is a way of joining objects together.
    • union{
    • object{greenBox}
    • object{redTorus}
    • rotate <20, -65, 0>
    • }
  • 85. Merge
    • #declare greenBox =
    • box{
    • <-2, 1, -2>, <2, -1, 2>
    • pigment{color rgbf <0, 1, 0, .5>}
    • }
    • #declare redTorus =
    • torus{
    • 1.25, // MAJOR radius (0,0,0 to mid-line of ring
    • 0.5 // MINOR radius (radius of cross section of ring
    • pigment{color rgbf <1, 0, 0, .5>}
    • translate 1*y
    • }
    • merge{
    • object{greenBox}
    • object{redTorus}
    • rotate <20, -65, 0>
    • }
    Render the image and you'll see that the torus now does not extend inside the box.
  • 86. Union and Merge Union Merge
  • 87. Intersection
    • Intersection renders only the areas where the objects in the CSG intersect, or overlap.
    • intersection{
    • object{greenBox}
    • object{redTorus}
    • rotate <20, -65, 0>
    • }
  • 88. Difference
    • POV will render the first object minus any following objects.
    • difference{
    • object{greenBox}
    • object{redTorus}
    • rotate <20, -65, 0>
    • }
  • 89. Troubleshooting
    • CSG has one major flaw that you should be aware of. When surfaces of CSG objects are identical, strange artifacts can appear.
    • difference{
    • object{greenBox}
    • box{
    • <-1, 1, -1>, <1, -1, 1>
    • pigment{color rgb <1, 0, 0>}
    • }
    • rotate <20, -65, 0>
    • }
  • 90. Troubleshooting
    • That is because as rays from the light source(s) reach the two objects, sometimes they hit the red box first, and other times they hit the green box first.
    • The problem is eliminated by ensuring the objects in a CSG have &quot;clearance&quot; from each other. Stretching the y values of the red box beyond those of the green box alleviates the problem.
  • 91. Troubleshooting
    • difference{
    • object{greenBox}
    • box{
    • <-1, 1.5, -1>, <1, -1.5, 1>
    • pigment{color rgb <1, 0, 0>}
    • }
    • rotate <20, -65, 0>
    • }
    • Rendered without the difference to show the overlap or &quot;clearance.&quot;
  • 92. END