Docstoc

povray

Document Sample
povray Powered By Docstoc
					Pierre Equey
Obere Sternengasse 21a
CH-4500 Solothurn
EMail: pierre.equey@gmail.com




                                     POVRAY




               AN INTRODUCTION




              Title: PovRay

              Author: Pierre Equey       Version: beta 4.2

              Format: Doc - Word 2003    Last Saved: 20.12.2011
                                                                                                                PovRay - An Introduction



                                          TABLE OF CONTENT
1\ Povray ........................................................................................................................................... 3
2\ Coordinates ................................................................................................................................... 3
3\ Inclusions ...................................................................................................................................... 3
4\ Declarations .................................................................................................................................. 4
5\ Comments ..................................................................................................................................... 4
6\ Cameras ........................................................................................................................................ 4
7\ Let There Be Light ........................................................................................................................ 5
8\ Objects .......................................................................................................................................... 5
9\ Surfaces......................................................................................................................................... 6
10\ Finishes ....................................................................................................................................... 7
11\ Diffuse & ambient ...................................................................................................................... 7
12\ Brilliance..................................................................................................................................... 8
13\ Phong highlights ......................................................................................................................... 8
14\ Specular Highlights..................................................................................................................... 9
15\ Reflections ................................................................................................................................ 10
16\ Refraction ................................................................................................................................. 11




                                                                    2 / 11
                                                                       PovRay - An Introduction




1\ Povray
These pages were not designed as a comprehensive tutorial for Povray, more of a crash
course. If you want extremely thorough documentation, well read the docs. To begin our
tutorial, we will start with the basics: coordinates, include files, declarations, comments,
cameras, lights, objects, pigments, finishes, textures, and more lights.


2\ Coordinates
Everything in Povray is positioned according to 3d coordinates, and specifically it uses the
right-hand coordinate system. Take your right hand, palm facing inwards.

Stick your thumb up, your index finger out, and point the rest of your fingers right. Your
bent fingers point to the positive x direction, your thumb is pointing to the positive y
direction, and your index finger to the positive z direction.


3\ Inclusions
Povray uses "includes files" to include useful information that is kept in a separate file; for
instance, a list of colours is stored in the file colors.inc.

Some of the most common include files are:


  #include    “colors.inc”
  #include    “shapes.inc”
  #include    “finish.inc”
  #include    “glass.inc”
  #include    “metals.inc”
  #include    “stones.inc”
  #include    “woods.inc”



Of course, you can make your own include files, but we’ll get to that in a minute. colors.inc
contains colour definitions, shapes.inc contains some shapes, finish.inc contains finish
definitions for textures, and so on.

Usually, you will want to include at least colors.inc in your pov files, just because then you
don’t have to declare all your colours.

It’s also easy just to make one file, say "allfiles.inc". Include all of the above files in
"allfiles.inc" and then include “allfiles.inc” in your pov file.




                                            3 / 11
                                                                          PovRay - An Introduction


4\ Declarations
Povray allows you declare just about anything you want with a simple command:


  #declare identifier = item



Identifier is a string up to 40 characters long, and item can be any of the following types:

float, vector, color or string expressions objects (all kinds), texture, pigment, normal, finish
or halo, color_map, pigment_map, slope_map, normal_map, camera, light_source, atmos-
phere, fog, rainbow, sky_sphere, transform.

Colour declarations are nothing more than the following statement:


  #declare lipstick_red = rgb <.804 .133 .133>



With the numbers being the red, green, and blue components, we will discuss further about
the colours.


5\ Comments
Comments are sections of text that Povray completely ignores. The syntax for comments is
as follows:


  // This is a single line comment

  /*
  This is a
  multiple line comment
  */




6\ Cameras
The camera is what records everything. The camera shoots multiple eye rays for every
pixel in the final image. If an eye ray hits an object, it records the colour of whatever is at
that point. If the object is transparent, reflective, refractive or whatever, then additional rays
are shot.

Plus, you can do a lot of things like specifying a focal length, aperture, fisheye lenses, and a
lot of other neat stuffs.




                                              4 / 11
                                                                       PovRay - An Introduction



Your basic camera definitions:


  camera
  {
  location <x, y, z>
  look_at <x, y, z>
  }




7\ Let There Be Light
Lights are cool. If you don’t have lights, you have nothing. So let’s examine your basic
light:


  light_source
  {
  <x, y, z>,
  color <r, g, b>
  }



This is your basic, everyday light that shoots out light rays in every direction. If you don’t
want your light to cast shadows, add the shadowless parameter to the light statement.


8\ Objects
PovRay has some primitive (and many not-so-primitive …) objects, but we won’t go into
details.

Primitive objects are:


  sphere
  {
  <x, y, z>, radius
  }

  box
  {
  <x, y, z> // upper left corner
  <x, y, z> // lower right corner
  }

  cone




                                            5 / 11
                                                                    PovRay - An Introduction


  {
  <x, y, z>, // one end
  apex_radius
  <x, y, z>, // the other end
  base_radius
  open // optional, it removes end caps
  }

  cylinder
  {
  <x, y, z> // one end
  <x, y, z> // the other end
  radius
  open // optional, it removes end caps
  }

  plane
  {
  <x, y, z> // normal vector
  float // displacement along vector
  }



However, if you just enter these, you won’t get anything. Every object needs a colour,
which brings us to surfaces.


9\ Surfaces
Most surfaces use colour, which is defined by the pigment statement. Pigments and finishes
and everything else are done on a per-object basis. You insert the pigment (and finish, and
halo, and normal, and everything else) statement within the object scope.


  object_name
  {
  <x, y, z>,
  object_stuff
  pigment { color rgb <r, g, b> }
  }



For a specific example:


  sphere
  {
  <0, 1.2, 7.5>, 5




                                          6 / 11
                                                                       PovRay - An Introduction


  pigment { color rgb <.45, .9245, 1> }
  }



Each red, green, or blue value is a number between 0 and 1. 0 is the lowest intensity for
that colour, and 1 is the highest. A value of 1 for red, green, and blue and blue will produce
white, while a value of 0 for red, green, and blue, will produce black.

There is a fourth channel, called filter or transparency. This allows a certain percentage of
light to pass through the object. 0, the default value, means completely opaque, while 1 is
completely transparent.


  pigment { color rgbt <r, g, b, t> }




10\ Finishes
Finishes are what give texture to an object, whether it’s highly reflective glass or green
jello.


11\ Diffuse & ambient
The two most basic finish statements are diffuse and ambient. Diffuse defines the
amount of light reflected from light_sources, and is a multiplier for the pigment colour.
Diffuse requires a number between 0 and 1.

A pigment colour of <.0039, .4274, 1> and a diffuse of .5 will give you a net colour
of <.00195, .2137, .5>. This option is most useful if you want to reduce glare on given
object.


  finish { diffuse diffuse }




                 diffuse .5               diffuse 1                diffuse 2

Ambient defines the amount of ambient light reflected by the object. It also means the
amount of light generated by an object in an otherwise completely dark scene. Ambient




                                            7 / 11
                                                                             PovRay - An Introduction

requires a number between 0 and 1. 0 is default, and specifies no ambient light. 1 is full
ambient.


  finish {diffuse 1 ambient ambient}




                   ambient 0                  ambient .5                  ambient 1

Basically, the ambient statement is a multiplier for the colour of unlit portions of your
object. Multiply each of the red, green, and blue components of the colour in your pigment
statement by the ambient value and you have the ambient colour of your object.


12\ Brilliance
Brilliance is, in my opinion, extremely useful. It allows you to specify how an object
diffuses the light hitting it. The illumination of an object is a function of the angle of the
light hitting it. A higher angle of incidence creates more illumination, and a lower angle of
incidence causes less illumination.

Brilliance lets you control how much an angle of incidence illuminates the object. High
values tend to make an object look metallic. Try it. It works really well when used with
lighting effects. 1 is the default value, but brilliance values can be any number.




    brilliance 0               brilliance 1                brilliance 2               brilliance 3



13\ Phong highlights
Two common and finish statements are phong and phong_size. These define the amount of
phong phong highlighting an object has. The phong statement requires a number between 0
and 1, and defines 0 means overall intensity of the highlight. No highlight and is default,
while 1 defines full highlight.

Phong_size defines the area the highlight covers.




                                                8 / 11
                                                                      PovRay - An Introduction

Low values, such as in the 0-200 range specify dull, broad highlight, such as plastic. High
values, such as 300 and greater, specify tight, focused highlights, such as those of a highly
polished surface.


  finish
  {
  diffuse 1
  ambient .1
  phong phong
  phong_size phong_size
  }




                      phong 1 phong_size 50    phong 1 phong_size 350



14\ Specular Highlights
The specular highlight is a related concept, but produces a slightly different effect. The
specular effect is better suited to metal and glass. It makes a brighter spot, and it looks a
little better when it’s brightly focused.

The specular statenent defines the overall brightness, with values ranging from 0 to 1, 1
being full intensity. The roughness statement defines the size of the highlight. Usually
values below .025 are best.


  finish
  {
  diffuse 1
  ambient .1
  specular specular
  roughness roughness
  }




                                           9 / 11
                                                                          PovRay - An Introduction

           specular 1 roughness .001                          specular 1 roughness .02

The metallic statement can be used with either phong or specular highlights. It makes the
highlight take on the color of the surface rather than the color of the light. Other than that, it
has no effect.


15\ Reflections
Reflection is another important feature. It does exactly what you think it does, defines the
amount of reflection in a given surface. Values range from 0 to 1, with 1 being totall
reflectiveness. If you’re trying to create a metallic surface, add the metallic statement.

This makes the highlight the color of the object, not the color of the light source.


  Finish
  {
  diffuse 1
  ambient .1
  specular .9
  roughness .001
  reflection reflection
  }




         reflection .1                     reflection .5                     reflection 1


Most surfaces that are reflective also have a specular component. Try it, you’ll see. Another
neat trick is to specify a colour vector with the reflection statement. This allows a red
object to reflect blue light, or any other colour you want. The syntax is simple:


  finish
  {
  diffuse 1
  ambient .1
  specular 1
  roughness .001
  reflection rgb <r, g, b>
  }




                                             10 / 11
                                                                        PovRay - An Introduction




                                reflection rgb <.88, .407, .1825>




16\ Refraction
When light passes through things like water, or jello, it’s bent, or refracted. How much the
light is bent is called the index of refraction, or ior, and corresponds to the relative density
of the object.

Water and glass both have ior’s of somewhere between 1.2 and 1.4, depending on how
dense you want to make them. Diamond has an ior of about 2.4.

The ior is useless without the refraction satement. A refraction value of 1 will allow light
to be refracted, a refraction value of 0 won’t. Values in-between are not recommended.


  finish { diffuse 1 ambient .1 refraction refraction ior ior }




           ior 1.03                          ior 1.2                         ior 1.4




                                             11 / 11

				
DOCUMENT INFO
Shared By:
Categories:
Tags:
Stats:
views:14
posted:12/20/2011
language:
pages:11