beyond gnuplot: an introduction to pov-raytim/programs/potalk.pdf · what is pov-ray? the...

25
Beyond Gnuplot: An introduction to POV-Ray Timothy Jones Drexel University May 28, 2008

Upload: vandan

Post on 29-Jul-2018

223 views

Category:

Documents


2 download

TRANSCRIPT

Beyond Gnuplot: An introduction to POV-Ray

Timothy Jones

Drexel University

May 28, 2008

What is raytracing? Step 1: Get a light source.

What is raytracing? Step 2: Get a camera.

What is raytracing? Step 3: Get an object.

What is raytracing? Step 4: Ray trace.

What is POV-Ray?

The “Persistence of Vision Raytracer” a freely availableleading free raytracer.

Ray tracing origins: In the 1980s, David Kirk Buck (realname) hacks around with the ancient Unix raytracer Amiga,eventually deciding to write his own version. He creativelycalls it DKBTrace. Posted on ancient communication devicecalled “bulletin board system”.

Snowballs into POV-Ray.

Street-cred: First raytracer to render an image while in space(rendered by astronaut Mark Shuttleworth on the ISS); usedby Intel to demonstrate new processors, etc.

Get it right.

POV-Ray is “free software”, not “open source”. If you don’t knowthe difference, you probably have a life.

Features

Lots of technical features of interest to graphics designers.Makes great use of classical optics.

Many features consume a lot of processor time, thus I don’tuse them for my simulations, just the basics.

POV-Ray is well documented on-line.

Known knowns and known unknowns

What POV-Ray can do:

Improved photo-realism via ray-tracing(an important part of the evolved human visual system)

Better “feel” for data and easier presentation

Animation for extra dimension

What POV-Ray can’t do:

Plots aren’t typically journal-quality (too 3D)

Sophisticated visualizations (like masking) available in suchprograms as VISIT aren’t pre-programed.

An example from “the internets”

The famous Utah teapot:

POV-Ray uses more sophisticated algorithms than simple photonraytracing, including radiosity and other optical effects, and focalblur and other camera effects.

The finest example: Glasses by artist Gilles Tran

Practical examples: Algebraic Topology figure

Goal: To create a visualization of the concept of contractibility viaspace homotopy to a single point. First we set the lighting,background, and camera position and angle.

camera {location <0.5, 0.8,-5>look_at <0,0,0>

}

light_source {<0, 20, -30> color White}light_source {<0,-10,-500> color White}background {rgb <1,1,1>}

Practical examples: Algebraic Topology figure

Build up the blob “space”. We use spheres and the blob function ofPOV-Ray. The threshold gives us a measure of blobiness.

blob {

threshold .65

sphere { <.5,0.3,0.2>, 0.5, 0.5 pigment {Yellow} }

sphere { <0,0.6,0>,1.3, 1 pigment {Red} }

sphere { <0.5,1,-0.5>,0.8, 0.5 pigment {Yellow} }

sphere { <-1,0.7,0>, 1, 0.5 pigment {Gold} }

texture{Glass}

finish { phong 0.8 }

}

http://en.wikipedia.org/wiki/Image:Phong_components_version_4.png

Practical examples: Algebraic Topology figure

Finally draw a few homotopy paths (in this case the problem called for acomposition of functions). We use cylinders to show these paths and asphere to mark our single-point.

sphere {<0.2,0.4,-1.5>,0.05 pigment{Black} finish { phong 0.9 }}

cylinder {<.5,0.3,0.2>,<0.8,0.2,-3>, 0.01 texture{pigment{color Green}

finish {ambient 0.45 diffuse 0.55 phong 1}}}

cylinder {<0.8,0.2,-3>,<0.2,0.4,-1.5>, 0.01 texture{pigment{color Blue}

finish {ambient 0.45 diffuse 0.55 phong 1}}}

cylinder { <0,0.6,0>,<-0.8,1.2,-3>, 0.01 texture{pigment{color Green}

finish {ambient 0.45 diffuse 0.55 phong 1}}}

cylinder {<-0.8,1.2,-3>,<0.2,0.4,-1.5>, 0.01 texture{pigment{color Blue}

finish {ambient 0.45 diffuse 0.55 phong 1}}}

cylinder { <0.5,1,-0.5>,<0.8,1,-3>, 0.01 texture{pigment{color Green}

finish {ambient 0.45 diffuse 0.55 phong 1}}}

cylinder {<0.8,1,-3>,<0.2,0.4,-1.5>, 0.01 texture{pigment{color Blue}

finish {ambient 0.45 diffuse 0.55 phong 1}}}

cylinder { <-1,0.7,0>,<-0.8,0.2,-2>, 0.01 texture{pigment{color Green}

finish {ambient 0.45 diffuse 0.55 phong 1}}}

cylinder {<-0.8,0.2,-2>,<0.2,0.4,-1.5>, 0.01 texture{pigment{color Blue}

finish {ambient 0.45 diffuse 0.55 phong 1}}}

Practical examples: Algebraic Topology figure

Practical examples: Astrophysics (microlensing)

A friend in astrophysics wants to give a really great postdoc job talk. Hehas a number of concept figures which POV-Ray could do quite well, anda friend who knows POV-Ray (me). To make a gravitational lensdiagram such as he had, we use POV-Rays spline (generates smoothcurve from discreet points) and lathe (generates by rotation) functions:

#declare bottle = lathe {

quadratic_spline

7,

<29/40,2-(113-59)/59>, <22/40,2-(104-59)/59>,

<14/40,2-(88-59)/59>,<7/40,2-(67-59)/59>,

<3.8/40,2 -(47-59)/59>,<2/40,2 -(28-59)/59>, <0,3>

sturm

}

#declare bottle2 = lathe {

quadratic_spline

7,

<29/40,2-(113-59)/59>, <22/40,2-(104-59)/59>,

<14/40,2-(88-59)/59>,<7/40,2-(67-59)/59>,

<3.8/40,2 -(47-59)/59>,<2/40,2 -(28-59)/59>, <0,3>

sturm

}

Practical examples: Astrophysics (microlensing)

Since the figure is to be conceptual, and is used to discuss the analogybetween classical lensing and gravitational lensing, we wish to give it aglass texture. We also wish to treat the two pieces created in theprevious slide as one, so we use the “union” tag. Notice that POV-Ray issophisticated enough that we can give ray transmission percentage(transmit) and index of refraction (ior) inputs.

union{

object { bottle

interior { ior 1.04 }

pigment{color Yellow transmit .7}

texture{Glass}

finish{phong .8}

translate<0,-1.0847-0.13,0>

}

object { bottle2

interior { ior 1.04 }

pigment{color Yellow transmit .7}

texture{Glass}

finish{phong .8}

rotate <180,0,0>

translate<0,0.29+(2-(113-59)/59)-0.12,0>

}

rotate<0,0,90>

scale<0.3,3.2,0>

}

Practical examples: Astrophysics (microlensing)

We can show the rays and sources using cylinder and spherecommands. The resulting figure compares well with the original.

Other figure examples...

Other figure examples...

Other figure examples...

Other figure examples...

Other figure examples...

Other figure examples...

Finally...all films are made up of frames.

POV-Ray has built in animation routines that are incredibly easy touse. You can find many examples on my web-page:

www.physics.drexel.edu/~tim

The complete set of codes for making these animations are madeavailable for reverse engineering.

The best of these animations has been compiled into a short film...