<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.povray.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Chrisb</id>
	<title>POV-Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.povray.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Chrisb"/>
	<link rel="alternate" type="text/html" href="https://wiki.povray.org/content/Special:Contributions/Chrisb"/>
	<updated>2026-04-22T12:14:46Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.35.1</generator>
	<entry>
		<id>https://wiki.povray.org/content?title=Knowledgebase:Macro_Files&amp;diff=1987</id>
		<title>Knowledgebase:Macro Files</title>
		<link rel="alternate" type="text/html" href="https://wiki.povray.org/content?title=Knowledgebase:Macro_Files&amp;diff=1987"/>
		<updated>2009-11-11T12:54:54Z</updated>

		<summary type="html">&lt;p&gt;Chrisb: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;p class=&amp;quot;Hint&amp;quot;&amp;gt;A listing of macro files sites in alphabetical order.&amp;lt;/p&amp;gt;&lt;br /&gt;
*[http://www.ndirect.co.uk/~chris.dennis/povray.html Accurate Sun Position macro]&lt;br /&gt;
:&amp;lt;p&amp;gt;A macro by Chris Dennis for calculating the position of the sun for any given time and place on the surface of the earth. It's cleverly called sun.inc.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[http://www.spiritone.com/~english/cyclopedia/include/bezier.inc Bezier.inc - Macro]&lt;br /&gt;
:&amp;lt;p&amp;gt;A bezier spline macro include file by Josh English based on POVRay 3.1.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[http://news.povray.org/povray.binaries.utilities/thread/%3C3d35eec1%40news.povray.org%3E/ Blob Man 4.2]&lt;br /&gt;
:&amp;lt;p&amp;gt;Blob Man is a set of macros that generate a humanoid figure from Blobs, the Head, Arms, Legs, Hands, Feet and Fingers can all be positioned. Hair of varying styles can be added if required, as can image_maps for the face.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[http://www.geocities.com/SiliconValley/Lakes/5432/povray/geodesic.html Geodesic V2 macro]&lt;br /&gt;
:&amp;lt;p&amp;gt;This macro include file creates evenly distributed points on a sphere like a geodesic dome By: Uwe Zimmermann&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[http://home.inreach.com/rtowle/POV/POV-Ray.html Icosahedral Kaleidoscopes]&lt;br /&gt;
:&amp;lt;p&amp;gt;Russell Towle's POV scene files for (1) and icosahedral kaleidoscope, and (2) regular and irregular star polygons, compounds of polygons, with spheres on the vertices and cylinders on the edges.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[http://home.pacbell.net/tylereng/index.html Include files/Macros]&lt;br /&gt;
:&amp;lt;p&amp;gt;Arbre.inc is a macro include file for the generation of realistic trees in POV-Ray and Mur.inc is a macro that makes realistic rock like block walls similar to what you might see in a garden or in dungeons. Both files created by Steven Pigeon and are hosted with persmission by Ken Tyler. You can also download 58 useful POV-Ray macros all in one zip file.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[http://enphilistor.50megs.com/macs.htm John VanSickles Thoroughly Useful Macros and Include files]&lt;br /&gt;
:&amp;lt;p&amp;gt;John has a great collection of macros and include files zipped into a single downloadable archive. Useful for any POV-Ray users tool box. Also available from  http://www.geocities.com./evilsnack/macs.htm&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[http://members.tripod.com/~klatte/pov/povfiles.html Julius Klatte's Asymmetrical Scaling Macro]&lt;br /&gt;
:&amp;lt;p&amp;gt;The Asymmetrical Scaling Macro is a very useful tool for scaling several parts of objects in separate ways, for example to create an egg shape by scaling a sphere asymmetrically. Object merging supported for perfect transparent objects.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[http://members.tripod.com/~klatte/pov/povfiles.html Julius Klatte's Lens Macro]&lt;br /&gt;
:&amp;lt;p&amp;gt;Create magnifying lenses with just two macro parameters: lens radius and thickness. Two example refractive glass materials included.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[http://members.tripod.com/~klatte/pov/povfiles.html Julius Klatte's Mesh Box Macro]&lt;br /&gt;
:&amp;lt;p&amp;gt;This small macro makes it possible to build a box consisting of mesh triangles, with an input of only two vectors (just like in the regular box object statement). Useful for exporting from POV-Ray.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[http://members.tripod.com/~klatte/pov/povfiles.html Julius Klatte's Random function Macro]&lt;br /&gt;
:&amp;lt;p&amp;gt;A macro shortcut for a mathematical calculation: input is a range (two different numbers), output is a random number in that range (i.e. smaller than the maximum and larger than the minimum).&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[http://members.tripod.com/~klatte/pov/povfiles.html Julius Klatte's Rounded Box Macro]&lt;br /&gt;
:&amp;lt;p&amp;gt;Do you wish to use a box without sharp edges in a scene, but a superellipsoid isn't quite the thing you want? Try this macro to get some smooth edges without placing all those spheres and cylinders.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[http://www.zeropps.uklinux.net Lattice Work Macro]&lt;br /&gt;
:&amp;lt;p&amp;gt;The Latticework macro can produce 31 different designs and with three different cross types and can apply the texture at three different levels all within the macro so that you can have as many different types of latticework in one scene as you like.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[http://www.xs4all.nl/~remcodek/pov.html Macros - SoftForm, XTree, and Voetbal]&lt;br /&gt;
:&amp;lt;p&amp;gt;*SoftForm, is an INC with a macro that creates (flat) polygons with rounded edges. It also has shortcuts to create several polygons, including stars. * XTree is an include-file that creates simple Xmas-type trees. *Voetbal (soccer ball) is yet another ball-macro but this one is (for) kicking!&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[http://www.oyonale.com/ MakeTree]&lt;br /&gt;
:&amp;lt;p&amp;gt;By Gilles Tran - Make Very realistic Trees in POV-Ray. This file keeps evolving and is very much in demand.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[http://perso.wanadoo.fr/mops/atelier05.html MPOS Studio - POV-Ray Macros]&lt;br /&gt;
:&amp;lt;p&amp;gt;A collection of POV-Ray Macros including macros to connects two pre-declared points.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[http://www.geocities.com/SiliconValley/Way/2419/POVMacros.html POV-Ray 3.1 Macros]&lt;br /&gt;
:&amp;lt;p&amp;gt;Fill - Box or Cylinder with Spheres Macros&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[http://www.oyonale.com/ POV-Ray Object Files by Gilles Tran - A True Master of the Art]&lt;br /&gt;
:&amp;lt;p&amp;gt;Site includes a Macro Tree file, Grass generation, Window Blinds, Brick Walls, Special Shape extrusion Macro, 19th Century Lamp Post, Folding Deck Chair, Odd Pipe connecting Macro file, Glass w/liquid object, Broken Egg, and Angel Wings object.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[http://lib.povray.org/searchcollection/index2.php POV-Ray Object Collection]&lt;br /&gt;
:&amp;lt;p&amp;gt;Lots of POV-Ray macros by different contributors on a common copyleft license. Maintained on the official POV-Ray web site.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[http://members.home.nl/seedseven/ POV-Ray Stuff by Ingo Janssen]&lt;br /&gt;
:&amp;lt;p&amp;gt;Site contains several useful macros; param.inc, twovar.inc, coons.inc, lathe.inc, msm.inc, prism.inc.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[http://www.geocities.com/evilsnack/nsss.htm Subdivision Surface Suite for POV-Ray]&lt;br /&gt;
:&amp;lt;p&amp;gt;A subdivision surface is a method of generating curving surfaces by taking a mesh of polygons, and refining those polygons by replacing them with smaller polygons, each derived by a set formula from the polygons of the prior generation of the surface. The resulting polygon mesh, over successive generations, approaches a smooth curve. The Surface Subdivision Suite is a suite of macros by John VanSickle which enable the user to take a coarse triangle mesh and smooth it into something that appears far smoother.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[http://www.jbarchuk.com/twillis/ Theresa Willis' Motion Library for POV-Ray3.0]&lt;br /&gt;
:&amp;lt;p&amp;gt;Theresa Willis' include files for generating robotic style walking POV-Ray animations. Walking.inc and Son of Wilbot.inc.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[http://www.nolights.de/main.html Tim's Resource Page]&lt;br /&gt;
:&amp;lt;p&amp;gt;Tim Nikias' site contains various macro utilities and object files for download. Visit site to see what is available.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[http://news.povray.org/povray.binaries.scene-files/thread/%3C38CB12D0.732F7F15@enter.net%3E/?ttop=214185&amp;amp;toff=700 Triscan Macro for MegaPOV]&lt;br /&gt;
:&amp;lt;p&amp;gt;Triscan.mcr is a macro definition file designed to work with MegaPOV's new features, such as trace(), min_extent, max_extent, and so forth to produce a simulated surface scan of a #declared POV object, and export it as a triangle mesh in RAW or LSL format. RAW files can then be converted with programs such as 3DWin or Crossroads to a number of other formats, and LSL files can be directly imported into the Leveller height field editor.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p class=&amp;quot;QTNavBar&amp;quot;&amp;gt;End of Category: [[KB:POV-Ray Include Macro and Object Files|Go Back to the Categories List]]&amp;lt;/p&amp;gt;&lt;br /&gt;
[[Category:POV-Ray Links Collection]]&lt;/div&gt;</summary>
		<author><name>Chrisb</name></author>
	</entry>
	<entry>
		<id>https://wiki.povray.org/content?title=Knowledgebase:Include_Files&amp;diff=1986</id>
		<title>Knowledgebase:Include Files</title>
		<link rel="alternate" type="text/html" href="https://wiki.povray.org/content?title=Knowledgebase:Include_Files&amp;diff=1986"/>
		<updated>2009-11-11T12:52:12Z</updated>

		<summary type="html">&lt;p&gt;Chrisb: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;p class=&amp;quot;Hint&amp;quot;&amp;gt;A listing of include files sites in alphabetical order.&amp;lt;/p&amp;gt;&lt;br /&gt;
*[http://www.interq.or.jp/blue/kawashu/ 5 POV-Ray Include files]&lt;br /&gt;
:&amp;lt;p&amp;gt;This site by Kawashu contains 5 POV-Ray include files Geodesic Dome,  Short torus macro, Curve generator, Cracke Pattern (Making objects with the shapes of the crackle pattern), Penrose Tiling, and a Regular Polytope. Include files page is in Japanese only but the files are easy to use.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[http://www.chez.com/pidou/arbres.htm Abres (Trees)]&lt;br /&gt;
:&amp;lt;p&amp;gt;Tree generating include file by Pidou&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[http://www.antonraves.com/lego.html Anton Raves' Lego Include File Libraries]&lt;br /&gt;
:&amp;lt;p&amp;gt;This is very cool stuff: lego blocks for the Persistence of Vision raytracer. You can now put lego creations into your ray-traced scenes! Almost as fun as the original.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[http://us.geocities.com/jvanvoorden/ Biowin - Biological Forms Generation App.]&lt;br /&gt;
:&amp;lt;p&amp;gt;Biowin is a graphical notepad (a toy ... a tool ...) for easy entering params and values to make bioforms with PovRay&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[http://www.geocities.com/SiliconValley/Lakes/1434/ Chris Colefax Include Files]&lt;br /&gt;
:&amp;lt;p&amp;gt;Chris basicaly invented the include file and has more include files than can be listed here.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[http://www.geocities.com/Athens/Academy/8764/index.html Edna Dorblazer Institute of Theoretical Cosmetology and Mad Secretarial Sciences]&lt;br /&gt;
:&amp;lt;p&amp;gt;Edna has several POV-Ray include files worth looking at&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[http://baillp.free.fr/feather.html Feather Include file]&lt;br /&gt;
:&amp;lt;p&amp;gt;This include file will create a realistic feather object.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[http://www.deakin.edu.au/~agoodman/gems.inc Gems.Inc]&lt;br /&gt;
:&amp;lt;p&amp;gt;POV-Ray include file with many declared textures and diamond shapes available&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[http://www.spiritone.com/~english/cyclopedia/grass.html Grasspatch.inc]&lt;br /&gt;
:&amp;lt;p&amp;gt;This is an include file for making realistic grasses with. Also on this page is a comprehensive tutorial explaining the techniques involved with the process.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[http://runevision.com/3d/include/include.asp Inverse Kinematics Neck Include File]&lt;br /&gt;
:&amp;lt;p&amp;gt;The Inverse Kinematics Neck Include File (or just ikn.inc) allows you to create smooth strings of objects which you can use for long necks, long tails, and many other things.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[http://www.imagico.de/pov/ic/index.html IsoCSG Include File]&lt;br /&gt;
:&amp;lt;p&amp;gt;POV-Ray offers very powerful CSG functions to design objects, but an often requested feature, bending and other nonlinear transformations is not possible for principal reasons. This IsoCSG library by Christoph Hormann allows you to go beyond these limitations using new features available in POV-Ray v3.5.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[http://www.imagico.de/iso_wood.html IsoWood Include File]&lt;br /&gt;
:&amp;lt;p&amp;gt;An include file by Christoph Hormann for creating realisted wood using  the Isosurface function in POV-Ray.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[http://users.zetnet.co.uk/keithh/index.htm Keith Hull's Moray Plugins]&lt;br /&gt;
:&amp;lt;p&amp;gt;Inludes the following plug-in moduals- Corrinthian Collumns, Liquid Spray, Galaxy, and City Generator. The last three are include files created by Chris Colefax and are available on his home page as standard POV-Ray include files.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[http://home.pacbell.net/tylereng/index.html Kolors.inc]&lt;br /&gt;
:&amp;lt;p&amp;gt;Ken Tyler's KOLORS.INC file is based on the standard POV-Ray colors.inc file but has been enhanced with the addition of many more pre declared colors. There are over 550 colors in all in the file plus there is a demonstration pov file included complete with indexing to help you select the correct colors for your scene.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[http://membres.lycos.fr/artphil/ Mathematical Art]&lt;br /&gt;
:&amp;lt;p&amp;gt;Polynomial, fractales, bioitÚration, landscape and more. Site contains a gallery of image produced using the above techniques plus offers include files for the creation of some of the images presented.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[http://nathan.kopp.com/nkflare.htm Nathan Kopps LensFlare inc.]&lt;br /&gt;
:&amp;lt;p&amp;gt;This is very popular and excellent utility that adds lens flares to objects in your scene.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[http://www.geocities.com/Tokyo/Teahouse/8148/ Polyhedral Include file]&lt;br /&gt;
:&amp;lt;p&amp;gt;Follow the link to 'GroundNet Graphics' to get a choice of POV-Ray pages by Treshall containing images and various POV-Ray utilities including Polyhedral.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[http://lib.povray.org/searchcollection/index2.php POV-Ray Object Collection]&lt;br /&gt;
:&amp;lt;p&amp;gt;Lots of POV-Ray include files by different contributors on a common copyleft license. Maintained on the official POV-Ray web site.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[http://www.deakin.edu.au/~agoodman/povstuff.php POV-Ray Utilities/incs]&lt;br /&gt;
:&amp;lt;p&amp;gt;Color-Wheel progam plus 6 include files and utilities of various types&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[http://membres.lycos.fr/froux/ Povray Include files]&lt;br /&gt;
:&amp;lt;p&amp;gt;Site contains a nice little collection of POV-Ray include files in the plugins section. Items available are - Trees, Effets de flare, cha¯ns, Books, Stwist, Mesh, Tentacle, Bend, Spheres and cones, Galaxy, Explode, City, and a Horse.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[http://runevision.com/3d/include/ RuneVision Include Files]&lt;br /&gt;
:&amp;lt;p&amp;gt;The RSJ Website contains an excellent collection of include files including the CD Disk include file, LipSync and Grass include files.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[http://www.geocities.com/SoHo/Lofts/1022/menu2.htm Sonya Roberts Include Files]&lt;br /&gt;
:&amp;lt;p&amp;gt;Keyboard, Tree, Books, and others&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[http://povplace.addr.com/files/ Spline-Tree: Andrew's POV Files Page]&lt;br /&gt;
:&amp;lt;p&amp;gt;A tree include file for POV-Ray v3.1&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[http://203.29.75.35/povray.binaries.utilities/thread/%3C3ccdbb76@news.povray.org%3E/?ttop=306190&amp;amp;toff=100 Stereo.inc]&lt;br /&gt;
:&amp;lt;p&amp;gt;This file creates a system for viewing POV-Ray scene files in stereo by 'Vic'&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[http://www.aust-manufaktur.de/austv2x.html TomTree]&lt;br /&gt;
:&amp;lt;p&amp;gt;Tree generating include file by Tom Aust - Excellent utility with many options. Click on the word TOMTREE written vertically down the right hand side of the images to download the zip file.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[http://www.geocities.com/SoHo/Studios/6578/include.html Useful Inc Files]&lt;br /&gt;
:&amp;lt;p&amp;gt;A zip file containing POV-Ray source for a number of objects such as a dagger, a sword, a pen, a clock and a cigar box.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[http://www.geocities.com/SiliconValley/Program/9231/povray.html Vegetate]&lt;br /&gt;
:&amp;lt;p&amp;gt;This include file will place objects at random on the surface of any object. Requires Ron Parkers Super Patch&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p class=&amp;quot;QTNavBar&amp;quot;&amp;gt;End of Category: [[KB:POV-Ray Include Macro and Object Files|Go Back to the Categories List]]&amp;lt;/p&amp;gt;&lt;br /&gt;
[[Category:POV-Ray Links Collection]]&lt;/div&gt;</summary>
		<author><name>Chrisb</name></author>
	</entry>
	<entry>
		<id>https://wiki.povray.org/content?title=Knowledgebase:Object_and_Scene_Files&amp;diff=1985</id>
		<title>Knowledgebase:Object and Scene Files</title>
		<link rel="alternate" type="text/html" href="https://wiki.povray.org/content?title=Knowledgebase:Object_and_Scene_Files&amp;diff=1985"/>
		<updated>2009-11-11T12:49:05Z</updated>

		<summary type="html">&lt;p&gt;Chrisb: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;p class=&amp;quot;Hint&amp;quot;&amp;gt;A listing of object and scene files sites in alphabetical order.&amp;lt;/p&amp;gt;&lt;br /&gt;
*[http://lib.povray.org/searchcollection/index2.php?objectName=FranciscoMunoz&amp;amp;version=1.0&amp;amp;contributorTag=SharkD Archive of imagination]&lt;br /&gt;
:&amp;lt;p&amp;gt;POV-Ray scene files and objects by Francisco Munoz, Uploaded to POVRay Object Collection when Geocities closed. &amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[http://jgrimbert.free.fr/pov/objet.html Brilliant Cut Diamond]&lt;br /&gt;
:&amp;lt;p&amp;gt;Downloadable Diamond shaped POV object. Author reserves all rights.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[http://www.btinternet.com/~timeref/freemods.htm Castle Object]&lt;br /&gt;
:&amp;lt;p&amp;gt;Free POVRAY model of a medieval building.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[http://www.asahi-net.or.jp/~nj2t-hg/ Cyberbust Gallery]&lt;br /&gt;
:&amp;lt;p&amp;gt;Mostly an exhibit of the work of Tsutomu Higo.Abstract images with POV-Ray source files available.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[http://dast.freeshell.org/section/pov/library Dast's POV-Ray page]&lt;br /&gt;
:&amp;lt;p&amp;gt;Eyeball, Candle, Padlock, Array include files for POV-Ray v3.0&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[http://perso.wanadoo.fr/eureka2.12/vrml/welcome.html Eureka parametric surface models]&lt;br /&gt;
:&amp;lt;p&amp;gt;Site in English, French, Spanish, Dutch and Italian containing 3d implicit / parametric surface models in POV-Ray format, VRML format and Mathematica format.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[http://www.f-lohmueller.de/pov/g_a6.htm Friedrich Lohmueller gallery]&lt;br /&gt;
:&amp;lt;p&amp;gt;While-loops with POV-Ray - how to create twisted rings - samples with POV-Ray scene files by F. A. Lohmueller.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[http://www.interstation3d.com/pov_sourc.htm INTER-STATION 3D - The homepage of Toni Bratincevic]&lt;br /&gt;
:&amp;lt;p&amp;gt;A nice collection of objects and macros, including a 'fake fire' macro, a tree generator and some impressive scene files.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[http://www.geocities.com/cyfr_j_bone/raytracing/models.html Jayz models]&lt;br /&gt;
:&amp;lt;p&amp;gt;Moray-files Electronics, Office, Bathroom misc. There are a couple of POV-Ray include files (Hexaagonal grid and Axes)&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[http://www.users.zetnet.co.uk/keithh/povnew.htm Keith Hull's Moray Plug-In's]&lt;br /&gt;
:&amp;lt;p&amp;gt;Moray Plugins Grass, Trees, Columns, Chains etc.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[http://www.outerarm.demon.co.uk/graphics/graphics_povray_objects.html OuterArm POVRay Objects]&lt;br /&gt;
:&amp;lt;p&amp;gt;Page has 5 POV-Ray objects. Newtons cradle, pencil, pencil holder w/pencils, coffee cup w/mat, and a flexible neck desk lamp.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[http://www.travelnotes.de/rays/ POV-Ray Images]&lt;br /&gt;
:&amp;lt;p&amp;gt;Source files available for study by: Kurt Bangert and Carola Blaesing-Bangert Be sure to see the section with images and sample code for using media.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[http://lib.povray.org/searchcollection/index2.php POV-Ray Object Collection]&lt;br /&gt;
:&amp;lt;p&amp;gt;Lots of POV-Ray objects by different contributors on a common copyleft license. Maintained on the official POV-Ray web site.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[http://membres.lycos.fr/froux/ POV-Ray Objects]&lt;br /&gt;
:&amp;lt;p&amp;gt;Site contains a very nice collection of about half a dozen objects in POV-Ray format by F Roux. The site is in French, but easily navigable, (see the 'modeles' section). Also includes a set of utilities and a gallery.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[http://www.povworld.de/objects/ Old POV-Ray Objects Collection]&lt;br /&gt;
:&amp;lt;p&amp;gt;Over 155 Excellent POV-Ray objects in one place You are invited to contribute to the collection. Maintained by Micha Riser - last updated in Feb 2003.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[http://www.travelnotes.de/rays/island/index.htm POV-Ray Scene File]&lt;br /&gt;
:&amp;lt;p&amp;gt;A couple of scenes inspired by Jurassic Park by Michael Crichton (1990). With cliffs, helicopter and waterfall - source is available and a discussion on the techniques use.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[http://www.geocities.com/SiliconValley/Network/4969/download.html Ray-Tracing Files]&lt;br /&gt;
:&amp;lt;p&amp;gt;POV-Ray mixed collection by Michael Brendan Hurley&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[http://www.asahi-net.or.jp/~nj2t-hg/ilpov21e.htm Raytraced Graphics Polar -E]&lt;br /&gt;
:&amp;lt;p&amp;gt;Mathematical objects created in POV-Ray. Source available in POV-ray 3.1 format by Tsutomu Higo&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[http://rod.gelaude.chez-alice.fr/en/index.htm Rod Gelaudes POV-Ray Gallery]&lt;br /&gt;
:&amp;lt;p&amp;gt;Rod Gelaudes web sit in French and mixed English/French. A small collection of downloadable Objects, Tutorials and a gallery of his own works. The objects include half a dozen animal models (including a triangular mesh for an elephant), a vase, a globe and a lamp.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[http://www.hal-pc.org/~jsb/shuttlepov.html Space Shuttle]&lt;br /&gt;
:&amp;lt;p&amp;gt;POV-Ray Model Project of the US Space Shuttle.This page is devoted to making available and further developing a detailed POV-Ray format Space Shuttle model. The current model is available for download and is shown in the image on this page.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[http://www.dylanbeattie.net/starwars/ Star Wars: The POV-Ray Collection]&lt;br /&gt;
:&amp;lt;p&amp;gt;A number of Star Wars related models mostly POV-Ray 3.1 format by D M Beattie.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[http://www.opticfox.com/povray.htm The Illuzion Zone - StarWars Models, POV-Ray Textures, and Utilities]&lt;br /&gt;
:&amp;lt;p&amp;gt;Site contains a nice collection of StarWars models in POV-Ray format, some POV-Ray v2.2 textures, and a small collection of POV-Ray utilities.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p class=&amp;quot;QTNavBar&amp;quot;&amp;gt;End of Category: [[KB:POV-Ray Include Macro and Object Files|Go Back to the Categories List]]&amp;lt;/p&amp;gt;&lt;br /&gt;
[[Category:POV-Ray Links Collection]]&lt;/div&gt;</summary>
		<author><name>Chrisb</name></author>
	</entry>
	<entry>
		<id>https://wiki.povray.org/content?title=Knowledgebase:Include_Files&amp;diff=1984</id>
		<title>Knowledgebase:Include Files</title>
		<link rel="alternate" type="text/html" href="https://wiki.povray.org/content?title=Knowledgebase:Include_Files&amp;diff=1984"/>
		<updated>2009-11-11T12:25:01Z</updated>

		<summary type="html">&lt;p&gt;Chrisb: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;p class=&amp;quot;Hint&amp;quot;&amp;gt;A listing of include files sites in alphabetical order.&amp;lt;/p&amp;gt;&lt;br /&gt;
*[http://www.interq.or.jp/blue/kawashu/ 5 POV-Ray Include files]&lt;br /&gt;
:&amp;lt;p&amp;gt;This site by Kawashu contains 5 POV-Ray include files Geodesic Dome,  Short torus macro, Curve generator, Cracke Pattern (Making objects with the shapes of the crackle pattern), Penrose Tiling, and a Regular Polytope. Include files page is in Japanese only but the files are easy to use.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[http://www.chez.com/pidou/arbres.htm Abres (Trees)]&lt;br /&gt;
:&amp;lt;p&amp;gt;Tree generating include file by Pidou&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[http://www.antonraves.com/lego.html Anton Raves' Lego Include File Libraries]&lt;br /&gt;
:&amp;lt;p&amp;gt;This is very cool stuff: lego blocks for the Persistence of Vision raytracer. You can now put lego creations into your ray-traced scenes! Almost as fun as the original.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[http://us.geocities.com/jvanvoorden/ Biowin - Biological Forms Generation App.]&lt;br /&gt;
:&amp;lt;p&amp;gt;Biowin is a graphical notepad (a toy ... a tool ...) for easy entering params and values to make bioforms with PovRay&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[http://www.geocities.com/SiliconValley/Lakes/1434/ Chris Colefax Include Files]&lt;br /&gt;
:&amp;lt;p&amp;gt;Chris basicaly invented the include file and has more include files than can be listed here.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[http://www.geocities.com/Athens/Academy/8764/index.html Edna Dorblazer Institute of Theoretical Cosmetology and Mad Secretarial Sciences]&lt;br /&gt;
:&amp;lt;p&amp;gt;Edna has several POV-Ray include files worth looking at&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[http://baillp.free.fr/feather.html Feather Include file]&lt;br /&gt;
:&amp;lt;p&amp;gt;This include file will create a realistic feather object.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[http://www.deakin.edu.au/~agoodman/gems.inc Gems.Inc]&lt;br /&gt;
:&amp;lt;p&amp;gt;POV-Ray include file with many declared textures and diamond shapes available&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[http://www.spiritone.com/~english/cyclopedia/grass.html Grasspatch.inc]&lt;br /&gt;
:&amp;lt;p&amp;gt;This is an include file for making realistic grasses with. Also on this page is a comprehensive tutorial explaining the techniques involved with the process.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[http://runevision.com/3d/include/include.asp Inverse Kinematics Neck Include File]&lt;br /&gt;
:&amp;lt;p&amp;gt;The Inverse Kinematics Neck Include File (or just ikn.inc) allows you to create smooth strings of objects which you can use for long necks, long tails, and many other things.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[http://www.imagico.de/pov/ic/index.html IsoCSG Include File]&lt;br /&gt;
:&amp;lt;p&amp;gt;POV-Ray offers very powerful CSG functions to design objects, but an often requested feature, bending and other nonlinear transformations is not possible for principal reasons. This IsoCSG library by Christoph Hormann allows you to go beyond these limitations using new features available in POV-Ray v3.5.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[http://www.imagico.de/iso_wood.html IsoWood Include File]&lt;br /&gt;
:&amp;lt;p&amp;gt;An include file by Christoph Hormann for creating realisted wood using  the Isosurface function in POV-Ray.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[http://users.zetnet.co.uk/keithh/index.htm Keith Hull's Moray Plugins]&lt;br /&gt;
:&amp;lt;p&amp;gt;Inludes the following plug-in moduals- Corrinthian Collumns, Liquid Spray, Galaxy, and City Generator. The last three are include files created by Chris Colefax and are available on his home page as standard POV-Ray include files.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[http://home.pacbell.net/tylereng/index.html Kolors.inc]&lt;br /&gt;
:&amp;lt;p&amp;gt;Ken Tyler's KOLORS.INC file is based on the standard POV-Ray colors.inc file but has been enhanced with the addition of many more pre declared colors. There are over 550 colors in all in the file plus there is a demonstration pov file included complete with indexing to help you select the correct colors for your scene.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[http://membres.lycos.fr/artphil/ Mathematical Art]&lt;br /&gt;
:&amp;lt;p&amp;gt;Polynomial, fractales, bioitÚration, landscape and more. Site contains a gallery of image produced using the above techniques plus offers include files for the creation of some of the images presented.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[http://nathan.kopp.com/nkflare.htm Nathan Kopps LensFlare inc.]&lt;br /&gt;
:&amp;lt;p&amp;gt;This is very popular and excellent utility that adds lens flares to objects in your scene.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[http://www.geocities.com/Tokyo/Teahouse/8148/ Polyhedral Include file]&lt;br /&gt;
:&amp;lt;p&amp;gt;Follow the link to 'GroundNet Graphics' to get a choice of POV-Ray pages by Treshall containing images and various POV-Ray utilities including Polyhedral.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[http://www.deakin.edu.au/~agoodman/povstuff.php POV-Ray Utilities/incs]&lt;br /&gt;
:&amp;lt;p&amp;gt;Color-Wheel progam plus 6 include files and utilities of various types&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[http://membres.lycos.fr/froux/ Povray Include files]&lt;br /&gt;
:&amp;lt;p&amp;gt;Site contains a nice little collection of POV-Ray include files in the plugins section. Items available are - Trees, Effets de flare, cha¯ns, Books, Stwist, Mesh, Tentacle, Bend, Spheres and cones, Galaxy, Explode, City, and a Horse.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[http://runevision.com/3d/include/ RuneVision Include Files]&lt;br /&gt;
:&amp;lt;p&amp;gt;The RSJ Website contains an excellent collection of include files including the CD Disk include file, LipSync and Grass include files.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[http://www.geocities.com/SoHo/Lofts/1022/menu2.htm Sonya Roberts Include Files]&lt;br /&gt;
:&amp;lt;p&amp;gt;Keyboard, Tree, Books, and others&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[http://povplace.addr.com/files/ Spline-Tree: Andrew's POV Files Page]&lt;br /&gt;
:&amp;lt;p&amp;gt;A tree include file for POV-Ray v3.1&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[http://203.29.75.35/povray.binaries.utilities/thread/%3C3ccdbb76@news.povray.org%3E/?ttop=306190&amp;amp;toff=100 Stereo.inc]&lt;br /&gt;
:&amp;lt;p&amp;gt;This file creates a system for viewing POV-Ray scene files in stereo by 'Vic'&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[http://www.aust-manufaktur.de/austv2x.html TomTree]&lt;br /&gt;
:&amp;lt;p&amp;gt;Tree generating include file by Tom Aust - Excellent utility with many options. Click on the word TOMTREE written vertically down the right hand side of the images to download the zip file.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[http://www.geocities.com/SoHo/Studios/6578/include.html Useful Inc Files]&lt;br /&gt;
:&amp;lt;p&amp;gt;A zip file containing POV-Ray source for a number of objects such as a dagger, a sword, a pen, a clock and a cigar box.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[http://www.geocities.com/SiliconValley/Program/9231/povray.html Vegetate]&lt;br /&gt;
:&amp;lt;p&amp;gt;This include file will place objects at random on the surface of any object. Requires Ron Parkers Super Patch&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p class=&amp;quot;QTNavBar&amp;quot;&amp;gt;End of Category: [[KB:POV-Ray Include Macro and Object Files|Go Back to the Categories List]]&amp;lt;/p&amp;gt;&lt;br /&gt;
[[Category:POV-Ray Links Collection]]&lt;/div&gt;</summary>
		<author><name>Chrisb</name></author>
	</entry>
	<entry>
		<id>https://wiki.povray.org/content?title=Knowledgebase:Object_and_Scene_Files&amp;diff=1983</id>
		<title>Knowledgebase:Object and Scene Files</title>
		<link rel="alternate" type="text/html" href="https://wiki.povray.org/content?title=Knowledgebase:Object_and_Scene_Files&amp;diff=1983"/>
		<updated>2009-11-11T12:09:00Z</updated>

		<summary type="html">&lt;p&gt;Chrisb: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;p class=&amp;quot;Hint&amp;quot;&amp;gt;A listing of object and scene files sites in alphabetical order.&amp;lt;/p&amp;gt;&lt;br /&gt;
*[http://www.geocities.com/SoHo/Studios/6578/ficheros.html Archive of imagination]&lt;br /&gt;
:&amp;lt;p&amp;gt;POV-Ray scene files and objects -Misc.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[http://jgrimbert.free.fr/pov/objet.html Brilliant Cut Diamond]&lt;br /&gt;
:&amp;lt;p&amp;gt;Downloadable Diamond shaped POV object. Author reserves all rights.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[http://www.btinternet.com/~timeref/freemods.htm Castle Object]&lt;br /&gt;
:&amp;lt;p&amp;gt;Free POVRAY model of a medieval building.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[http://www.asahi-net.or.jp/~nj2t-hg/ Cyberbust Gallery]&lt;br /&gt;
:&amp;lt;p&amp;gt;Mostly an exhibit of the work of Tsutomu Higo.Abstract images with POV-Ray source files available.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[http://dast.freeshell.org/section/pov/library Dast's POV-Ray page]&lt;br /&gt;
:&amp;lt;p&amp;gt;Eyeball, Candle, Padlock, Array include files for POV-Ray v3.0&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[http://perso.wanadoo.fr/eureka2.12/vrml/welcome.html Eureka parametric surface models]&lt;br /&gt;
:&amp;lt;p&amp;gt;Site in English, French, Spanish, Dutch and Italian containing 3d implicit / parametric surface models in POV-Ray format, VRML format and Mathematica format.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[http://www.f-lohmueller.de/pov/g_a6.htm Friedrich Lohmueller gallery]&lt;br /&gt;
:&amp;lt;p&amp;gt;While-loops with POV-Ray - how to create twisted rings - samples with POV-Ray scene files by F. A. Lohmueller.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[http://www.interstation3d.com/pov_sourc.htm INTER-STATION 3D - The homepage of Toni Bratincevic]&lt;br /&gt;
:&amp;lt;p&amp;gt;A nice collection of objects and macros, including a 'fake fire' macro, a tree generator and some impressive scene files.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[http://www.geocities.com/cyfr_j_bone/raytracing/models.html Jayz models]&lt;br /&gt;
:&amp;lt;p&amp;gt;Moray-files Electronics, Office, Bathroom misc. There are a couple of POV-Ray include files (Hexaagonal grid and Axes)&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[http://www.users.zetnet.co.uk/keithh/povnew.htm Keith Hull's Moray Plug-In's]&lt;br /&gt;
:&amp;lt;p&amp;gt;Moray Plugins Grass, Trees, Columns, Chains etc.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[http://www.outerarm.demon.co.uk/graphics/graphics_povray_objects.html OuterArm POVRay Objects]&lt;br /&gt;
:&amp;lt;p&amp;gt;Page has 5 POV-Ray objects. Newtons cradle, pencil, pencil holder w/pencils, coffee cup w/mat, and a flexible neck desk lamp.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[http://www.travelnotes.de/rays/ POV-Ray Images]&lt;br /&gt;
:&amp;lt;p&amp;gt;Source files available for study by: Kurt Bangert and Carola Blaesing-Bangert Be sure to see the section with images and sample code for using media.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[http://membres.lycos.fr/froux/ POV-Ray Objects]&lt;br /&gt;
:&amp;lt;p&amp;gt;Site contains a very nice collection of about half a dozen objects in POV-Ray format by F Roux. The site is in French, but easily navigable, (see the 'modeles' section). Also includes a set of utilities and a gallery.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[http://www.povworld.de/objects/ POV-Ray Objects Collection]&lt;br /&gt;
:&amp;lt;p&amp;gt;Over 155 Excellent POV-Ray objects in one place You are invited to contribute to the collection. Maintained by Micha Riser - last updated in Feb 2003.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[http://www.travelnotes.de/rays/island/index.htm POV-Ray Scene File]&lt;br /&gt;
:&amp;lt;p&amp;gt;A couple of scenes inspired by Jurassic Park by Michael Crichton (1990). With cliffs, helicopter and waterfall - source is available and a discussion on the techniques use.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[http://www.geocities.com/SiliconValley/Network/4969/download.html Ray-Tracing Files]&lt;br /&gt;
:&amp;lt;p&amp;gt;POV-Ray mixed collection by Michael Brendan Hurley&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[http://www.asahi-net.or.jp/~nj2t-hg/ilpov21e.htm Raytraced Graphics Polar -E]&lt;br /&gt;
:&amp;lt;p&amp;gt;Mathematical objects created in POV-Ray. Source available in POV-ray 3.1 format by Tsutomu Higo&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[http://rod.gelaude.chez-alice.fr/en/index.htm Rod Gelaudes POV-Ray Gallery]&lt;br /&gt;
:&amp;lt;p&amp;gt;Rod Gelaudes web sit in French and mixed English/French. A small collection of downloadable Objects, Tutorials and a gallery of his own works. The objects include half a dozen animal models (including a triangular mesh for an elephant), a vase, a globe and a lamp.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[http://www.hal-pc.org/~jsb/shuttlepov.html Space Shuttle]&lt;br /&gt;
:&amp;lt;p&amp;gt;POV-Ray Model Project of the US Space Shuttle.This page is devoted to making available and further developing a detailed POV-Ray format Space Shuttle model. The current model is available for download and is shown in the image on this page.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[http://www.dylanbeattie.net/starwars/ Star Wars: The POV-Ray Collection]&lt;br /&gt;
:&amp;lt;p&amp;gt;A number of Star Wars related models mostly POV-Ray 3.1 format by D M Beattie.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[http://www.opticfox.com/povray.htm The Illuzion Zone - StarWars Models, POV-Ray Textures, and Utilities]&lt;br /&gt;
:&amp;lt;p&amp;gt;Site contains a nice collection of StarWars models in POV-Ray format, some POV-Ray v2.2 textures, and a small collection of POV-Ray utilities.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p class=&amp;quot;QTNavBar&amp;quot;&amp;gt;End of Category: [[KB:POV-Ray Include Macro and Object Files|Go Back to the Categories List]]&amp;lt;/p&amp;gt;&lt;br /&gt;
[[Category:POV-Ray Links Collection]]&lt;/div&gt;</summary>
		<author><name>Chrisb</name></author>
	</entry>
	<entry>
		<id>https://wiki.povray.org/content?title=Documentation_Talk:Tutorial_Section_3&amp;diff=1929</id>
		<title>Documentation Talk:Tutorial Section 3</title>
		<link rel="alternate" type="text/html" href="https://wiki.povray.org/content?title=Documentation_Talk:Tutorial_Section_3&amp;diff=1929"/>
		<updated>2009-10-22T12:56:38Z</updated>

		<summary type="html">&lt;p&gt;Chrisb: Created page with '&amp;lt;!--&amp;lt;wikitalk&amp;gt;---&amp;gt; &amp;lt;table width=100% border=1 cellspacing=0 cellpadding=5&amp;gt; &amp;lt;tr&amp;gt;&amp;lt;td width=100% bgcolor=#FFEEEE&amp;gt; This document is protected, so submissions, corrections and discuss…'&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;!--&amp;lt;wikitalk&amp;gt;---&amp;gt;&lt;br /&gt;
&amp;lt;table width=100% border=1 cellspacing=0 cellpadding=5&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td width=100% bgcolor=#FFEEEE&amp;gt;&lt;br /&gt;
This document is protected, so submissions, corrections and discussions should be held on this documents [[Documentation_Talk:Tutorial Section 3|talk]] page.&lt;br /&gt;
&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;!--&amp;lt;/wikitalk&amp;gt;---&amp;gt;&lt;br /&gt;
===Advanced Features===&lt;br /&gt;
&amp;lt;!--&amp;lt;sectiondesc desc=&amp;lt;&amp;quot;advanced tutorial&amp;quot;&amp;gt;---&amp;gt;&lt;br /&gt;
===Spline Based Shapes===&lt;br /&gt;
&amp;lt;!--&amp;lt;indexentry &amp;quot;Shapes, spline based&amp;quot;&amp;gt;---&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;After we have gained some experience with the simpler shapes available in&lt;br /&gt;
POV-Ray it is time to go on to the more advanced, thrilling shapes.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
We should be aware that the shapes described in this and the following two chapters are not trivial to&lt;br /&gt;
understand. We need not be worried though if we do not know how to use&lt;br /&gt;
them or how they work. We just try the examples and play with the features&lt;br /&gt;
described in the reference chapter. There is nothing better than learning by&lt;br /&gt;
doing.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
You may wish to skip to the chapter &amp;amp;quot;&amp;lt;!--&amp;lt;linkto &amp;quot;Simple Texture Options&amp;quot;&amp;gt;Simple Texture Options&amp;lt;/linkto&amp;gt;---&amp;gt;[[Documentation:Tutorial Section 2.1#Simple Texture Options|Simple Texture Options]]&amp;amp;quot;&lt;br /&gt;
before proceeding with these advanced shapes.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Lathe Object===&lt;br /&gt;
&amp;lt;!--&amp;lt;indexentry &amp;quot;lathe, tutorial&amp;quot;&amp;gt;---&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;In the real world, &amp;lt;code&amp;gt;&amp;lt;!--&amp;lt;linkto &amp;quot;lathe&amp;quot;&amp;gt;lathe&amp;lt;/linkto&amp;gt;---&amp;gt;[[Documentation:Reference Section 4#Lathe|lathe]]&amp;lt;/code&amp;gt; refers to a process of making&lt;br /&gt;
patterned rounded shapes by spinning the source material in place and carving&lt;br /&gt;
pieces out as it turns. The results can be elaborate, smoothly rounded,&lt;br /&gt;
elegant looking artefacts such as table legs, pottery, etc. In POV-Ray, a&lt;br /&gt;
lathe object is used for creating much the same kind of items, although we&lt;br /&gt;
are referring to the object itself rather than the means of production.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
Here is some source for a really basic lathe.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  #include &amp;amp;quot;colors.inc&amp;amp;quot;&lt;br /&gt;
  background{White}&lt;br /&gt;
  camera {&lt;br /&gt;
    angle 10&lt;br /&gt;
    location &amp;amp;lt;1, 9, -50&amp;amp;gt;&lt;br /&gt;
    look_at &amp;amp;lt;0, 2, 0&amp;amp;gt;&lt;br /&gt;
  }&lt;br /&gt;
  light_source {&lt;br /&gt;
    &amp;amp;lt;20, 20, -20&amp;amp;gt; color White&lt;br /&gt;
  }&lt;br /&gt;
  lathe {&lt;br /&gt;
    linear_spline&lt;br /&gt;
    6,&lt;br /&gt;
    &amp;amp;lt;0,0&amp;amp;gt;, &amp;amp;lt;1,1&amp;amp;gt;, &amp;amp;lt;3,2&amp;amp;gt;, &amp;amp;lt;2,3&amp;amp;gt;, &amp;amp;lt;2,4&amp;amp;gt;, &amp;amp;lt;0,4&amp;amp;gt;&lt;br /&gt;
    pigment { Blue }&lt;br /&gt;
    finish {&lt;br /&gt;
      ambient .3&lt;br /&gt;
      phong .75&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;[[Image:TutImgLatheobj.png|A simple lathe object.]]&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;We render this, and what we see is a fairly simply type of lathe, which&lt;br /&gt;
looks like a child's top. Let's take a look at how this code produced&lt;br /&gt;
the effect.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
First, a set of six points is declared which the raytracer connects with&lt;br /&gt;
lines. We note that there are only two components in the vectors which&lt;br /&gt;
describe these points. The lines that are drawn are assumed to be in the&lt;br /&gt;
x-y-plane, therefore it is as if all the z-components were assumed to be&lt;br /&gt;
zero. The use of a two-dimensional vector is mandatory (Attempting to use a&lt;br /&gt;
3D vector would trigger an error... with one exception, which we will explore&lt;br /&gt;
later in the discussion of splines).&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
Once the lines are determined, the ray-tracer rotates this line around the&lt;br /&gt;
y-axis, and we can imagine a trail being left through space as it goes, with&lt;br /&gt;
the surface of that trail being the surface of our object.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
The specified points are connected with straight lines because we used the&lt;br /&gt;
&amp;lt;code&amp;gt;linear_spline&amp;lt;/code&amp;gt; keyword. There are other types of splines&lt;br /&gt;
available with the lathe, which will result in smooth curving lines, and even&lt;br /&gt;
rounded curving points of transition, but we will get back to that in a&lt;br /&gt;
moment.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
First, we would like to digress a moment to talk about the difference&lt;br /&gt;
between a lathe and a surface of revolution object (SOR). The SOR object,&lt;br /&gt;
described in a separate tutorial, may seem terribly similar to the lathe at&lt;br /&gt;
first glance. It too declares a series of points and connects them with&lt;br /&gt;
curving lines and then rotates them around the y-axis. The lathe has certain&lt;br /&gt;
advantages, such as different kinds of splines, linear, quadratic and cubic,&lt;br /&gt;
and one more thing:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
The simpler mathematics used by a SOR does not allow the curve to double&lt;br /&gt;
back over the same y-coordinates, thus, if using a SOR, any sudden twist&lt;br /&gt;
which cuts back down over the same heights that the curve previously covered&lt;br /&gt;
will trigger an error. For example, suppose we wanted a lathe to arc up from&lt;br /&gt;
&amp;amp;lt;0,0&amp;amp;gt; to &amp;amp;lt;2,2&amp;amp;gt;, then to dip back down to &amp;amp;lt;4,0&amp;amp;gt;. Rotated&lt;br /&gt;
around the y-axis, this would produce something like a gelatin mold - a&lt;br /&gt;
rounded semi torus, hollow in the middle. But with the SOR, as soon as the&lt;br /&gt;
curve doubled back on itself in the y-direction, it would become an illegal&lt;br /&gt;
declaration.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
Still, the SOR has one powerful strong point: because it uses simpler order&lt;br /&gt;
mathematics, it generally tends to render faster than an equivalent lathe. So&lt;br /&gt;
in the end, it is a matter of: we use a SOR if its limitations will allow, but&lt;br /&gt;
when we need a more flexible shape, we go with the lathe instead.&amp;lt;/p&amp;gt;&lt;br /&gt;
===Understanding The Concept of Splines===&lt;br /&gt;
&amp;lt;!--&amp;lt;indexentry &amp;quot;Splines, understanding the concept of&amp;quot;&amp;gt;---&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;It would be helpful, in order to understand splines, if we had a sort of&lt;br /&gt;
&amp;lt;em&amp;gt;Spline Workshop&amp;lt;/em&amp;gt; where we could practice manipulating types and&lt;br /&gt;
points of splines and see what the effects were like. So let's make one!&lt;br /&gt;
Now that we know how to create a basic lathe, it will be easy:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#include &amp;amp;quot;colors.inc&amp;amp;quot;&lt;br /&gt;
  camera {&lt;br /&gt;
    orthographic&lt;br /&gt;
    up &amp;amp;lt;0, 5, 0&amp;amp;gt;&lt;br /&gt;
    right &amp;amp;lt;5, 0, 0&amp;amp;gt;&lt;br /&gt;
    location &amp;amp;lt;2.5, 2.5, -100&amp;amp;gt;&lt;br /&gt;
    look_at &amp;amp;lt;2.5, 2.5, 0&amp;amp;gt;&lt;br /&gt;
  }&lt;br /&gt;
  /* set the control points to be used */&lt;br /&gt;
  #declare Red_Point    = &amp;amp;lt;1.00, 0.00&amp;amp;gt;;&lt;br /&gt;
  #declare Orange_Point = &amp;amp;lt;1.75, 1.00&amp;amp;gt;;&lt;br /&gt;
  #declare Yellow_Point = &amp;amp;lt;2.50, 2.00&amp;amp;gt;;&lt;br /&gt;
  #declare Green_Point  = &amp;amp;lt;2.00, 3.00&amp;amp;gt;;&lt;br /&gt;
  #declare Blue_Point   = &amp;amp;lt;1.50, 4.00&amp;amp;gt;;&lt;br /&gt;
  /* make the control points visible */&lt;br /&gt;
  cylinder { Red_Point, Red_Point - &amp;amp;lt;0,0,20&amp;amp;gt;, .1&lt;br /&gt;
    pigment { Red }&lt;br /&gt;
    finish { ambient 1 }&lt;br /&gt;
  }&lt;br /&gt;
  cylinder { Orange_Point, Orange_Point - &amp;amp;lt;0,0,20&amp;amp;gt;, .1&lt;br /&gt;
    pigment { Orange }&lt;br /&gt;
    finish { ambient 1 }&lt;br /&gt;
  }&lt;br /&gt;
  cylinder { Yellow_Point, Yellow_Point - &amp;amp;lt;0,0,20&amp;amp;gt;, .1&lt;br /&gt;
    pigment { Yellow }&lt;br /&gt;
    finish { ambient 1 }&lt;br /&gt;
  }&lt;br /&gt;
  cylinder { Green_Point, Green_Point - &amp;amp;lt;0,0,20&amp;amp;gt;, .1&lt;br /&gt;
    pigment { Green }&lt;br /&gt;
    finish { ambient 1 }&lt;br /&gt;
  }&lt;br /&gt;
  cylinder { Blue_Point, Blue_Point- &amp;amp;lt;0,0,20&amp;amp;gt;, .1&lt;br /&gt;
    pigment { Blue }&lt;br /&gt;
    finish { ambient 1 }&lt;br /&gt;
  }&lt;br /&gt;
  /* something to make the curve show up */&lt;br /&gt;
  lathe {&lt;br /&gt;
    linear_spline&lt;br /&gt;
    5,&lt;br /&gt;
    Red_Point,&lt;br /&gt;
    Orange_Point,&lt;br /&gt;
    Yellow_Point,&lt;br /&gt;
    Green_Point,&lt;br /&gt;
    Blue_Point&lt;br /&gt;
    pigment { White }&lt;br /&gt;
    finish { ambient 1 }&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&amp;lt;!--&amp;lt;img src=&amp;quot;tut_img/spline.png&amp;quot; alt=&amp;quot;A simple &amp;amp;quot;Spline Workshop&amp;amp;quot;.&amp;quot;&amp;gt;---&amp;gt;[[Image:TutImgSpline.png|A simple Spline Workshop]]&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;Now, we take a deep breath. We know that all looks a bit weird, but with&lt;br /&gt;
some simple explanations, we can easily see what all this does.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
First, we are using the orthographic camera. If we have not read up on&lt;br /&gt;
that yet, a quick summary is: it renders the scene &amp;lt;em&amp;gt;flat&amp;lt;/em&amp;gt;, eliminating&lt;br /&gt;
perspective distortion so that in a side view, the objects look like they&lt;br /&gt;
were drawn on a piece of graph paper (like in the side view of a modeler or&lt;br /&gt;
CAD package). There are several uses for this practical new type of camera,&lt;br /&gt;
but here it is allowing us to see our lathe and cylinders&amp;lt;em&amp;gt; edge on&amp;lt;/em&amp;gt;,&lt;br /&gt;
so that what we see is almost like a cross section of the curve which makes&lt;br /&gt;
the lathe, rather than the lathe itself. To further that effect, we&lt;br /&gt;
eliminated shadowing with the &amp;lt;code&amp;gt;ambient 1&amp;lt;/code&amp;gt; finish, which of course&lt;br /&gt;
also eliminates the need for lighting. We have also positioned this&lt;br /&gt;
particular side view so that &amp;amp;lt;0,0&amp;amp;gt; appears at the lower left of our&lt;br /&gt;
scene.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
Next, we declared a set of points. We note that we used 3D vectors for these&lt;br /&gt;
points rather than the 2D vectors we expect in a lathe. That is the&lt;br /&gt;
exception we mentioned earlier. When we declare a 3D point, then use it in a&lt;br /&gt;
lathe, the lathe only uses the first two components of the vector, and&lt;br /&gt;
whatever is in the third component is simply ignored. This is handy here,&lt;br /&gt;
since it makes this example possible.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
Next we do two things with the declared points. First we use them to place&lt;br /&gt;
small diameter cylinders at the locations of the points with the circular&lt;br /&gt;
caps facing the camera. Then we re-use those same vectors to determine the&lt;br /&gt;
lathe.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
Since trying to declare a 2D vector can have some odd results, and is not&lt;br /&gt;
really what our cylinder declarations need anyway, we can take advantage of&lt;br /&gt;
the lathe's tendency to ignore the third component by just setting the&lt;br /&gt;
z-coordinate in these 3D vectors to zero.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
The end result is: when we render this code, we see a white lathe against a&lt;br /&gt;
black background showing us how the curve we have declared looks, and the&lt;br /&gt;
circular ends of the cylinders show us where along the x-y-plane our control&lt;br /&gt;
points are. In this case, it is very simple. The linear spline has been&lt;br /&gt;
used so our curve is just straight lines zig-zagging between the points. We&lt;br /&gt;
change the declarations of &amp;lt;code&amp;gt;Red_Point&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;Blue_Point&amp;lt;/code&amp;gt;&lt;br /&gt;
to read as follows.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  #declare Red_Point  = &amp;amp;lt;2.00, 0.00&amp;amp;gt;;&lt;br /&gt;
  #declare Blue_Point = &amp;amp;lt;0.00, 4.00&amp;amp;gt;;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;[[Image:TutImgMvspline.png|Moving some points of the spline.]]&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;We re-render and, as we can see, all that happens is that the straight&lt;br /&gt;
line segments just move to accommodate the new position of the red and blue&lt;br /&gt;
points. Linear splines are so simple, we could manipulate them in our sleep,&lt;br /&gt;
no?&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
Let's try something different. First, we change the points to the&lt;br /&gt;
following.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  #declare Red_Point    = &amp;amp;lt;1.00, 0.00&amp;amp;gt;;&lt;br /&gt;
  #declare Orange_Point = &amp;amp;lt;2.00, 1.00&amp;amp;gt;;&lt;br /&gt;
  #declare Yellow_Point = &amp;amp;lt;3.50, 2.00&amp;amp;gt;;&lt;br /&gt;
  #declare Green_Point  = &amp;amp;lt;2.00, 3.00&amp;amp;gt;;&lt;br /&gt;
  #declare Blue_Point   = &amp;amp;lt;1.50, 4.00&amp;amp;gt;;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;[[Image:TutImgQuspline.png|A quadratic spline lathe.]]&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;We then go down to the lathe declaration and change &amp;lt;code&amp;gt;linear_spline&amp;lt;/code&amp;gt;&lt;br /&gt;
to &amp;lt;code&amp;gt;quadratic_spline&amp;lt;/code&amp;gt;. We re-render and what do we have? Well,&lt;br /&gt;
there is a couple of things worthy of note this time. First, we will see&lt;br /&gt;
that instead of straight lines we have smooth arcs connecting the points.&lt;br /&gt;
These arcs are made from quadratic curves, so our lathe looks much more&lt;br /&gt;
interesting this time. Also, &amp;lt;code&amp;gt;Red_Point&amp;lt;/code&amp;gt; is no longer connected&lt;br /&gt;
to the curve. What happened?&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
Well, while any two points can determine a straight line, it takes three to&lt;br /&gt;
determine a quadratic curve. POV-Ray looks not only to the two points to be&lt;br /&gt;
connected, but to the point immediately preceding them to determine the&lt;br /&gt;
formula of the quadratic curve that will be used to connect them. The problem&lt;br /&gt;
comes in at the beginning of the curve. Beyond the first point in the curve&lt;br /&gt;
there is no &amp;lt;em&amp;gt;previous&amp;lt;/em&amp;gt; point. So we need to declare one. Therefore,&lt;br /&gt;
when using a quadratic spline, we must remember that the first point we&lt;br /&gt;
specify is only there so that POV-Ray can determine what curve to connect the&lt;br /&gt;
first two points with. It will not show up as part of the actual curve.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
There is just one more thing about this lathe example. Even though our&lt;br /&gt;
curve is now put together with smooth curving lines, the transitions between&lt;br /&gt;
those lines is... well, kind of choppy, no? This curve looks like the lines&lt;br /&gt;
between each individual point have been terribly mismatched. Depending on&lt;br /&gt;
what we are trying to make, this could be acceptable, or, we might long for a&lt;br /&gt;
more smoothly curving shape. Fortunately, if the latter is true, we have&lt;br /&gt;
another option.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
The quadratic spline takes longer to render than a linear spline. The math&lt;br /&gt;
is more complex. Taking longer still is the cubic spline, yet for a really&lt;br /&gt;
smoothed out shape this is the only way to go. We go back into our example,&lt;br /&gt;
and simply replace &amp;lt;code&amp;gt;quadratic_spline&amp;lt;/code&amp;gt; with &amp;lt;code&amp;gt;&lt;br /&gt;
cubic_spline&amp;lt;/code&amp;gt;. We render one more&lt;br /&gt;
time, and take a look at what we have.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;[[Image:TutImgCuspline.png|A cubic spline lathe.]]&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt; While a quadratic spline takes three points to determine the curve, a&lt;br /&gt;
cubic needs four. So, as we might expect, &amp;lt;code&amp;gt;Blue_Point&amp;lt;/code&amp;gt; has now&lt;br /&gt;
dropped out of the curve, just as &amp;lt;code&amp;gt;Red_Point&amp;lt;/code&amp;gt; did, as the first&lt;br /&gt;
and last points of our curve are now only control points for shaping the&lt;br /&gt;
curves between the remaining points. But look at the transition from &amp;lt;code&amp;gt;&lt;br /&gt;
Orange_Point&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;Yellow_Point&amp;lt;/code&amp;gt; and then back to &amp;lt;code&amp;gt;&lt;br /&gt;
Green_Point&amp;lt;/code&amp;gt;. Now, rather than looking mismatched, our curve segments&lt;br /&gt;
look like one smoothly joined curve.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt; finally there is another kind of quadratic spline, the &amp;lt;code&amp;gt;bezier_spline&amp;lt;/code&amp;gt;. &lt;br /&gt;
This one takes four points per section. The start point, the end points and in between, &lt;br /&gt;
two control points. To use it, we will have to make a few changes to our work shop. &lt;br /&gt;
Delete the Yellow point, delete the Yellow cylinder. Change the points to:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  #declare Red_Point    = &amp;amp;lt;2.00, 1.00&amp;amp;gt;;&lt;br /&gt;
  #declare Orange_Point = &amp;amp;lt;3.00, 1.50&amp;amp;gt;;&lt;br /&gt;
  #declare Green_Point  = &amp;amp;lt;3.00, 3.50&amp;amp;gt;;&lt;br /&gt;
  #declare Blue_Point   = &amp;amp;lt;2.00, 4.00&amp;amp;gt;;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;And change the lathe to:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  lathe {&lt;br /&gt;
    bezier_spline&lt;br /&gt;
    4,&lt;br /&gt;
    Red_Point,&lt;br /&gt;
    Orange_Point,&lt;br /&gt;
    Green_Point,&lt;br /&gt;
    Blue_Point&lt;br /&gt;
    pigment { White }&lt;br /&gt;
    finish { ambient 1 }&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt; The, green and orange, control points are not connected to the curve. Move them around a bit,&lt;br /&gt;
for example &amp;lt;code&amp;gt;#declare Orange_Point = &amp;amp;lt;1.00, 1.50&amp;amp;gt;;&amp;lt;/code&amp;gt;. The line that can be drawn&lt;br /&gt;
from the start point to its closest control point (red to orange) shows the tangent of the curve&lt;br /&gt;
at the start point. Same for the end point, blue to green.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;[[Image:TutImgBezspline1.png|a bezier_spline lathe]]&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt; One spline segment is nice, two is nicer. So we will add another segment and connect it to the&lt;br /&gt;
blue point. One segment has four points, so two segments have eight. The first point of the second&lt;br /&gt;
segment is the same as the last point of the first segment. The blue point. So we only have to&lt;br /&gt;
declare three more points. Also we have to move the camera a bit and add more cylinders. Here is&lt;br /&gt;
the complete scene again:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#include &amp;amp;quot;colors.inc&amp;amp;quot;&lt;br /&gt;
  camera {&lt;br /&gt;
    orthographic&lt;br /&gt;
    up &amp;amp;lt;0, 7, 0&amp;amp;gt;&lt;br /&gt;
    right &amp;amp;lt;7, 0, 0&amp;amp;gt;&lt;br /&gt;
    location &amp;amp;lt;3.5, 4, -100&amp;amp;gt;&lt;br /&gt;
    look_at &amp;amp;lt;3.5, 4, 0&amp;amp;gt;&lt;br /&gt;
  }&lt;br /&gt;
  /* set the control points to be used */&lt;br /&gt;
  #declare Red_Point    = &amp;amp;lt;2.00, 1.00&amp;amp;gt;;&lt;br /&gt;
  #declare Orange_Point = &amp;amp;lt;1.00, 1.50&amp;amp;gt;;&lt;br /&gt;
  #declare Green_Point  = &amp;amp;lt;3.00, 3.50&amp;amp;gt;;&lt;br /&gt;
  #declare Blue_Point   = &amp;amp;lt;2.00, 4.00&amp;amp;gt;;&lt;br /&gt;
  #declare Green_Point2 = &amp;amp;lt;3.00, 4.50&amp;amp;gt;;&lt;br /&gt;
  #declare Orange_Point2= &amp;amp;lt;1.00, 6.50&amp;amp;gt;;&lt;br /&gt;
  #declare Red_Point2   = &amp;amp;lt;2.00, 7.00&amp;amp;gt;;&lt;br /&gt;
  /* make the control points visible */&lt;br /&gt;
&lt;br /&gt;
  cylinder { Red_Point, Red_Point - &amp;amp;lt;0,0,20&amp;amp;gt;, .1&lt;br /&gt;
    pigment { Red } finish { ambient 1 }&lt;br /&gt;
  }&lt;br /&gt;
  cylinder { Orange_Point, Orange_Point - &amp;amp;lt;0,0,20&amp;amp;gt;, .1&lt;br /&gt;
    pigment { Orange } finish { ambient 1 }&lt;br /&gt;
  }&lt;br /&gt;
  cylinder { Green_Point, Green_Point - &amp;amp;lt;0,0,20&amp;amp;gt;, .1&lt;br /&gt;
    pigment { Green } finish { ambient 1 }&lt;br /&gt;
  }&lt;br /&gt;
  cylinder { Blue_Point, Blue_Point- &amp;amp;lt;0,0,20&amp;amp;gt;, .1&lt;br /&gt;
    pigment { Blue } finish { ambient 1 }&lt;br /&gt;
  }&lt;br /&gt;
  cylinder { Green_Point2, Green_Point2 - &amp;amp;lt;0,0,20&amp;amp;gt;, .1&lt;br /&gt;
    pigment { Green } finish { ambient 1 }&lt;br /&gt;
  }&lt;br /&gt;
  cylinder { Orange_Point2, Orange_Point2 - &amp;amp;lt;0,0,20&amp;amp;gt;, .1&lt;br /&gt;
    pigment { Orange } finish { ambient 1 }&lt;br /&gt;
  }&lt;br /&gt;
  cylinder { Red_Point2, Red_Point2 - &amp;amp;lt;0,0,20&amp;amp;gt;, .1&lt;br /&gt;
    pigment { Red } finish { ambient 1 }&lt;br /&gt;
  }  &lt;br /&gt;
  /* something to make the curve show up */&lt;br /&gt;
  lathe {&lt;br /&gt;
    bezier_spline&lt;br /&gt;
    8,&lt;br /&gt;
    Red_Point, Orange_Point, Green_Point, Blue_Point&lt;br /&gt;
    Blue_Point, Green_Point2, Orange_Point2, Red_Point2&lt;br /&gt;
    pigment { White }&lt;br /&gt;
    finish { ambient 1 }&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;[[Image:TutImgBezspline2.png|two bezier_spline segments, not smooth]]&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
A nice curve, but what if we want a smooth curve? Let us have a look at the tangents&lt;br /&gt;
on the Blue_point, draw the lines Green_Point, Blue_point and Green_Point2, Blue_point.&lt;br /&gt;
Look at the angle they make, it is as sharp as the dent in the curve. What if we make&lt;br /&gt;
the angle bigger? What if we make the angle 180°? Try a few positions for Green_point2&lt;br /&gt;
and end with &amp;lt;code&amp;gt;#declare Green_Point2 = &amp;amp;lt;1.00, 4.50&amp;amp;gt;;&amp;lt;/code&amp;gt;. A smooth curve.&lt;br /&gt;
If we make sure that the two control points and the connection point are on one line,&lt;br /&gt;
the curve is perfectly smooth. In general this can be achieved by &lt;br /&gt;
&amp;lt;code&amp;gt;#declare Green_Point2 = Blue_Point+(Blue_Point-Green_Point);&amp;lt;/code&amp;gt;&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;[[Image:TutImgBezspline3.png|smooth bezier_spline lathe]]&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt; The concept of splines is a handy and necessary one, which will be seen&lt;br /&gt;
again in the prism and polygon objects. But with a little tinkering we can&lt;br /&gt;
quickly get a feel for working with them.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Surface of Revolution Object===&lt;br /&gt;
&amp;lt;!--&amp;lt;indexentry &amp;quot;sor, tutorial&amp;quot;&amp;gt;---&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;Bottles, vases and glasses make nice objects in ray-traced scenes. We want&lt;br /&gt;
to create a golden cup using the &amp;lt;em&amp;gt;surface of revolution&amp;lt;/em&amp;gt; object (SOR&lt;br /&gt;
object).&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
We first start by thinking about the shape of the final object. It is quite&lt;br /&gt;
difficult to come up with a set of points that describe a given curve without&lt;br /&gt;
the help of a modeling program supporting POV-Ray's surface of revolution&lt;br /&gt;
object. If such a program is available we should take advantage of it.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;[[Image:TutImgPtcubobj.gif|The point configuration of our cup object.]]&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;We will use the point configuration shown in the figure above. There are&lt;br /&gt;
eight points describing the curve that will be rotated about the y-axis to&lt;br /&gt;
get our cup. The curve was calculated using the method described in the&lt;br /&gt;
reference section (see &amp;amp;quot;&amp;lt;!--&amp;lt;linkto &amp;quot;Surface of Revolution&amp;quot;&amp;gt;Surface of Revolution&amp;lt;/linkto&amp;gt;---&amp;gt;[[Documentation:Reference Section 4.1#Surface of Revolution|Surface of Revolution]]&amp;amp;quot;).&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
Now it is time to come up with a scene that uses the above SOR object. We&lt;br /&gt;
create a file called &amp;lt;code&amp;gt;sordemo.pov&amp;lt;/code&amp;gt; and enter the following text.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  #include &amp;amp;quot;colors.inc&amp;amp;quot;&lt;br /&gt;
  #include &amp;amp;quot;golds.inc&amp;amp;quot;&lt;br /&gt;
  camera {&lt;br /&gt;
    location &amp;amp;lt;10, 15, -20&amp;amp;gt;&lt;br /&gt;
    look_at &amp;amp;lt;0, 5, 0&amp;amp;gt;&lt;br /&gt;
    angle 45&lt;br /&gt;
  }&lt;br /&gt;
  background { color rgb&amp;amp;lt;0.2, 0.4, 0.8&amp;amp;gt;  }&lt;br /&gt;
  light_source { &amp;amp;lt;100, 100, -100&amp;amp;gt; color rgb 1 }&lt;br /&gt;
  plane {&lt;br /&gt;
    y, 0&lt;br /&gt;
    pigment { checker color Red, color Green scale 10 }&lt;br /&gt;
  }&lt;br /&gt;
  sor {&lt;br /&gt;
    8,&lt;br /&gt;
    &amp;amp;lt;0.0,  -0.5&amp;amp;gt;,&lt;br /&gt;
    &amp;amp;lt;3.0,   0.0&amp;amp;gt;,&lt;br /&gt;
    &amp;amp;lt;1.0,   0.2&amp;amp;gt;,&lt;br /&gt;
    &amp;amp;lt;0.5,   0.4&amp;amp;gt;,&lt;br /&gt;
    &amp;amp;lt;0.5,   4.0&amp;amp;gt;,&lt;br /&gt;
    &amp;amp;lt;1.0,   5.0&amp;amp;gt;,&lt;br /&gt;
    &amp;amp;lt;3.0,  10.0&amp;amp;gt;,&lt;br /&gt;
    &amp;amp;lt;4.0,  11.0&amp;amp;gt;&lt;br /&gt;
    open&lt;br /&gt;
    texture { T_Gold_1B }&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;The scene contains our cup object resting on a checkered plane. Tracing&lt;br /&gt;
this scene results in the image below.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;[[Image:TutImgSorobj.png|A surface of revolution object.]]&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;The surface of revolution is described by starting with the number of&lt;br /&gt;
points followed by the points. Points from second to last but one are listed&lt;br /&gt;
with ascending heights. Each of them determines the radius of the curve for&lt;br /&gt;
a given height. E. g. the first valid point (second listed) tells POV-Ray&lt;br /&gt;
that at height 0.0 the radius is 3. We should take care that each point has&lt;br /&gt;
a larger height than its predecessor. If this is not the case the program&lt;br /&gt;
will abort with an error message. First and last point from the list are&lt;br /&gt;
used to determine slope at beginning and end of curve and can be defined for&lt;br /&gt;
any height.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Prism Object===&lt;br /&gt;
&amp;lt;!--&amp;lt;indexentry &amp;quot;prism, tutorial&amp;quot;&amp;gt;---&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;The prism is essentially a polygon or closed curve which is swept along a&lt;br /&gt;
linear path. We can imagine the shape so swept leaving a trail in space, and&lt;br /&gt;
the surface of that trail is the surface of our prism. The curve or polygon&lt;br /&gt;
making up a prism's face can be a composite of any number of sub-shapes,&lt;br /&gt;
can use any kind of three different splines, and can either keep a constant&lt;br /&gt;
width as it is swept, or slowly tapering off to a fine point on one end. But&lt;br /&gt;
before this gets too confusing, let's start one step at a time with the&lt;br /&gt;
simplest form of prism. We enter and render the following POV code (see file&lt;br /&gt;
&amp;lt;code&amp;gt;prismdm1.pov&amp;lt;/code&amp;gt;).&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  #include &amp;amp;quot;colors.inc&amp;amp;quot;&lt;br /&gt;
  background{White}&lt;br /&gt;
  camera {&lt;br /&gt;
    angle 20&lt;br /&gt;
    location &amp;amp;lt;2, 10, -30&amp;amp;gt;&lt;br /&gt;
    look_at &amp;amp;lt;0, 1, 0&amp;amp;gt;&lt;br /&gt;
  }&lt;br /&gt;
  light_source { &amp;amp;lt;20, 20, -20&amp;amp;gt; color White }&lt;br /&gt;
  prism {&lt;br /&gt;
    linear_sweep&lt;br /&gt;
    linear_spline&lt;br /&gt;
    0, // sweep the following shape from here ...&lt;br /&gt;
    1, // ... up through here&lt;br /&gt;
    7, // the number of points making up the shape ...&lt;br /&gt;
    &amp;amp;lt;3,5&amp;amp;gt;, &amp;amp;lt;-3,5&amp;amp;gt;, &amp;amp;lt;-5,0&amp;amp;gt;, &amp;amp;lt;-3,-5&amp;amp;gt;, &amp;amp;lt;3, -5&amp;amp;gt;, &amp;amp;lt;5,0&amp;amp;gt;, &amp;amp;lt;3,5&amp;amp;gt;&lt;br /&gt;
    pigment { Green }&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;[[Image:TutImgHexprism.png|A hexagonal prism shape.]]&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;This produces a hexagonal polygon, which is then swept from y=0 through&lt;br /&gt;
y=1. In other words, we now have an extruded hexagon. One point to note is&lt;br /&gt;
that although this is a six sided figure, we have used a total of seven&lt;br /&gt;
points. That is because the polygon is supposed to be a closed shape, which&lt;br /&gt;
we do here by making the final point the same as the first. Technically, with&lt;br /&gt;
linear polygons, if we did not do this, POV-Ray would automatically join&lt;br /&gt;
the two ends with a line to force it to close, although a warning would be&lt;br /&gt;
issued. However, this only works with linear splines, so we must not get&lt;br /&gt;
too casual about those warning messages!&amp;lt;/p&amp;gt;&lt;br /&gt;
===Teaching An Old Spline New Tricks===&lt;br /&gt;
&amp;lt;!--&amp;lt;indexentry &amp;quot;Spline, new tricks&amp;quot; &amp;quot;cubic_spline, tutorial&amp;quot;&amp;gt;---&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;If we followed the section on splines covered under the lathe tutorial&lt;br /&gt;
(see section &amp;amp;quot;&amp;lt;!--&amp;lt;linkto &amp;quot;Understanding The Concept of Splines&amp;quot;&amp;gt;Understanding The Concept of Splines&amp;lt;/linkto&amp;gt;---&amp;gt;[[Documentation:Tutorial Section 3#Understanding The Concept of Splines|Understanding The Concept of Splines]]&amp;amp;quot;), we know that&lt;br /&gt;
there are two additional kinds of splines besides linear: the quadratic and&lt;br /&gt;
the cubic spline. Sure enough, we can use these with prisms to make a more&lt;br /&gt;
free form, smoothly curving type of prism.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
There is just one catch, and we should read this section carefully to keep&lt;br /&gt;
from tearing our hair out over mysterious &amp;amp;quot;too few points in prism&amp;amp;quot;&lt;br /&gt;
messages which keep our prism from rendering. We can probably guess where&lt;br /&gt;
this is heading: how to close a non-linear spline. Unlike the linear spline,&lt;br /&gt;
which simply draws a line between the last and first points if we forget to&lt;br /&gt;
make the last point equal to the first, quadratic and cubic splines are a&lt;br /&gt;
little more fussy.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
First of all, we remember that quadratic splines determine the equation of&lt;br /&gt;
the curve which connects any two points based on those two points and the&lt;br /&gt;
previous point, so the first point in any quadratic spline is just &amp;lt;em&amp;gt;&lt;br /&gt;
control point&amp;lt;/em&amp;gt; and will not actually be part of the curve. What this&lt;br /&gt;
means is: when we make our shape out of a quadratic spline, we must match the&lt;br /&gt;
second point to the last, since the first point is not on the curve -&lt;br /&gt;
it is just a control point needed for computational purposes.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
Likewise, cubic splines need both the first and last points to be control&lt;br /&gt;
points, therefore, to close a shape made with a cubic spline, we must match&lt;br /&gt;
the second point to the second from last point. If we do not match the&lt;br /&gt;
correct points on a quadratic or cubic shape, that is when we will get the&lt;br /&gt;
&amp;amp;quot;too few points in prism&amp;amp;quot; error. POV-Ray is still waiting for us to&lt;br /&gt;
close the shape, and when it runs out of points without seeing the closure,&lt;br /&gt;
an error is issued.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
Confused? Okay, how about an example? We replace the prism in our last bit&lt;br /&gt;
of code with this one (see file &amp;lt;code&amp;gt;prismdm2.pov&amp;lt;/code&amp;gt;).&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  prism {&lt;br /&gt;
    cubic_spline&lt;br /&gt;
    0, // sweep the following shape from here ...&lt;br /&gt;
    1, // ... up through here&lt;br /&gt;
    6, // the number of points making up the shape ...&lt;br /&gt;
    &amp;amp;lt; 3, -5&amp;amp;gt;, // point#1 (control point... not on curve)&lt;br /&gt;
    &amp;amp;lt; 3,  5&amp;amp;gt;, // point#2  ... THIS POINT ...&lt;br /&gt;
    &amp;amp;lt;-5,  0&amp;amp;gt;, // point#3&lt;br /&gt;
    &amp;amp;lt; 3, -5&amp;amp;gt;, // point#4&lt;br /&gt;
    &amp;amp;lt; 3,  5&amp;amp;gt;, // point#5 ... MUST MATCH THIS POINT&lt;br /&gt;
    &amp;amp;lt;-5,  0&amp;amp;gt;  // point#6 (control point... not on curve)&lt;br /&gt;
    pigment { Green }&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;[[Image:TutImgCubprism.png|A cubic, triangular prism shape.]]&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;This simple prism produces what looks like an extruded triangle with its&lt;br /&gt;
corners sanded smoothly off. Points two, three and four are the corners of&lt;br /&gt;
the triangle and point five closes the shape by returning to the location of&lt;br /&gt;
point two. As for points one and six, they are our control points, and&lt;br /&gt;
are not part of the shape - they are just there to help compute what&lt;br /&gt;
curves to use between the other points.&amp;lt;/p&amp;gt;&lt;br /&gt;
===Smooth Transitions===&lt;br /&gt;
&amp;lt;p&amp;gt;Now a handy thing to note is that we have made point one equal point four,&lt;br /&gt;
and also point six equals point three. Yes, this is important. Although this&lt;br /&gt;
prism would still be legally closed if the control points were not what&lt;br /&gt;
we have made them, the curve transitions between points would not be as&lt;br /&gt;
smooth. We change points one and six to &amp;amp;lt;4,6&amp;amp;gt; and &amp;amp;lt;0,7&amp;amp;gt;&lt;br /&gt;
respectively and re-render to see how the back edge of the shape is altered&lt;br /&gt;
(see file &amp;lt;code&amp;gt;prismdm3.pov&amp;lt;/code&amp;gt;).&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
To put this more generally, if we want a smooth closure on a cubic spline,&lt;br /&gt;
we make the first control point equal to the third from last point, and the&lt;br /&gt;
last control point equal to the third point. On a quadratic spline, the trick&lt;br /&gt;
is similar, but since only the first point is a control point, make that&lt;br /&gt;
equal to the second from last point.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Multiple Sub-Shapes===&lt;br /&gt;
&amp;lt;p&amp;gt;Just as with the polygon object (see section&lt;br /&gt;
&amp;amp;quot;&amp;lt;!--&amp;lt;linkto &amp;quot;Polygon Object&amp;quot;&amp;gt;Polygon Object&amp;lt;/linkto&amp;gt;---&amp;gt;[[Documentation:Tutorial Section 3.1#Polygon Object|Polygon Object]]&amp;amp;quot;)&lt;br /&gt;
the prism is very flexible, and allows us to make one prism out of several&lt;br /&gt;
sub-prisms. To do this, all we need to do is keep listing points after we&lt;br /&gt;
have already closed the first shape. The second shape can be simply an add on&lt;br /&gt;
going off in another direction from the first, but one of the more&lt;br /&gt;
interesting features is that if any even number of sub-shapes overlap, that&lt;br /&gt;
region where they overlap behaves as though it has been cut away from both&lt;br /&gt;
sub-shapes. Let's look at another example. Once again, same basic code as&lt;br /&gt;
before for camera, light and so forth, but we substitute this complex prism&lt;br /&gt;
(see file &amp;lt;code&amp;gt;prismdm4.pov&amp;lt;/code&amp;gt;).&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  prism {&lt;br /&gt;
    linear_sweep&lt;br /&gt;
    cubic_spline&lt;br /&gt;
    0,  // sweep the following shape from here ...&lt;br /&gt;
    1,  // ... up through here&lt;br /&gt;
    18, // the number of points making up the shape ...&lt;br /&gt;
    &amp;amp;lt;3,-5&amp;amp;gt;, &amp;amp;lt;3,5&amp;amp;gt;, &amp;amp;lt;-5,0&amp;amp;gt;, &amp;amp;lt;3, -5&amp;amp;gt;, &amp;amp;lt;3,5&amp;amp;gt;, &amp;amp;lt;-5,0&amp;amp;gt;,//sub-shape #1&lt;br /&gt;
    &amp;amp;lt;2,-4&amp;amp;gt;, &amp;amp;lt;2,4&amp;amp;gt;, &amp;amp;lt;-4,0&amp;amp;gt;, &amp;amp;lt;2,-4&amp;amp;gt;, &amp;amp;lt;2,4&amp;amp;gt;, &amp;amp;lt;-4,0&amp;amp;gt;, //sub-shape #2&lt;br /&gt;
    &amp;amp;lt;1,-3&amp;amp;gt;, &amp;amp;lt;1,3&amp;amp;gt;, &amp;amp;lt;-3,0&amp;amp;gt;, &amp;amp;lt;1, -3&amp;amp;gt;, &amp;amp;lt;1,3&amp;amp;gt;, &amp;amp;lt;-3,0&amp;amp;gt; //sub-shape #3&lt;br /&gt;
    pigment { Green }&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;[[Image:TutImgSubshape.png|Using sub-shapes to create a more complex shape.]]&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;For readability purposes, we have started a new line every time we moved&lt;br /&gt;
on to a new sub-shape, but the ray-tracer of course tells where each shape&lt;br /&gt;
ends based on whether the shape has been closed (as described earlier). We&lt;br /&gt;
render this new prism, and look what we have got. It is the same&lt;br /&gt;
familiar shape, but it now looks like a smaller version of the shape has been&lt;br /&gt;
carved out of the center, then the carved piece was sanded down even smaller&lt;br /&gt;
and set back in the hole.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
Simply, the outer rim is where only sub-shape one exists, then the carved&lt;br /&gt;
out part is where sub-shapes one and two overlap. In the extreme center, the&lt;br /&gt;
object reappears because sub-shapes one, two, and three overlap, returning us&lt;br /&gt;
to an odd number of overlapping pieces. Using this technique we could make&lt;br /&gt;
any number of extremely complex prism shapes!&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Conic Sweeps And The Tapering Effect===&lt;br /&gt;
&amp;lt;!--&amp;lt;indexentry &amp;quot;Tapering Conic Sweeps&amp;quot;&amp;gt;---&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;In our original prism, the keyword &amp;lt;code&amp;gt;linear_sweep&amp;lt;/code&amp;gt; is actually&lt;br /&gt;
optional. This is the default sweep assumed for a prism if no type of sweep&lt;br /&gt;
is specified. But there is another, extremely useful kind of sweep: the conic&lt;br /&gt;
sweep. The basic idea is like the original prism, except that while we are&lt;br /&gt;
sweeping the shape from the first height through the second height, we are&lt;br /&gt;
constantly expanding it from a single point until, at the second height, the&lt;br /&gt;
shape has expanded to the original points we made it from. To give a small&lt;br /&gt;
idea of what such effects are good for, we replace our existing prism with&lt;br /&gt;
this (see file &amp;lt;code&amp;gt;prismdm4.pov&amp;lt;/code&amp;gt;):&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  prism {&lt;br /&gt;
    conic_sweep&lt;br /&gt;
    linear_spline&lt;br /&gt;
    0, // height 1&lt;br /&gt;
    1, // height 2&lt;br /&gt;
    5, // the number of points making up the shape...&lt;br /&gt;
    &amp;amp;lt;4,4&amp;amp;gt;,&amp;amp;lt;-4,4&amp;amp;gt;,&amp;amp;lt;-4,-4&amp;amp;gt;,&amp;amp;lt;4,-4&amp;amp;gt;,&amp;amp;lt;4,4&amp;amp;gt;&lt;br /&gt;
    rotate &amp;amp;lt;180, 0, 0&amp;amp;gt;&lt;br /&gt;
    translate &amp;amp;lt;0, 1, 0&amp;amp;gt;&lt;br /&gt;
    scale &amp;amp;lt;1, 4, 1&amp;amp;gt;&lt;br /&gt;
    pigment { gradient y scale .2 }&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;[[Image:TutImgPyrsweep.png|Creating a pyramid using conic sweeping.]]&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;The gradient pigment was selected to give some definition to our object&lt;br /&gt;
without having to fix the lights and the camera angle right at this moment,&lt;br /&gt;
but when we render it, what have we created? A horizontally striped&lt;br /&gt;
pyramid! By now we can recognize the linear spline connecting the four points&lt;br /&gt;
of a square, and the familiar final point which is there to close the&lt;br /&gt;
spline.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
Notice all the transformations in the object declaration. That is going&lt;br /&gt;
to take a little explanation. The rotate and translate are easy. Normally, a&lt;br /&gt;
conic sweep starts full sized at the top, and tapers to a point at y=0, but&lt;br /&gt;
of course that would be upside down if we are making a pyramid. So we flip&lt;br /&gt;
the shape around the x-axis to put it right side up, then since we actually&lt;br /&gt;
orbited around the point, we translate back up to put it in the same position&lt;br /&gt;
it was in when we started.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
The scale is to put the proportions right for this example. The base is&lt;br /&gt;
eight units by eight units, but the height (from y=1 to y=0) is only one&lt;br /&gt;
unit, so we have stretched it out a little. At this point, we are&lt;br /&gt;
probably thinking, &amp;amp;quot;why not just sweep up from y=0 to y=4 and avoid this&lt;br /&gt;
whole scaling thing?&amp;amp;quot;&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
That is a very important gotcha! with conic sweeps. To see what is wrong&lt;br /&gt;
with that, let's try and put it into practice (see file &amp;lt;code&amp;gt;&lt;br /&gt;
prismdm5.pov&amp;lt;/code&amp;gt;). We must make sure to remove the scale statement, and&lt;br /&gt;
then replace the line which reads&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  1, // height 2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;with&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  4, // height 2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;This sets the second height at y=4, so let's re-render and see if the&lt;br /&gt;
effect is the same.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;[[Image:TutImgImprswep.png|Choosing a second height larger than one for the conic sweep.]]&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;Whoa! Our height is correct, but our pyramid's base is now huge! What&lt;br /&gt;
went wrong here? Simple. The base, as we described it with the points we used&lt;br /&gt;
actually occurs at y=1 no matter what we set the second height for. But if we&lt;br /&gt;
do set the second height higher than one, once the sweep passes y=1, it keeps&lt;br /&gt;
expanding outward along the same lines as it followed to our original base,&lt;br /&gt;
making the actual base bigger and bigger as it goes.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
To avoid losing control of a conic sweep prism, it is usually best to let&lt;br /&gt;
the second height stay at y=1, and use a scale statement to adjust the height&lt;br /&gt;
from its unit size. This way we can always be sure the base's corners&lt;br /&gt;
remain where we think they are.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
That leads to one more interesting thing about conic sweeps. What if we for&lt;br /&gt;
some reason do not want them to taper all the way to a point? What if&lt;br /&gt;
instead of a complete pyramid, we want more of a ziggurat step? Easily done.&lt;br /&gt;
After putting the second height back to one, and replacing our scale&lt;br /&gt;
statement, we change the line which reads&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  0, // height 1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;to&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  0.251, // height 1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;[[Image:TutImgSweepinc.png|Increasing the first height for the conic sweep.]]&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;When we re-render, we see that the sweep stops short of going all the way&lt;br /&gt;
to its point, giving us a pyramid without a cap. Exactly how much of the cap&lt;br /&gt;
is cut off depends on how close the first height is to the second height.&amp;lt;/p&amp;gt;&lt;br /&gt;
===Sphere Sweep Object===&lt;br /&gt;
&amp;lt;!--&amp;lt;indexentry &amp;quot;sphere_sweep, tutorial&amp;quot;&amp;gt;---&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;A Sphere Sweep Object is the space a sphere occupies during its movement along a spline.&lt;br /&gt;
&amp;lt;br&amp;gt;So we need to specify the kind of spline we want and a list of control points to define&lt;br /&gt;
that spline. To help POV-Ray we tell how many control points will be used. In addition, we also&lt;br /&gt;
define the radius the moving sphere should have when passing through each of these control&lt;br /&gt;
points.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;The syntax of the sphere_sweep object is:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  sphere_sweep {&lt;br /&gt;
    linear_spline | b_spline | cubic_spline&lt;br /&gt;
    NUM_OF_SPHERES,&lt;br /&gt;
&lt;br /&gt;
    CENTER, RADIUS,&lt;br /&gt;
    CENTER, RADIUS,&lt;br /&gt;
    ...&lt;br /&gt;
    CENTER, RADIUS&lt;br /&gt;
    [tolerance DEPTH_TOLERANCE]&lt;br /&gt;
    [OBJECT_MODIFIERS]&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;An example for a linear Sphere Sweep would be:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  sphere_sweep {&lt;br /&gt;
    linear_spline&lt;br /&gt;
    4,&lt;br /&gt;
    &amp;amp;lt;-5, -5, 0&amp;amp;gt;, 1&lt;br /&gt;
    &amp;amp;lt;-5,  5, 0&amp;amp;gt;, 1&lt;br /&gt;
    &amp;amp;lt; 5, -5, 0&amp;amp;gt;, 1&lt;br /&gt;
    &amp;amp;lt; 5,  5, 0&amp;amp;gt;, 1&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;This object is described by four spheres. You can use as many spheres as you like to&lt;br /&gt;
describe the object, but you will need at least two spheres for a linear Sphere Sweep, and&lt;br /&gt;
four spheres for one approximated with a cubic_spline or b_spline.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;The example above would result in an object shaped like the letter &amp;amp;quot;N&amp;amp;quot;. The&lt;br /&gt;
sphere sweep goes through &amp;lt;em&amp;gt;all&amp;lt;/em&amp;gt; points which are connected with straight&lt;br /&gt;
cones.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;Changing the kind of interpolation to a cubic_spline produces a quite different,&lt;br /&gt;
slightly bent, object. It then starts at the second sphere and ends at the last but one. Since&lt;br /&gt;
the first and last points are used to control the spline, you need two more points to get a&lt;br /&gt;
shape that can be compared to the linear sweep. Let's add them:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  sphere_sweep {&lt;br /&gt;
    cubic_spline&lt;br /&gt;
    6,&lt;br /&gt;
    &amp;amp;lt;-4, -5, 0&amp;amp;gt;, 1&lt;br /&gt;
    &amp;amp;lt;-5, -5, 0&amp;amp;gt;, 1&lt;br /&gt;
    &amp;amp;lt;-5,  5, 0&amp;amp;gt;, 0.5&lt;br /&gt;
    &amp;amp;lt; 5, -5, 0&amp;amp;gt;, 0.5&lt;br /&gt;
    &amp;amp;lt; 5,  5, 0&amp;amp;gt;, 1&lt;br /&gt;
    &amp;amp;lt; 4,  5, 0&amp;amp;gt;, 1&lt;br /&gt;
    tolerance 0.1&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;So the cubic sweep creates a smooth sphere sweep actually going through&lt;br /&gt;
all points (except the first and last one). In this example the radius of the second and third&lt;br /&gt;
spheres have been changed. We also added the &amp;amp;quot;tolerance&amp;amp;quot; keyword, because&lt;br /&gt;
dark spots appeared on the surface with the default value (0.000001).&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;When using a b_spline, the resulting object is somewhat similar to the cubic&lt;br /&gt;
sweep, but does not actually go through the control points. It lies somewhere between them.&amp;lt;/p&amp;gt;&lt;br /&gt;
===Bicubic Patch Object===&lt;br /&gt;
&amp;lt;!--&amp;lt;indexentry &amp;quot;bicubic_patch, tutorial&amp;quot;&amp;gt;---&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
Bicubic patches are useful surface representations because they allow an easy definition&lt;br /&gt;
of surfaces using only a few control points. The control points serve to determine the shape&lt;br /&gt;
of the patch. Instead of defining the vertices of triangles, we simply give the coordinates&lt;br /&gt;
of the control points. A single patch has 16 control points, one at each corner, and the rest&lt;br /&gt;
positioned to divide the patch into smaller sections. POV-Ray does not ray trace the patches&lt;br /&gt;
directly, they are approximated using triangles as described in the&lt;br /&gt;
&amp;lt;!--&amp;lt;linkto &amp;quot;bezier&amp;quot;&amp;gt;Scene Description Language&amp;lt;/linkto&amp;gt;---&amp;gt;[[Documentation:Reference Section 4.1#Bicubic Patch|Scene Description Language]] section.&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
Bicubic patches are almost always created by using a third party modeler, but for this tutorial&lt;br /&gt;
we will manipulate them by hand. Modelers that support Bicubic patches and export to POV-Ray&lt;br /&gt;
can be found in the [http://www.povray.org/links/ links collection on our server]&amp;lt;br&amp;gt;&lt;br /&gt;
Let's set up a basic scene and start exploring the Bicubic patch.&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#version 3.5;&lt;br /&gt;
global_settings {assumed_gamma 1.0}&lt;br /&gt;
background {rgb &amp;amp;lt;1,0.9,0.9&amp;amp;gt;}&lt;br /&gt;
camera {location &amp;amp;lt;1.6,5,-6&amp;amp;gt; look_at &amp;amp;lt;1.5,0,1.5&amp;amp;gt; angle 40}&lt;br /&gt;
light_source {&amp;amp;lt;500,500,-500&amp;amp;gt; rgb 1 }&lt;br /&gt;
&lt;br /&gt;
#declare B11=&amp;amp;lt;0,0,3&amp;amp;gt;; #declare B12=&amp;amp;lt;1,0,3&amp;amp;gt;; //&lt;br /&gt;
#declare B13=&amp;amp;lt;2,0,3&amp;amp;gt;; #declare B14=&amp;amp;lt;3,0,3&amp;amp;gt;; // row 1&lt;br /&gt;
&lt;br /&gt;
#declare B21=&amp;amp;lt;0,0,2&amp;amp;gt;; #declare B22=&amp;amp;lt;1,0,2&amp;amp;gt;; //&lt;br /&gt;
#declare B23=&amp;amp;lt;2,0,2&amp;amp;gt;; #declare B24=&amp;amp;lt;3,0,2&amp;amp;gt;; // row 2&lt;br /&gt;
&lt;br /&gt;
#declare B31=&amp;amp;lt;0,0,1&amp;amp;gt;; #declare B32=&amp;amp;lt;1,0,1&amp;amp;gt;; //&lt;br /&gt;
#declare B33=&amp;amp;lt;2,0,1&amp;amp;gt;; #declare B34=&amp;amp;lt;3,0,1&amp;amp;gt;; // row 3&lt;br /&gt;
&lt;br /&gt;
#declare B41=&amp;amp;lt;0,0,0&amp;amp;gt;; #declare B42=&amp;amp;lt;1,0,0&amp;amp;gt;; //&lt;br /&gt;
#declare B43=&amp;amp;lt;2,0,0&amp;amp;gt;; #declare B44=&amp;amp;lt;3,0,0&amp;amp;gt;; // row 4&lt;br /&gt;
&lt;br /&gt;
bicubic_patch {&lt;br /&gt;
   type 1 flatness 0.001&lt;br /&gt;
   u_steps 4 v_steps 4&lt;br /&gt;
   uv_vectors&lt;br /&gt;
   &amp;amp;lt;0,0&amp;amp;gt; &amp;amp;lt;1,0&amp;amp;gt; &amp;amp;lt;1,1&amp;amp;gt; &amp;amp;lt;0,1&amp;amp;gt;&lt;br /&gt;
   B11, B12, B13, B14&lt;br /&gt;
   B21, B22, B23, B24&lt;br /&gt;
   B31, B32, B33, B34&lt;br /&gt;
   B41, B42, B43, B44&lt;br /&gt;
   uv_mapping&lt;br /&gt;
   texture {&lt;br /&gt;
      pigment {&lt;br /&gt;
         checker &lt;br /&gt;
         color rgbf &amp;amp;lt;1,1,1,0.5&amp;amp;gt; &lt;br /&gt;
         color rgbf &amp;amp;lt;0,0,1,0.7&amp;amp;gt; &lt;br /&gt;
         scale 1/3&lt;br /&gt;
      }&lt;br /&gt;
      finish {phong 0.6 phong_size 20}&lt;br /&gt;
   }&lt;br /&gt;
   no_shadow&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
The points B11, B14, B41, B44 are the corner points of the patch.&lt;br /&gt;
All other points are control points. The names of the declared points are as follows:&lt;br /&gt;
B for the colour of the patch, the first digit gives the row number, the second digit&lt;br /&gt;
the column number. If you render the above scene, you will get a blue &amp;amp;amp; white&lt;br /&gt;
checkered square, not very exciting. First we will add some spheres to make the control&lt;br /&gt;
points visible. As we do not want to type the code for 16 spheres, we will use&lt;br /&gt;
an array and a while loop to construct the spheres.&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#declare Points=array[16]{&lt;br /&gt;
   B11, B12, B13, B14&lt;br /&gt;
   B21, B22, B23, B24&lt;br /&gt;
   B31, B32, B33, B34&lt;br /&gt;
   B41, B42, B43, B44&lt;br /&gt;
}&lt;br /&gt;
#declare I=0;&lt;br /&gt;
#while (I&amp;amp;lt;16)&lt;br /&gt;
   sphere {&lt;br /&gt;
      Points[I],0.1 &lt;br /&gt;
      no_shadow &lt;br /&gt;
      pigment{&lt;br /&gt;
         #if (I=0|I=3|I=12|I=15)&lt;br /&gt;
            color rgb &amp;amp;lt;1,0,0&amp;amp;gt;&lt;br /&gt;
         #else&lt;br /&gt;
            color rgb &amp;amp;lt;0,1,1&amp;amp;gt;&lt;br /&gt;
         #end&lt;br /&gt;
      }&lt;br /&gt;
   }&lt;br /&gt;
   #declare I=I+1;&lt;br /&gt;
#end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
Rendering this scene will show the patch with its corner points in red and its control&lt;br /&gt;
points in cyan. Now it is time to start exploring.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Change B41 to &amp;lt;code&amp;gt;&amp;amp;lt;-1,0,0&amp;amp;gt;&amp;lt;/code&amp;gt; and render.&amp;lt;br&amp;gt;&lt;br /&gt;
Change B41 to &amp;lt;code&amp;gt;&amp;amp;lt;-1,1,0&amp;amp;gt;&amp;lt;/code&amp;gt; and render.&amp;lt;br&amp;gt;&lt;br /&gt;
Change B41 to &amp;lt;code&amp;gt;&amp;amp;lt; 1,2,1&amp;amp;gt;&amp;lt;/code&amp;gt; and render.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
Let's do some exercise with the control points. Start with a flat patch again.&amp;lt;br&amp;gt;&lt;br /&gt;
Change B42 to &amp;lt;code&amp;gt;&amp;amp;lt;1,2,0&amp;amp;gt;&amp;lt;/code&amp;gt; and B43 to &amp;lt;code&amp;gt;&amp;amp;lt;2,-2,0&amp;amp;gt;&amp;lt;/code&amp;gt; and render.&amp;lt;br&amp;gt;&lt;br /&gt;
Change B42 and B43 back to their original positions and try B34 to &amp;lt;code&amp;gt;&amp;amp;lt;4,2,1&amp;amp;gt;&amp;lt;/code&amp;gt;  &lt;br /&gt;
and B24 to &amp;lt;code&amp;gt;&amp;amp;lt;2,-2,2&amp;amp;gt;&amp;lt;/code&amp;gt; and render. Move the points around some more, also&lt;br /&gt;
try the control points in the middle.&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;[[Image:TutImgBpatch01.png|Bicubic_patch with control points]]&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
After all this we notice two things: &amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;ul type=&amp;quot;disc&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; The patch always goes through the corner points.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; In most situations the patch does not go through the control points. &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
Now go back to our spline work shop and have a look at the bezier_spline again. Indeed,&lt;br /&gt;
the points B11,B12,B13,B14, make up a bezier_spline. So do the points B11,B21,B31,B41 &lt;br /&gt;
and B41,B42,B43,B44 and B14,B24,B34,B44.&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
So far we have only been looking at one single patch, but one of the strengths of the&lt;br /&gt;
Bicubic patch lays in the fact that they can be connected smoothly, to form bigger shapes.&lt;br /&gt;
The process of connecting is relatively simple as there are actually only two rules to&lt;br /&gt;
follow. It can be done by using a well set up set of macros or by using a modeler. To give&lt;br /&gt;
an idea what is needed we will do a simple example by hand.&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
First put the patch in our scene back to its flat position. Then &lt;br /&gt;
change&amp;lt;code&amp;gt; #declare B14 = &amp;amp;lt;3,0,3&amp;amp;gt;; #declare B24 = &amp;amp;lt;3,2,2&amp;amp;gt;; #declare B34 = &amp;amp;lt;3.5,1,1&amp;amp;gt;; #declare B44 = &amp;amp;lt;3,-1,0&amp;amp;gt;; #declare B41 = &amp;amp;lt;0,-1,0&amp;amp;gt;;&amp;lt;/code&amp;gt; Move the camera a bit back&lt;br /&gt;
&amp;lt;code&amp;gt;camera { location &amp;amp;lt;3.1,7,-8&amp;amp;gt; look_at &amp;amp;lt;3,-2,1.5&amp;amp;gt; angle 40 }&amp;lt;/code&amp;gt; and delete&lt;br /&gt;
all the code for the spheres. We will now try and stitch a patch to the right side of the&lt;br /&gt;
current one. Off course the points on the left side (column 1) of the new patch have to be&lt;br /&gt;
in the same position as the points on the right side (column 4) of the blue one.&amp;lt;br&amp;gt;&lt;br /&gt;
Render the scene, including our new patch:&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#declare R11=B14; #declare R12=&amp;amp;lt;4,0,3&amp;amp;gt;;     //&lt;br /&gt;
#declare R13=&amp;amp;lt;5,0,3&amp;amp;gt;; #declare R14=&amp;amp;lt;6,0,3&amp;amp;gt;; // row 1&lt;br /&gt;
&lt;br /&gt;
#declare R21=B24; #declare R22=&amp;amp;lt;4,0,2&amp;amp;gt;;     //&lt;br /&gt;
#declare R23=&amp;amp;lt;5,0,2&amp;amp;gt;; #declare R24=&amp;amp;lt;6,0,2&amp;amp;gt;; // row 2&lt;br /&gt;
&lt;br /&gt;
#declare R31=B34; #declare R32=&amp;amp;lt;4,0,1&amp;amp;gt;;     //&lt;br /&gt;
#declare R33=&amp;amp;lt;5,0,1&amp;amp;gt;; #declare R34=&amp;amp;lt;6,0,1&amp;amp;gt;; // row 3&lt;br /&gt;
&lt;br /&gt;
#declare R41=B44; #declare R42=&amp;amp;lt;4,0,0&amp;amp;gt;;     //&lt;br /&gt;
#declare R43=&amp;amp;lt;5,0,0&amp;amp;gt;; #declare R44=&amp;amp;lt;6,0,0&amp;amp;gt;; // row 4&lt;br /&gt;
&lt;br /&gt;
bicubic_patch {&lt;br /&gt;
   type 1 flatness 0.001&lt;br /&gt;
   u_steps 4 v_steps 4&lt;br /&gt;
   uv_vectors&lt;br /&gt;
   &amp;amp;lt;0,0&amp;amp;gt; &amp;amp;lt;1,0&amp;amp;gt; &amp;amp;lt;1,1&amp;amp;gt; &amp;amp;lt;0,1&amp;amp;gt;&lt;br /&gt;
   R11, R12, R13, R14&lt;br /&gt;
   R21, R22, R23, R24&lt;br /&gt;
   R31, R32, R33, R34&lt;br /&gt;
   R41, R42, R43, R44&lt;br /&gt;
   uv_mapping&lt;br /&gt;
   texture {&lt;br /&gt;
      pigment {&lt;br /&gt;
         checker &lt;br /&gt;
         color rgbf &amp;amp;lt;1,1,1,0.5&amp;amp;gt; &lt;br /&gt;
         color rgbf &amp;amp;lt;1,0,0,0.7&amp;amp;gt; &lt;br /&gt;
         scale 1/3&lt;br /&gt;
      }&lt;br /&gt;
      finish {phong 0.6 phong_size 20}&lt;br /&gt;
   }&lt;br /&gt;
   no_shadow&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
This is a rather disappointing result. The patches are connected, but not exactly smooth.&lt;br /&gt;
In connecting patches the same principles apply as for connecting two 2D bezier splines&lt;br /&gt;
as we see in the &amp;lt;!--&amp;lt;linkto &amp;quot;Understanding The Concept of Splines&amp;quot;&amp;gt;spline workshop&amp;lt;/linkto&amp;gt;---&amp;gt;[[Documentation:Tutorial Section 3#Understanding The Concept of Splines|spline workshop]].&lt;br /&gt;
Control point, connection point and the next control point should be on one line to give&lt;br /&gt;
a smooth result. Also it is preferred, not required, that the distances from both control&lt;br /&gt;
points to the connection point are the same. For the Bicubic patch we have to do the same,&lt;br /&gt;
for all connection points involved in the joint. So, in our case, the following points &lt;br /&gt;
should be on one line:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;ul type=&amp;quot;disc&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; B13, B14=R11, R12&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; B23, B24=R21, R22&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; B33, B34=R31, R32&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; B43, B44=R41, R42&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
To achieve this we do:&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#declare R12=B14+(B14-B13); &lt;br /&gt;
#declare R22=B24+(B24-B23); &lt;br /&gt;
#declare R32=B34+(B34-B33); &lt;br /&gt;
#declare R42=B44+(B44-B43); &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;[[Image:TutImgBpatch02.png|patches, (un)smoothly connected]] &amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
This renders a smooth surface. Adding a third patch in front is relative simple now:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#declare G11=B41;      #declare G12=B42;                //&lt;br /&gt;
#declare G13=B43;      #declare G14=B44;                // row 1&lt;br /&gt;
&lt;br /&gt;
#declare G21=B41+(B41-B31); #declare G22=B42+(B42-B32); //&lt;br /&gt;
#declare G23=B43+(B43-B33); #declare G24=B44+(B44-B34); // row 2&lt;br /&gt;
&lt;br /&gt;
#declare G31=&amp;amp;lt;0,0,-2&amp;amp;gt;; #declare G32=&amp;amp;lt;1,0,-2&amp;amp;gt;;           //&lt;br /&gt;
#declare G33=&amp;amp;lt;2,0,-2&amp;amp;gt;; #declare G34=&amp;amp;lt;3,2,-2&amp;amp;gt;;           // row 3&lt;br /&gt;
&lt;br /&gt;
#declare G41=&amp;amp;lt;0,0,-3&amp;amp;gt;; #declare G42=&amp;amp;lt;1,0,-3&amp;amp;gt;;           // &lt;br /&gt;
#declare G43=&amp;amp;lt;2,0,-3&amp;amp;gt;; #declare G44=&amp;amp;lt;3,0,-3&amp;amp;gt;            // row 4&lt;br /&gt;
&lt;br /&gt;
bicubic_patch {&lt;br /&gt;
   type 1 flatness 0.001&lt;br /&gt;
   u_steps 4 v_steps 4&lt;br /&gt;
   uv_vectors&lt;br /&gt;
   &amp;amp;lt;0,0&amp;amp;gt; &amp;amp;lt;1,0&amp;amp;gt; &amp;amp;lt;1,1&amp;amp;gt; &amp;amp;lt;0,1&amp;amp;gt;&lt;br /&gt;
   G11, G12, G13, G14&lt;br /&gt;
   G21, G22, G23, G24&lt;br /&gt;
   G31, G32, G33, G34&lt;br /&gt;
   G41, G42, G43, G44&lt;br /&gt;
   uv_mapping&lt;br /&gt;
   texture {&lt;br /&gt;
      pigment {&lt;br /&gt;
         checker &lt;br /&gt;
         color rgbf &amp;amp;lt;1,1,1,0.5&amp;amp;gt; &lt;br /&gt;
         color rgbf &amp;amp;lt;0,1,0,0.7&amp;amp;gt; &lt;br /&gt;
         scale 1/3&lt;br /&gt;
      }&lt;br /&gt;
      finish {phong 0.6 phong_size 20}&lt;br /&gt;
   }&lt;br /&gt;
   no_shadow&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
Finally, let's put a few spheres back in the scene and add some cylinders to visualize what&lt;br /&gt;
is going on. See what happens if you move for example B44, B43, B33 or B34.&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#declare Points=array[8]{B33,B34,R32,B43,B44,R42,G23,G24}&lt;br /&gt;
#declare I=0;&lt;br /&gt;
#while (I&amp;amp;lt;8)&lt;br /&gt;
   sphere {&lt;br /&gt;
      Points[I],0.1 &lt;br /&gt;
      no_shadow &lt;br /&gt;
      pigment{&lt;br /&gt;
         #if (I=4)&lt;br /&gt;
            color rgb &amp;amp;lt;1,0,0&amp;amp;gt;&lt;br /&gt;
         #else&lt;br /&gt;
            color rgb &amp;amp;lt;0,1,1&amp;amp;gt;&lt;br /&gt;
         #end&lt;br /&gt;
      }&lt;br /&gt;
   }&lt;br /&gt;
   #declare I=I+1;&lt;br /&gt;
#end&lt;br /&gt;
union {&lt;br /&gt;
   cylinder {B33,B34,0.04} cylinder {B34,R32,0.04}&lt;br /&gt;
   cylinder {B43,B44,0.04} cylinder {B44,R42,0.04}&lt;br /&gt;
   cylinder {G23,G24,0.04} &lt;br /&gt;
   cylinder {B33,B43,0.04} cylinder {B43,G23,0.04}&lt;br /&gt;
   cylinder {B34,B44,0.04} cylinder {B44,G24,0.04}&lt;br /&gt;
   cylinder {R32,R42,0.04}&lt;br /&gt;
   no_shadow &lt;br /&gt;
   pigment {color rgb &amp;amp;lt;1,1,0&amp;amp;gt;}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
The hard part in using the Bicubic patch is not in connecting several patches. The &lt;br /&gt;
difficulty is keeping control over the shape you want to build. As patches are added, &lt;br /&gt;
in order to keep the result smooth, control over the position of many points gets restrained.&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt; [[Image:TutImgBpatch03.png|3 patches, some control points]] &amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Text Object===&lt;br /&gt;
&amp;lt;!--&amp;lt;indexentry &amp;quot;text, tutorial&amp;quot;&amp;gt;---&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;The &amp;lt;code&amp;gt;text&amp;lt;/code&amp;gt; object is a primitive that can use TrueType fonts&lt;br /&gt;
and TrueType Collections to create text objects. These&lt;br /&gt;
objects can be used in CSG, transformed and textured just like any other POV&lt;br /&gt;
primitive.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
For this tutorial, we will make two uses of the text object. First,&lt;br /&gt;
let's just make some block letters sitting on a checkered plane. Any TTF&lt;br /&gt;
font should do, but for this tutorial, we will use the &amp;lt;code&amp;gt;&lt;br /&gt;
timrom.ttf&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;cyrvetic.ttf&amp;lt;/code&amp;gt; which come bundled with&lt;br /&gt;
POV-Ray.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
We create a file called &amp;lt;code&amp;gt;textdemo.pov&amp;lt;/code&amp;gt; and edit it as&lt;br /&gt;
follows:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  #include &amp;amp;quot;colors.inc&amp;amp;quot;&lt;br /&gt;
  camera {&lt;br /&gt;
    location &amp;amp;lt;0, 1, -10&amp;amp;gt;&lt;br /&gt;
    look_at 0&lt;br /&gt;
    angle 35&lt;br /&gt;
  }&lt;br /&gt;
  light_source { &amp;amp;lt;500,500,-1000&amp;amp;gt; White }&lt;br /&gt;
  plane {&lt;br /&gt;
    y,0&lt;br /&gt;
    pigment { checker Green White }&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;Now let's add the text object. We will use the font &amp;lt;code&amp;gt;&lt;br /&gt;
timrom.ttf&amp;lt;/code&amp;gt; and we will create the string &amp;amp;quot;POV-RAY 3.0&amp;amp;quot;. For&lt;br /&gt;
now, we will just make the letters red. The syntax is very simple. The first&lt;br /&gt;
string in quotes is the font name, the second one is the string to be&lt;br /&gt;
rendered. The two floats are the thickness and offset values. The thickness&lt;br /&gt;
float determines how thick the block letters will be. Values of .5 to 2 are&lt;br /&gt;
usually best for this. The offset value will add to the kerning distance of&lt;br /&gt;
the letters. We will leave this a 0 for now.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  text {&lt;br /&gt;
    ttf &amp;amp;quot;timrom.ttf&amp;amp;quot; &amp;amp;quot;POV-RAY 3.0&amp;amp;quot; 1, 0&lt;br /&gt;
    pigment { Red }&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;Rendering this we notice that the letters are&lt;br /&gt;
off to the right of the screen. This is because they are placed so that the&lt;br /&gt;
lower left front corner of the first letter is at the origin. To center the&lt;br /&gt;
string we need to translate it -x some distance. But how far? In the docs we&lt;br /&gt;
see that the letters are all 0.5 to 0.75 units high. If we assume that each&lt;br /&gt;
one takes about 0.5 units of space on the x-axis, this means that the string&lt;br /&gt;
is about 6 units long (12 characters and spaces). Let's translate the&lt;br /&gt;
string 3 units along the negative x-axis.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  text {&lt;br /&gt;
    ttf &amp;amp;quot;timrom.ttf&amp;amp;quot; &amp;amp;quot;POV-RAY 3.0&amp;amp;quot; 1, 0&lt;br /&gt;
    pigment { Red }&lt;br /&gt;
    translate -3*x&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;That is better. Now let's play around with some of the parameters&lt;br /&gt;
of the text object. First, let's raise the thickness float to something&lt;br /&gt;
outlandish... say 25!&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  text {&lt;br /&gt;
    ttf &amp;amp;quot;timrom.ttf&amp;amp;quot; &amp;amp;quot;POV-RAY 3.0&amp;amp;quot; 25, 0&lt;br /&gt;
    pigment { Red }&lt;br /&gt;
    translate -2.25*x&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;Actually, that is kind of cool. Now let's return the thickness&lt;br /&gt;
value to 1 and try a different offset value. Change the offset float from 0&lt;br /&gt;
to 0.1 and render it again.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
Wait a minute?! The letters go wandering off up at an angle! That is not&lt;br /&gt;
what the docs describe! It almost looks as if the offset value applies in&lt;br /&gt;
both the x- and y-axis instead of just the x axis like we intended. Could it&lt;br /&gt;
be that a vector is called for here instead of a float? Let's try it. We&lt;br /&gt;
replace &amp;lt;code&amp;gt;0.1&amp;lt;/code&amp;gt; with &amp;lt;code&amp;gt; 0.1*x&amp;lt;/code&amp;gt; and render it again.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
That works! The letters are still in a straight line along the x-axis, just&lt;br /&gt;
a little further apart. Let's verify this and try to offset just in the&lt;br /&gt;
y-axis. We replace &amp;lt;code&amp;gt; 0.1*x&amp;lt;/code&amp;gt; with &amp;lt;code&amp;gt; 0.1*y&amp;lt;/code&amp;gt;. Again, this&lt;br /&gt;
works as expected with the letters going up to the right at an angle with no&lt;br /&gt;
additional distance added along the x-axis. Now let's try the z-axis. We&lt;br /&gt;
replace &amp;lt;code&amp;gt; 0.1*y&amp;lt;/code&amp;gt; with &amp;lt;code&amp;gt; 0.1*z&amp;lt;/code&amp;gt;. Rendering this yields a&lt;br /&gt;
disappointment. No offset occurs! The offset value can only be applied in the&lt;br /&gt;
x- and y-directions.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
Let's finish our scene by giving a fancier texture to the block letters,&lt;br /&gt;
using that cool large thickness value, and adding a slight y-offset. For fun,&lt;br /&gt;
we will throw in a sky sphere, dandy up our plane a bit, and use a little&lt;br /&gt;
more interesting camera viewpoint (we render the following scene at 640x480&lt;br /&gt;
&amp;lt;code&amp;gt; +A0.2&amp;lt;/code&amp;gt;):&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  #include &amp;amp;quot;colors.inc&amp;amp;quot;&lt;br /&gt;
  camera {&lt;br /&gt;
    location &amp;amp;lt;-5,.15,-2&amp;amp;gt;&lt;br /&gt;
    look_at &amp;amp;lt;.3,.2,1&amp;amp;gt;&lt;br /&gt;
    angle 35&lt;br /&gt;
  }&lt;br /&gt;
  light_source { &amp;amp;lt;500,500,-1000&amp;amp;gt; White }&lt;br /&gt;
  plane {&lt;br /&gt;
    y,0&lt;br /&gt;
    texture {&lt;br /&gt;
      pigment { SeaGreen }&lt;br /&gt;
      finish { reflection .35 specular 1 }&lt;br /&gt;
      normal { ripples .35 turbulence .5 scale .25 }&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  text {&lt;br /&gt;
    ttf &amp;amp;quot;timrom.ttf&amp;amp;quot; &amp;amp;quot;POV-RAY 3.0&amp;amp;quot; 25, 0.1*y&lt;br /&gt;
    pigment { BrightGold }&lt;br /&gt;
    finish { reflection .25 specular 1 }&lt;br /&gt;
    translate -3*x&lt;br /&gt;
  }&lt;br /&gt;
  #include &amp;amp;quot;skies.inc&amp;amp;quot;&lt;br /&gt;
  sky_sphere { S_Cloud5 }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;Let's try using text in a CSG object. We will attempt to create an&lt;br /&gt;
inlay in a stone block using a text object. We create a new file called&lt;br /&gt;
&amp;lt;code&amp;gt;textcsg.pov&amp;lt;/code&amp;gt; and edit it as follows:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  #include &amp;amp;quot;colors.inc&amp;amp;quot;&lt;br /&gt;
  #include &amp;amp;quot;stones.inc&amp;amp;quot;&lt;br /&gt;
  background { color rgb 1 }&lt;br /&gt;
  camera {&lt;br /&gt;
    location &amp;amp;lt;-3, 5, -15&amp;amp;gt;&lt;br /&gt;
    look_at 0&lt;br /&gt;
    angle 25&lt;br /&gt;
  }&lt;br /&gt;
  light_source { &amp;amp;lt;500,500,-1000&amp;amp;gt; White }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;Now let's create the block. We want it to be about eight units across&lt;br /&gt;
because our text string &amp;amp;quot;POV-RAY 3.0&amp;amp;quot; is about six units long. We&lt;br /&gt;
also want it about four units high and about one unit deep. But we need to&lt;br /&gt;
avoid a potential coincident surface with the text object so we will make the&lt;br /&gt;
first z-coordinate 0.1 instead of 0. Finally, we will give this block a nice&lt;br /&gt;
stone texture.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  box {&lt;br /&gt;
    &amp;amp;lt;-3.5, -1, 0.1&amp;amp;gt;, &amp;amp;lt;3.5, 1, 1&amp;amp;gt;&lt;br /&gt;
    texture { T_Stone10 }&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;Next, we want to make the text object. We can use the same object we used&lt;br /&gt;
in the first tutorial except we will use slightly different thickness and&lt;br /&gt;
offset values.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  text {&lt;br /&gt;
    ttf &amp;amp;quot;timrom.ttf&amp;amp;quot; &amp;amp;quot;POV-RAY 3.0&amp;amp;quot; 0.15, 0&lt;br /&gt;
    pigment { BrightGold }&lt;br /&gt;
    finish { reflection .25 specular 1 }&lt;br /&gt;
    translate -3*x&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;We remember that the text object is placed by default so that its front&lt;br /&gt;
surface lies directly on the x-y-plane. If the front of the box begins at&lt;br /&gt;
z=0.1 and thickness is set at 0.15, the depth of the inlay will be 0.05&lt;br /&gt;
units. We place a difference block around the two objects.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  difference {&lt;br /&gt;
    box {&lt;br /&gt;
      &amp;amp;lt;-3.5, -1, 0.1&amp;amp;gt;, &amp;amp;lt;3.5, 1, 1&amp;amp;gt;&lt;br /&gt;
      texture { T_Stone10 }&lt;br /&gt;
    }&lt;br /&gt;
    text {&lt;br /&gt;
      ttf &amp;amp;quot;timrom.ttf&amp;amp;quot; &amp;amp;quot;POV-RAY 3.0&amp;amp;quot; 0.15, 0&lt;br /&gt;
      pigment { BrightGold }&lt;br /&gt;
      finish { reflection .25 specular 1 }&lt;br /&gt;
      translate -3*x&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;[[Image:TutImgTxtstone.png|Text carved from stone.]]&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;When we render this at a low resolution we can see the inlay clearly&lt;br /&gt;
and that it is indeed a bright gold color. We can render at a higher resolution and see the results more clearly, but be forewarned... this can take quite some time at higher resolutions.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;!--&amp;lt;wikinav&amp;gt;---&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;table width=100% border=0 cellspacing=0 cellpadding=5&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td width=50% bgcolor=#EEEEEF&amp;gt;&lt;br /&gt;
[[Documentation:Tutorial Section 2.2#Using the POVINI Environment Variable|Using the POVINI Environment Variable]]&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td width=50% bgcolor=#EEEEEF align=right&amp;gt;&lt;br /&gt;
[[Documentation:Tutorial Section 3.1#Polygon Based Shapes|Polygon Based Shapes]]&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;!--&amp;lt;/wikinav&amp;gt;---&amp;gt;&lt;br /&gt;
&amp;lt;!--&amp;lt;wikitalk&amp;gt;---&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;table width=100% border=1 cellspacing=0 cellpadding=5&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td width=100% bgcolor=#FFEEEE&amp;gt;&lt;br /&gt;
This document is protected, so submissions, corrections and discussions should be held on this documents [[Documentation_Talk:Tutorial Section 3|talk]] page.&lt;br /&gt;
&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;!--&amp;lt;/wikitalk&amp;gt;---&amp;gt;&lt;/div&gt;</summary>
		<author><name>Chrisb</name></author>
	</entry>
	<entry>
		<id>https://wiki.povray.org/content?title=Documentation_Talk:Tutorial_Section_3.3&amp;diff=1928</id>
		<title>Documentation Talk:Tutorial Section 3.3</title>
		<link rel="alternate" type="text/html" href="https://wiki.povray.org/content?title=Documentation_Talk:Tutorial_Section_3.3&amp;diff=1928"/>
		<updated>2009-10-22T12:51:19Z</updated>

		<summary type="html">&lt;p&gt;Chrisb: Created page with '&amp;lt;!--&amp;lt;wikitalk&amp;gt;---&amp;gt; &amp;lt;table width=100% border=1 cellspacing=0 cellpadding=5&amp;gt; &amp;lt;tr&amp;gt;&amp;lt;td width=100% bgcolor=#FFEEEE&amp;gt; This document is protected, so submissions, corrections and discuss…'&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;!--&amp;lt;wikitalk&amp;gt;---&amp;gt;&lt;br /&gt;
&amp;lt;table width=100% border=1 cellspacing=0 cellpadding=5&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td width=100% bgcolor=#FFEEEE&amp;gt;&lt;br /&gt;
This document is protected, so submissions, corrections and discussions should be held on this documents [[Documentation_Talk:Tutorial Section 3.3|talk]] page.&lt;br /&gt;
&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;!--&amp;lt;/wikitalk&amp;gt;---&amp;gt;&lt;br /&gt;
===Superquadric Ellipsoid Object===&lt;br /&gt;
&amp;lt;!--&amp;lt;indexentry &amp;quot;superellipsoid, tutorial&amp;quot;&amp;gt;---&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;Sometimes we want to make an object that does not have perfectly sharp&lt;br /&gt;
edges like a box does. Then, the superquadric ellipsoid shape made by the&lt;br /&gt;
&amp;lt;code&amp;gt;superellipsoid&amp;lt;/code&amp;gt; is a useful object. It is described by the simple&lt;br /&gt;
syntax:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  superellipsoid { &amp;amp;lt;Value_E, Value_N &amp;amp;gt;}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;Where &amp;lt;em&amp;gt;Value_E&amp;lt;/em&amp;gt; and &amp;lt;em&amp;gt;Value_N&amp;lt;/em&amp;gt; are float values greater than&lt;br /&gt;
zero and less than or equal to one. Let's make a superellipsoid and&lt;br /&gt;
experiment with the values of &amp;lt;em&amp;gt;Value_E&amp;lt;/em&amp;gt; and &amp;lt;em&amp;gt;Value_N&amp;lt;/em&amp;gt; to see&lt;br /&gt;
what kind of shapes we can make. We create a file called &amp;lt;code&amp;gt;&lt;br /&gt;
supellps.pov&amp;lt;/code&amp;gt; and edit it as follows:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  #include &amp;amp;quot;colors.inc&amp;amp;quot;&lt;br /&gt;
  camera {&lt;br /&gt;
    location &amp;amp;lt;10, 5, -20&amp;amp;gt;&lt;br /&gt;
    look_at 0&lt;br /&gt;
    angle 15&lt;br /&gt;
  }&lt;br /&gt;
  background { color rgb &amp;amp;lt;.5, .5, .5&amp;amp;gt; }&lt;br /&gt;
  light_source { &amp;amp;lt;10, 50, -100&amp;amp;gt; White }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;The addition of a gray background makes it a little easier to see our&lt;br /&gt;
object. We now type:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  superellipsoid { &amp;amp;lt;.25, .25&amp;amp;gt;&lt;br /&gt;
    pigment { Red }&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;We save the file and render it to see the shape.&lt;br /&gt;
It will look like a box, but the edges will be rounded off. Now let's&lt;br /&gt;
experiment with different values of &amp;lt;em&amp;gt;Value_E&amp;lt;/em&amp;gt; and &amp;lt;em&amp;gt; Value_N&amp;lt;/em&amp;gt;.&lt;br /&gt;
For the next render, try &amp;amp;lt;1, 0.2&amp;amp;gt;. The shape now looks like a cylinder,&lt;br /&gt;
but the top edges are rounded. Now try &amp;amp;lt;0.1, 1&amp;amp;gt;. This shape is an odd&lt;br /&gt;
one! We do not know exactly what to call it, but it is interesting.&lt;br /&gt;
Finally, let's try &amp;amp;lt;1, 1&amp;amp;gt;. Well, this is more familiar... a sphere!&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
There are a couple of facts about superellipsoids we should know. First, we&lt;br /&gt;
should not use a value of 0 for either &amp;lt;em&amp;gt; Value_E&amp;lt;/em&amp;gt; nor &amp;lt;em&amp;gt;&lt;br /&gt;
Value_N&amp;lt;/em&amp;gt;. This will cause POV-Ray to incorrectly make a black box instead&lt;br /&gt;
of our desired shape. Second, very small values of &amp;lt;em&amp;gt;Value_E&amp;lt;/em&amp;gt; and &amp;lt;em&amp;gt;&lt;br /&gt;
Value_N&amp;lt;/em&amp;gt; may yield strange results so they should be avoided. Finally,&lt;br /&gt;
the Sturmian root solver will not work with superellipsoids.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
Superellipsoids are finite objects so they respond to auto-bounding and can&lt;br /&gt;
be used in CSG.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
Now let's use the superellipsoid to make something that would be useful&lt;br /&gt;
in a scene. We will make a tiled floor and place a couple of superellipsoid&lt;br /&gt;
objects hovering over it. We can start with the file we have already&lt;br /&gt;
made.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
We rename it to &amp;lt;code&amp;gt; tiles.pov&amp;lt;/code&amp;gt; and edit it so that it reads as&lt;br /&gt;
follows:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  #include &amp;amp;quot;colors.inc&amp;amp;quot;&lt;br /&gt;
  #include &amp;amp;quot;textures.inc&amp;amp;quot;&lt;br /&gt;
  camera {&lt;br /&gt;
    location &amp;amp;lt;10, 5, -20&amp;amp;gt;&lt;br /&gt;
    look_at 0&lt;br /&gt;
    angle 15&lt;br /&gt;
  }&lt;br /&gt;
  background { color rgb &amp;amp;lt;.5, .5, .5&amp;amp;gt; }&lt;br /&gt;
  light_source{ &amp;amp;lt;10, 50, -100&amp;amp;gt; White }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p class=&amp;quot;Note&amp;quot;&amp;gt;&amp;lt;strong&amp;gt;Note:&amp;lt;/strong&amp;gt; we have added &amp;lt;code&amp;gt;#include &amp;amp;quot;textures.inc&amp;amp;quot;&amp;lt;/code&amp;gt; so&lt;br /&gt;
we can use pre-defined textures. Now we want to define the superellipsoid&lt;br /&gt;
which will be our tile.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  #declare Tile = superellipsoid { &amp;amp;lt;0.5, 0.1&amp;amp;gt;&lt;br /&gt;
    scale &amp;amp;lt;1, .05, 1&amp;amp;gt;&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;Superellipsoids are roughly 2*2*2 units unless we scale them otherwise. If&lt;br /&gt;
we wish to lay a bunch of our tiles side by side, they will have to be offset&lt;br /&gt;
from each other so they do not overlap. We should select an offset value&lt;br /&gt;
that is slightly more than 2 so that we have some space between the tiles to&lt;br /&gt;
fill with grout. So we now add this:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  #declare Offset = 2.1;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;We now want to lay down a row of tiles. Each tile will be offset from the&lt;br /&gt;
original by an ever-increasing amount in both the +z and -z directions. We&lt;br /&gt;
refer to our offset and multiply by the tile's rank to determine the&lt;br /&gt;
position of each tile in the row. We also union these tiles into a single&lt;br /&gt;
object called &amp;lt;code&amp;gt;Row&amp;lt;/code&amp;gt; like this:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  #declare Row = union {&lt;br /&gt;
    object { Tile }&lt;br /&gt;
    object { Tile translate z*Offset }&lt;br /&gt;
    object { Tile translate z*Offset*2 }&lt;br /&gt;
    object { Tile translate z*Offset*3 }&lt;br /&gt;
    object { Tile translate z*Offset*4 }&lt;br /&gt;
    object { Tile translate z*Offset*5 }&lt;br /&gt;
    object { Tile translate z*Offset*6 }&lt;br /&gt;
    object { Tile translate z*Offset*7 }&lt;br /&gt;
    object { Tile translate z*Offset*8 }&lt;br /&gt;
    object { Tile translate z*Offset*9 }&lt;br /&gt;
    object { Tile translate z*Offset*10 }&lt;br /&gt;
    object { Tile translate -z*Offset }&lt;br /&gt;
    object { Tile translate -z*Offset*2 }&lt;br /&gt;
    object { Tile translate -z*Offset*3 }&lt;br /&gt;
    object { Tile translate -z*Offset*4 }&lt;br /&gt;
    object { Tile translate -z*Offset*5 }&lt;br /&gt;
    object { Tile translate -z*Offset*6 }&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;This gives us a single row of 17 tiles, more than enough to fill the&lt;br /&gt;
screen. Now we must make copies of the &amp;lt;code&amp;gt;Row&amp;lt;/code&amp;gt; and translate them,&lt;br /&gt;
again by the offset value, in both the +x and -x directions in ever&lt;br /&gt;
increasing amounts in the same manner.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  object { Row }&lt;br /&gt;
  object { Row translate x*Offset }&lt;br /&gt;
  object { Row translate x*Offset*2 }&lt;br /&gt;
  object { Row translate x*Offset*3 }&lt;br /&gt;
  object { Row translate x*Offset*4 }&lt;br /&gt;
  object { Row translate x*Offset*5 }&lt;br /&gt;
  object { Row translate x*Offset*6 }&lt;br /&gt;
  object { Row translate x*Offset*7 }&lt;br /&gt;
  object { Row translate -x*Offset }&lt;br /&gt;
  object { Row translate -x*Offset*2 }&lt;br /&gt;
  object { Row translate -x*Offset*3 }&lt;br /&gt;
  object { Row translate -x*Offset*4 }&lt;br /&gt;
  object { Row translate -x*Offset*5 }&lt;br /&gt;
  object { Row translate -x*Offset*6 }&lt;br /&gt;
  object { Row translate -x*Offset*7 }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;Finally, our tiles are complete. But we need a texture for them. To do&lt;br /&gt;
this we union all of the &amp;lt;code&amp;gt;Rows&amp;lt;/code&amp;gt; together and apply a &amp;lt;code&amp;gt;White&lt;br /&gt;
Marble&amp;lt;/code&amp;gt; pigment and a somewhat shiny reflective surface to it:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  union{&lt;br /&gt;
    object { Row }&lt;br /&gt;
    object { Row translate x*Offset }&lt;br /&gt;
    object { Row translate x*Offset*2 }&lt;br /&gt;
    object { Row translate x*Offset*3 }&lt;br /&gt;
    object { Row translate x*Offset*4 }&lt;br /&gt;
    object { Row translate x*Offset*5 }&lt;br /&gt;
    object { Row translate x*Offset*6 }&lt;br /&gt;
    object { Row translate x*Offset*7 }&lt;br /&gt;
    object { Row translate -x*Offset }&lt;br /&gt;
    object { Row translate -x*Offset*2 }&lt;br /&gt;
    object { Row translate -x*Offset*3 }&lt;br /&gt;
    object { Row translate -x*Offset*4 }&lt;br /&gt;
    object { Row translate -x*Offset*5 }&lt;br /&gt;
    object { Row translate -x*Offset*6 }&lt;br /&gt;
    object { Row translate -x*Offset*7 }&lt;br /&gt;
    pigment { White_Marble }&lt;br /&gt;
    finish { phong 1 phong_size 50 reflection .35 }&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;We now need to add the grout. This can simply be a white plane. We have&lt;br /&gt;
stepped up the ambient here a little so it looks whiter.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  plane {&lt;br /&gt;
    y, 0  //this is the grout&lt;br /&gt;
    pigment { color White }&lt;br /&gt;
    finish { ambient .4 diffuse .7 }&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;To complete our scene, let's add five different superellipsoids, each&lt;br /&gt;
a different color, so that they hover over our tiles and are reflected in&lt;br /&gt;
them.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  superellipsoid {&lt;br /&gt;
    &amp;amp;lt;0.1, 1&amp;amp;gt;&lt;br /&gt;
    pigment { Red }&lt;br /&gt;
    translate &amp;amp;lt;5, 3, 0&amp;amp;gt;&lt;br /&gt;
    scale .45&lt;br /&gt;
  }&lt;br /&gt;
  superellipsoid {&lt;br /&gt;
    &amp;amp;lt;1, 0.25&amp;amp;gt;&lt;br /&gt;
    pigment { Blue }&lt;br /&gt;
    translate &amp;amp;lt;-5, 3, 0&amp;amp;gt;&lt;br /&gt;
    scale .45&lt;br /&gt;
  }&lt;br /&gt;
  superellipsoid {&lt;br /&gt;
    &amp;amp;lt;0.2, 0.6&amp;amp;gt;&lt;br /&gt;
    pigment { Green }&lt;br /&gt;
    translate &amp;amp;lt;0, 3, 5&amp;amp;gt;&lt;br /&gt;
    scale .45&lt;br /&gt;
  }&lt;br /&gt;
  superellipsoid {&lt;br /&gt;
    &amp;amp;lt;0.25, 0.25&amp;amp;gt;&lt;br /&gt;
    pigment { Yellow }&lt;br /&gt;
    translate &amp;amp;lt;0, 3, -5&amp;amp;gt;&lt;br /&gt;
    scale .45&lt;br /&gt;
  }&lt;br /&gt;
  superellipsoid {&lt;br /&gt;
    &amp;amp;lt;1, 1&amp;amp;gt;&lt;br /&gt;
    pigment { Pink }&lt;br /&gt;
    translate y*3&lt;br /&gt;
    scale .45&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;[[Image:TutImgSuperell.png|Some superellipsoids hovering above a tiled floor.]]&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;We render the scene to see the result. If we are&lt;br /&gt;
happy with that, we do a final trace at 640x480 &amp;lt;code&amp;gt;+A0.2&amp;lt;/code&amp;gt;.&amp;lt;/p&amp;gt;&lt;br /&gt;
===Advanced Texture Options===&lt;br /&gt;
&amp;lt;!--&amp;lt;indexentry &amp;quot;Texture Options, advanced&amp;quot;&amp;gt;---&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;The extremely powerful texturing ability is one thing that really sets&lt;br /&gt;
POV-Ray apart from other raytracers. So far we have not really tried anything&lt;br /&gt;
too complex but by now we should be comfortable enough with the program's&lt;br /&gt;
syntax to try some of the more advanced texture options.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
Obviously, we cannot try them all. It would take a tutorial a lot more pages&lt;br /&gt;
to use every texturing option available in POV-Ray. For this limited&lt;br /&gt;
tutorial, we will content ourselves to just trying a few of them to give an&lt;br /&gt;
idea of how textures are created. With a little practice, we will soon be&lt;br /&gt;
creating beautiful textures of our own.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p class=&amp;quot;Note&amp;quot;&amp;gt;&amp;lt;strong&amp;gt;Note:&amp;lt;/strong&amp;gt; early versions of POV-Ray made a distinction between pigment and&lt;br /&gt;
normal patterns, i. e. patterns that could be used inside a &amp;lt;code&amp;gt;&lt;br /&gt;
normal&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;pigment&amp;lt;/code&amp;gt; statement. Since POV-Ray 3.0 this&lt;br /&gt;
restriction was removed so that all patterns listed in section&lt;br /&gt;
&amp;amp;quot;Patterns&amp;amp;quot; can be used as a pigment or normal pattern.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Pigments===&lt;br /&gt;
&amp;lt;!--&amp;lt;indexentry &amp;quot;pigment, tutorial&amp;quot;&amp;gt;---&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;Every surface must have a color. In POV-Ray this color is called a &amp;lt;code&amp;gt;&amp;lt;!--&amp;lt;linkto &amp;quot;pigment&amp;quot;&amp;gt;pigment&amp;lt;/linkto&amp;gt;---&amp;gt;[[Documentation:Reference Section 5#Pigment|pigment]]&amp;lt;/code&amp;gt;.&lt;br /&gt;
It does not have to be a single color. It can be a color pattern, a color&lt;br /&gt;
list or even an image map. Pigments can also be layered one on top of the next&lt;br /&gt;
so long as the uppermost layers are at least partially transparent so the ones&lt;br /&gt;
beneath can show through. Let's play around with some of these kinds of&lt;br /&gt;
pigments.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
We create a file called &amp;lt;code&amp;gt;texdemo.pov&amp;lt;/code&amp;gt; and edit it as&lt;br /&gt;
follows:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  #include &amp;amp;quot;colors.inc&amp;amp;quot;&lt;br /&gt;
  camera {&lt;br /&gt;
    location &amp;amp;lt;1, 1, -7&amp;amp;gt;&lt;br /&gt;
    look_at 0&lt;br /&gt;
    angle 36&lt;br /&gt;
  }&lt;br /&gt;
  light_source { &amp;amp;lt;1000, 1000, -1000&amp;amp;gt; White }&lt;br /&gt;
  plane {&lt;br /&gt;
    y, -1.5&lt;br /&gt;
    pigment { checker Green, White }&lt;br /&gt;
  }&lt;br /&gt;
  sphere {&lt;br /&gt;
    &amp;amp;lt;0,0,0&amp;amp;gt;, 1&lt;br /&gt;
    pigment { Red }&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;Giving this file a quick test render we see&lt;br /&gt;
that it is a simple red sphere against a green and white checkered plane. We&lt;br /&gt;
will be using the sphere for our textures.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Using Color List Pigments===&lt;br /&gt;
&amp;lt;!--&amp;lt;indexentry &amp;quot;Color List Pigments, using&amp;quot;&amp;gt;---&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;Before we begin we should note that we have already made one kind of&lt;br /&gt;
pigment, the color list pigment. In the previous example we have used a&lt;br /&gt;
checkered pattern on our plane. There are three other kinds of color list&lt;br /&gt;
pigments, &amp;lt;code&amp;gt;&amp;lt;!--&amp;lt;linkto &amp;quot;brick&amp;quot;&amp;gt;brick&amp;lt;/linkto&amp;gt;---&amp;gt;[[Documentation:Reference Section 5.3#Brick|brick]]&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;&amp;lt;!--&amp;lt;linkto &amp;quot;hexagon&amp;quot;&amp;gt;hexagon&amp;lt;/linkto&amp;gt;---&amp;gt;[[Documentation:Reference Section 5.4#Hexagon|hexagon]]&amp;lt;/code&amp;gt; and the&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;!--&amp;lt;linkto &amp;quot;object&amp;quot;&amp;gt;object&amp;lt;/linkto&amp;gt;---&amp;gt;[[Documentation:Reference Section 5.4#Object Pattern|object]]&amp;lt;/code&amp;gt; pattern.&lt;br /&gt;
Let's quickly try each of these. First, we change the plane's&lt;br /&gt;
pigment as follows:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  pigment { hexagon Green, White, Yellow }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;Rendering this we see a three-color hexagonal pattern. Note that this&lt;br /&gt;
pattern requires three colors. Now we change the pigment to...&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  pigment { brick Gray75, Red rotate -90*x scale .25 }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;Looking at the resulting image we see that the plane now has a brick&lt;br /&gt;
pattern. We note that we had to rotate the pattern to make it appear&lt;br /&gt;
correctly on the flat plane. This pattern normally is meant to be used on&lt;br /&gt;
vertical surfaces. We also had to scale the pattern down a bit so we could&lt;br /&gt;
see it more easily. We can play around with these color list pigments, change&lt;br /&gt;
the colors, etc. until we get a floor that we like.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Using Pigment and Patterns===&lt;br /&gt;
&amp;lt;!--&amp;lt;indexentry &amp;quot;Pigment and Patterns, using&amp;quot;&amp;gt;---&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;Let's begin texturing our sphere by using a pattern and a color map&lt;br /&gt;
consisting of three colors. We replace the pigment block with the&lt;br /&gt;
following.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  pigment {&lt;br /&gt;
    gradient x&lt;br /&gt;
    color_map {&lt;br /&gt;
      [0.00 color Red]&lt;br /&gt;
      [0.33 color Blue]&lt;br /&gt;
      [0.66 color Yellow]&lt;br /&gt;
      [1.00 color Red]&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;Rendering this we see that the &amp;lt;code&amp;gt;&amp;lt;!--&amp;lt;linkto &amp;quot;gradient&amp;quot;&amp;gt;gradient&amp;lt;/linkto&amp;gt;---&amp;gt;[[Documentation:Reference Section 5.4#Gradient|gradient]]&amp;lt;/code&amp;gt; pattern gives us an&lt;br /&gt;
interesting pattern of vertical stripes. We change the gradient direction to&lt;br /&gt;
y. The stripes are horizontal now. We change the gradient direction to z. The&lt;br /&gt;
stripes are now more like concentric rings. This is because the gradient&lt;br /&gt;
direction is directly away from the camera. We change the direction back to x&lt;br /&gt;
and add the following to the pigment block.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  pigment {&lt;br /&gt;
    gradient x&lt;br /&gt;
    color_map {&lt;br /&gt;
      [0.00 color Red]&lt;br /&gt;
      [0.33 color Blue]&lt;br /&gt;
      [0.66 color Yellow]&lt;br /&gt;
      [1.00 color Red]&lt;br /&gt;
    }&lt;br /&gt;
    rotate -45*z          // &amp;amp;lt;- add this line&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;The vertical bars are now slanted at a 45 degree angle. All patterns can&lt;br /&gt;
be rotated, scaled and translated in this manner. Let's now try some&lt;br /&gt;
different types of patterns. One at a time, we substitute the following&lt;br /&gt;
keywords for &amp;lt;code&amp;gt;gradient x&amp;lt;/code&amp;gt; and render to see the result: &amp;lt;code&amp;gt;&amp;lt;!--&amp;lt;linkto &amp;quot;bozo&amp;quot;&amp;gt;bozo&amp;lt;/linkto&amp;gt;---&amp;gt;[[Documentation:Reference Section 5.3#Bozo|bozo]]&amp;lt;/code&amp;gt;,&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;!--&amp;lt;linkto &amp;quot;marble&amp;quot;&amp;gt;marble&amp;lt;/linkto&amp;gt;---&amp;gt;[[Documentation:Reference Section 5.4#Marble|marble]]&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;&amp;lt;!--&amp;lt;linkto &amp;quot;agate&amp;quot;&amp;gt;agate&amp;lt;/linkto&amp;gt;---&amp;gt;[[Documentation:Reference Section 5.3#Agate|agate]]&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;&amp;lt;!--&amp;lt;linkto &amp;quot;granite&amp;quot;&amp;gt;granite&amp;lt;/linkto&amp;gt;---&amp;gt;[[Documentation:Reference Section 5.4#Granite|granite]]&amp;lt;/code&amp;gt;,&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;!--&amp;lt;linkto &amp;quot;leopard&amp;quot;&amp;gt;leopard&amp;lt;/linkto&amp;gt;---&amp;gt;[[Documentation:Reference Section 5.4#Leopard|leopard]]&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;&amp;lt;!--&amp;lt;linkto &amp;quot;spotted&amp;quot;&amp;gt;spotted&amp;lt;/linkto&amp;gt;---&amp;gt;[[Documentation:Reference Section 5.5#Spotted|spotted]]&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;&amp;lt;!--&amp;lt;linkto &amp;quot;wood&amp;quot;&amp;gt;wood&amp;lt;/linkto&amp;gt;---&amp;gt;[[Documentation:Reference Section 5.5#Wood|wood]]&amp;lt;/code&amp;gt;&lt;br /&gt;
(if we like  we can test all patterns listed in section &amp;amp;quot;&amp;lt;!--&amp;lt;linkto &amp;quot;Patterns&amp;quot;&amp;gt;Patterns&amp;lt;/linkto&amp;gt;---&amp;gt;[[Documentation:Reference Section 5.3#Patterns|Patterns]]&amp;amp;quot;).&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
Rendering these we see that each results in a slightly different pattern.&lt;br /&gt;
But to get really good results each type of pattern requires the use of some&lt;br /&gt;
pattern modifiers.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Using Pattern Modifiers===&lt;br /&gt;
&amp;lt;!--&amp;lt;indexentry &amp;quot;Pattern Modifiers, using&amp;quot;&amp;gt;---&amp;gt;&lt;br /&gt;
&amp;lt;!--&amp;lt;indexentry &amp;quot;frequency, tutorial&amp;quot;&amp;gt;---&amp;gt;&lt;br /&gt;
&amp;lt;!--&amp;lt;indexentry &amp;quot;turbulence, tutorial&amp;quot;&amp;gt;---&amp;gt;&lt;br /&gt;
&amp;lt;!--&amp;lt;indexentry &amp;quot;omega, tutorial&amp;quot;&amp;gt;---&amp;gt;&lt;br /&gt;
&amp;lt;!--&amp;lt;indexentry &amp;quot;lambda, tutorial&amp;quot;&amp;gt;---&amp;gt;&lt;br /&gt;
&amp;lt;!--&amp;lt;indexentry &amp;quot;octaves, tutorial&amp;quot;&amp;gt;---&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;Let's take a look at some pattern modifiers. First, we change the&lt;br /&gt;
pattern type to bozo. Then we add the following change.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  pigment {&lt;br /&gt;
    bozo&lt;br /&gt;
    frequency 3            // &amp;amp;lt;- add this line&lt;br /&gt;
    color_map {&lt;br /&gt;
      [0.00 color Red]&lt;br /&gt;
      [0.33 color Blue]&lt;br /&gt;
      [0.66 color Yellow]&lt;br /&gt;
      [1.00 color Red]&lt;br /&gt;
    }&lt;br /&gt;
    rotate -45*z&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;The &amp;lt;code&amp;gt;frequency&amp;lt;/code&amp;gt; modifier determines the number of times the&lt;br /&gt;
color map repeats itself per unit of size. This change makes the &amp;lt;code&amp;gt;bozo&amp;lt;/code&amp;gt;&lt;br /&gt;
pattern we saw earlier have many more bands in it. Now we change&lt;br /&gt;
the pattern type to &amp;lt;code&amp;gt;marble&amp;lt;/code&amp;gt;. When we rendered this earlier, we&lt;br /&gt;
saw a banded pattern similar to &amp;lt;code&amp;gt;gradient y&amp;lt;/code&amp;gt; that really did not&lt;br /&gt;
look much like marble at all. This is because marble really is a kind of&lt;br /&gt;
gradient and it needs another pattern modifier to look like marble. This&lt;br /&gt;
modifier is called &amp;lt;code&amp;gt;&amp;lt;!--&amp;lt;linkto &amp;quot;turbulence&amp;quot;&amp;gt;turbulence&amp;lt;/linkto&amp;gt;---&amp;gt;[[Documentation:Reference Section 5.6#Turbulence|turbulence]]&amp;lt;/code&amp;gt;. We change the line &amp;lt;code&amp;gt;&lt;br /&gt;
frequency 3&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;turbulence 1&amp;lt;/code&amp;gt; and render again. That's&lt;br /&gt;
better! Now let's put &amp;lt;code&amp;gt;frequency 3&amp;lt;/code&amp;gt; back in right after the&lt;br /&gt;
turbulence and take another look. Even more interesting!&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
But wait, it gets better! Turbulence itself has some modifiers of its own.&lt;br /&gt;
We can adjust the turbulence several ways. First, the float that follows the&lt;br /&gt;
&amp;lt;code&amp;gt;turbulence&amp;lt;/code&amp;gt; keyword can be any value with higher values giving&lt;br /&gt;
us more turbulence. Second, we can use the keywords &amp;lt;code&amp;gt;&amp;lt;!--&amp;lt;linkto &amp;quot;omega&amp;quot;&amp;gt;omega&amp;lt;/linkto&amp;gt;---&amp;gt;[[Documentation:Reference Section 5.6#Omega|omega]]&amp;lt;/code&amp;gt;,&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;!--&amp;lt;linkto &amp;quot;lambda&amp;quot;&amp;gt;lambda&amp;lt;/linkto&amp;gt;---&amp;gt;[[Documentation:Reference Section 5.6#Lambda|lambda]]&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;&amp;lt;!--&amp;lt;linkto &amp;quot;octaves&amp;quot;&amp;gt;octaves&amp;lt;/linkto&amp;gt;---&amp;gt;[[Documentation:Reference Section 5.6#Octaves|octaves]]&amp;lt;/code&amp;gt;&lt;br /&gt;
to change the turbulence parameters.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
Let's try this now:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  pigment {&lt;br /&gt;
    marble&lt;br /&gt;
    turbulence 0.5&lt;br /&gt;
    lambda 1.5&lt;br /&gt;
    omega 0.8&lt;br /&gt;
    octaves 5&lt;br /&gt;
    frequency 3&lt;br /&gt;
    color_map {&lt;br /&gt;
      [0.00 color Red]&lt;br /&gt;
      [0.33 color Blue]&lt;br /&gt;
      [0.66 color Yellow]&lt;br /&gt;
      [1.00 color Red]&lt;br /&gt;
    }&lt;br /&gt;
    rotate 45*z&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;Rendering this we see that the turbulence has changed and the pattern&lt;br /&gt;
looks different. We play around with the numerical values of turbulence,&lt;br /&gt;
lambda, omega and octaves to see what they do.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Using Transparent Pigments and Layered Textures===&lt;br /&gt;
&amp;lt;!--&amp;lt;indexentry &amp;quot;Transparent Pigments, using&amp;quot; &amp;quot;Layered Textures, using&amp;quot;&amp;gt;---&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;Pigments are described by numerical values that give the &amp;lt;!--&amp;lt;linkto &amp;quot;rgb&amp;quot;&amp;gt;rgb&amp;lt;/linkto&amp;gt;---&amp;gt;[[Documentation:Reference Section 2.1#Color Vectors|rgb]] value of the&lt;br /&gt;
color to be used (like &amp;lt;code&amp;gt;color rgb&amp;amp;lt;1,0,0&amp;amp;gt;&amp;lt;/code&amp;gt; giving us a red&lt;br /&gt;
color). But this syntax will give us more than just the rgb values. We can&lt;br /&gt;
specify filtering transparency by changing it as follows: &amp;lt;code&amp;gt;color&lt;br /&gt;
rgbf&amp;amp;lt;1,0,0,1&amp;amp;gt;&amp;lt;/code&amp;gt;. The &amp;lt;em&amp;gt;f&amp;lt;/em&amp;gt; stands for &amp;lt;code&amp;gt;filter&amp;lt;/code&amp;gt;,&lt;br /&gt;
POV-Ray's word for &amp;lt;!--&amp;lt;linkto &amp;quot;rgbf&amp;quot;&amp;gt;filtered transparency&amp;lt;/linkto&amp;gt;---&amp;gt;[[Documentation:Reference Section 2.1#Color Vectors|filtered transparency]]. A value of one means that the&lt;br /&gt;
color is completely transparent, but still filters the light according to&lt;br /&gt;
what the pigment is. In this case, the color will be a transparent red, like&lt;br /&gt;
red cellophane.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
There is another kind of transparency in POV-Ray. It is called &amp;lt;em&amp;gt;transmittance&amp;lt;/em&amp;gt;&lt;br /&gt;
or non-filtering transparency (the keyword is &amp;lt;code&amp;gt;&amp;lt;!--&amp;lt;linkto &amp;quot;transmit&amp;quot;&amp;gt;transmit&amp;lt;/linkto&amp;gt;---&amp;gt;[[Documentation:Reference Section 2.1#Specifying Colors|transmit]]&amp;lt;/code&amp;gt;;&lt;br /&gt;
see also &amp;lt;code&amp;gt;&amp;lt;!--&amp;lt;linkto &amp;quot;rgbt&amp;quot;&amp;gt;rgbt&amp;lt;/linkto&amp;gt;---&amp;gt;[[Documentation:Reference Section 2.1#Color Vectors|rgbt]]&amp;lt;/code&amp;gt;).&lt;br /&gt;
It is different from &amp;lt;code&amp;gt;filter&amp;lt;/code&amp;gt; in that it does not filter the light according&lt;br /&gt;
to the pigment color. It instead allows all the light to pass through unchanged. It can&lt;br /&gt;
be specified like this: &amp;lt;code&amp;gt;rgbt &amp;amp;lt;1,0,0,1&amp;amp;gt;&amp;lt;/code&amp;gt;.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
Let's use some transparent pigments to create another kind of texture,&lt;br /&gt;
the layered texture. Returning to our previous example, declare the following&lt;br /&gt;
texture.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  #declare LandArea = texture {&lt;br /&gt;
      pigment {&lt;br /&gt;
        agate&lt;br /&gt;
        turbulence 1&lt;br /&gt;
        lambda 1.5&lt;br /&gt;
        omega .8&lt;br /&gt;
        octaves 8&lt;br /&gt;
        color_map {&lt;br /&gt;
          [0.00 color rgb &amp;amp;lt;.5, .25, .15&amp;amp;gt;]&lt;br /&gt;
          [0.33 color rgb &amp;amp;lt;.1, .5, .4&amp;amp;gt;]&lt;br /&gt;
          [0.86 color rgb &amp;amp;lt;.6, .3, .1&amp;amp;gt;]&lt;br /&gt;
          [1.00 color rgb &amp;amp;lt;.5, .25, .15&amp;amp;gt;]&lt;br /&gt;
        }&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;This texture will be the land area. Now let's make the oceans by&lt;br /&gt;
declaring the following.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  #declare OceanArea = texture {&lt;br /&gt;
      pigment {&lt;br /&gt;
        bozo&lt;br /&gt;
        turbulence .5&lt;br /&gt;
        lambda 2&lt;br /&gt;
        color_map {&lt;br /&gt;
          [0.00, 0.33 color rgb &amp;amp;lt;0, 0, 1&amp;amp;gt;&lt;br /&gt;
                      color rgb &amp;amp;lt;0, 0, 1&amp;amp;gt;]&lt;br /&gt;
          [0.33, 0.66 color rgbf &amp;amp;lt;1, 1, 1, 1&amp;amp;gt;&lt;br /&gt;
                      color rgbf &amp;amp;lt;1, 1, 1, 1&amp;amp;gt;]&lt;br /&gt;
          [0.66, 1.00 color rgb &amp;amp;lt;0, 0, 1&amp;amp;gt;&lt;br /&gt;
                      color rgb &amp;amp;lt;0, 0, 1&amp;amp;gt;]&lt;br /&gt;
        }&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p class=&amp;quot;Note&amp;quot;&amp;gt;&amp;lt;strong&amp;gt;Note:&amp;lt;/strong&amp;gt; how the ocean is the opaque blue area and the land is the clear area&lt;br /&gt;
which will allow the underlying texture to show through.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
Now, let's declare one more texture to simulate an atmosphere with&lt;br /&gt;
swirling clouds.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  #declare CloudArea = texture {&lt;br /&gt;
    pigment {&lt;br /&gt;
      agate&lt;br /&gt;
      turbulence 1&lt;br /&gt;
      lambda 2&lt;br /&gt;
      frequency 2&lt;br /&gt;
      color_map {&lt;br /&gt;
        [0.0 color rgbf &amp;amp;lt;1, 1, 1, 1&amp;amp;gt;]&lt;br /&gt;
        [0.5 color rgbf &amp;amp;lt;1, 1, 1, .35&amp;amp;gt;]&lt;br /&gt;
        [1.0 color rgbf &amp;amp;lt;1, 1, 1, 1&amp;amp;gt;]&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;Now apply all of these to our sphere.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  sphere {&lt;br /&gt;
    &amp;amp;lt;0,0,0&amp;amp;gt;, 1&lt;br /&gt;
    texture { LandArea }&lt;br /&gt;
    texture { OceanArea }&lt;br /&gt;
    texture { CloudArea }&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;We render this and have a pretty good rendition of a little planetoid. But&lt;br /&gt;
it could be better. We do not particularly like the appearance of the&lt;br /&gt;
clouds. There is a way they could be done that would be much more&lt;br /&gt;
realistic.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Using Pigment Maps===&lt;br /&gt;
&amp;lt;!--&amp;lt;indexentry &amp;quot;Pigment Maps, using&amp;quot; &amp;quot;pigment_map, tutorial&amp;quot;&amp;gt;---&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;Pigments may be blended together in the same way as the colors in a color&lt;br /&gt;
map using the same pattern keywords and a &amp;lt;code&amp;gt;pigment_map&amp;lt;/code&amp;gt;. Let's&lt;br /&gt;
just give it a try.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
We add the following declarations, making sure they appear before the other&lt;br /&gt;
declarations in the file.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  #declare Clouds1 = pigment {&lt;br /&gt;
      bozo&lt;br /&gt;
      turbulence 1&lt;br /&gt;
      color_map {&lt;br /&gt;
        [0.0 color White filter 1]&lt;br /&gt;
        [0.5 color White]&lt;br /&gt;
        [1.0 color White filter 1]&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
  #declare Clouds2 = pigment {&lt;br /&gt;
    agate&lt;br /&gt;
    turbulence 1&lt;br /&gt;
    color_map {&lt;br /&gt;
      [0.0 color White filter 1]&lt;br /&gt;
      [0.5 color White]&lt;br /&gt;
      [1.0 color White filter 1]&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
  #declare Clouds3 = pigment {&lt;br /&gt;
    marble&lt;br /&gt;
    turbulence 1&lt;br /&gt;
    color_map {&lt;br /&gt;
      [0.0 color White filter 1]&lt;br /&gt;
      [0.5 color White]&lt;br /&gt;
      [1.0 color White filter 1]&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  #declare Clouds4 = pigment {&lt;br /&gt;
    granite&lt;br /&gt;
    turbulence 1&lt;br /&gt;
    color_map {&lt;br /&gt;
      [0.0 color White filter 1]&lt;br /&gt;
      [0.5 color White]&lt;br /&gt;
      [1.0 color White filter 1]&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;Now we use these declared pigments in our cloud layer on our planetoid. We&lt;br /&gt;
replace the declared cloud layer with.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  #declare CloudArea = texture {&lt;br /&gt;
    pigment {&lt;br /&gt;
      gradient y&lt;br /&gt;
      pigment_map {&lt;br /&gt;
        [0.00 Clouds1]&lt;br /&gt;
        [0.25 Clouds2]&lt;br /&gt;
        [0.50 Clouds3]&lt;br /&gt;
        [0.75 Clouds4]&lt;br /&gt;
        [1.00 Clouds1]&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;We render this and see a remarkable pattern that looks very much like&lt;br /&gt;
weather patterns on the planet earth. They are separated into bands,&lt;br /&gt;
simulating the different weather types found at different latitudes.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Normals===&lt;br /&gt;
&amp;lt;p&amp;gt;Objects in POV-Ray have very smooth surfaces. This is not very realistic&lt;br /&gt;
so there are several ways to disturb the smoothness of an object by&lt;br /&gt;
perturbing the surface normal. The surface normal is the vector that is&lt;br /&gt;
perpendicular to the angle of the surface. By changing this normal the&lt;br /&gt;
surface can be made to appear bumpy, wrinkled or any of the many patterns&lt;br /&gt;
available. Let's try a couple of them.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Using Basic Normal Modifiers===&lt;br /&gt;
&amp;lt;!--&amp;lt;indexentry &amp;quot;Normal Modifiers, using&amp;quot;&amp;gt;---&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;We comment out the planetoid sphere for now and, at the bottom of the&lt;br /&gt;
file, create a new sphere with a simple, single color texture.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  sphere {&lt;br /&gt;
    &amp;amp;lt;0,0,0&amp;amp;gt;, 1&lt;br /&gt;
    pigment { Gray75 }&lt;br /&gt;
    normal { bumps 1 scale .2 }&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;Here we have added a &amp;lt;code&amp;gt;normal&amp;lt;/code&amp;gt; block in addition to the &amp;lt;code&amp;gt;&lt;br /&gt;
pigment&amp;lt;/code&amp;gt; block (note that these do not have to be included in a &amp;lt;code&amp;gt;&lt;br /&gt;
texture&amp;lt;/code&amp;gt; block unless they need to be transformed together or need to&lt;br /&gt;
be part of a layered texture). We render this to see what it looks like. Now,&lt;br /&gt;
one at a time, we substitute for the keyword &amp;lt;code&amp;gt;&amp;lt;!--&amp;lt;linkto &amp;quot;bumps&amp;quot;&amp;gt;bumps&amp;lt;/linkto&amp;gt;---&amp;gt;[[Documentation:Reference Section 5.3#Bumps|bumps]]&amp;lt;/code&amp;gt; the following&lt;br /&gt;
keywords: &amp;lt;code&amp;gt;&amp;lt;!--&amp;lt;linkto &amp;quot;dents&amp;quot;&amp;gt;dents&amp;lt;/linkto&amp;gt;---&amp;gt;[[Documentation:Reference Section 5.3#Dents|dents]]&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;&amp;lt;!--&amp;lt;linkto &amp;quot;wrinkles&amp;quot;&amp;gt;wrinkles&amp;lt;/linkto&amp;gt;---&amp;gt;[[Documentation:Reference Section 5.5#Wrinkles|wrinkles]]&amp;lt;/code&amp;gt;,&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;!--&amp;lt;linkto &amp;quot;ripples&amp;quot;&amp;gt;ripples&amp;lt;/linkto&amp;gt;---&amp;gt;[[Documentation:Reference Section 5.5#Ripples|ripples]]&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;&amp;lt;!--&amp;lt;linkto &amp;quot;waves&amp;quot;&amp;gt;waves&amp;lt;/linkto&amp;gt;---&amp;gt;[[Documentation:Reference Section 5#Waves|waves]]&amp;lt;/code&amp;gt;&lt;br /&gt;
(we can also use any of the patterns listed in &amp;amp;quot;&amp;lt;!--&amp;lt;linkto &amp;quot;Patterns&amp;quot;&amp;gt;Patterns&amp;lt;/linkto&amp;gt;---&amp;gt;[[Documentation:Reference Section 5.3#Patterns|Patterns]]&amp;amp;quot;).&lt;br /&gt;
We render each to see what they look like. We play around with the float value that follows the&lt;br /&gt;
keyword. We also experiment with the scale value.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
For added interest, we change the plane texture to a single color with a&lt;br /&gt;
normal as follows.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  plane {&lt;br /&gt;
    y, -1.5&lt;br /&gt;
    pigment { color rgb &amp;amp;lt;.65, .45, .35&amp;amp;gt; }&lt;br /&gt;
    normal { dents .75 scale .25 }&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Blending Normals===&lt;br /&gt;
&amp;lt;!--&amp;lt;indexentry &amp;quot;Normals, blending&amp;quot;&amp;gt;---&amp;gt;&lt;br /&gt;
&amp;lt;!--&amp;lt;indexentry &amp;quot;normal_map, tutorial&amp;quot;&amp;gt;---&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;Normals can be layered similar to pigments but the results can be&lt;br /&gt;
unexpected. Let's try that now by editing the sphere as follows.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  sphere {&lt;br /&gt;
    &amp;amp;lt;0,0,0&amp;amp;gt;, 1&lt;br /&gt;
    pigment { Gray75 }&lt;br /&gt;
      normal { radial frequency 10 }&lt;br /&gt;
      normal { gradient y scale .2 }&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;As we can see, the resulting pattern is neither a radial nor a gradient.&lt;br /&gt;
It is instead the result of first calculating a radial pattern and then&lt;br /&gt;
calculating a gradient pattern. The results are simply additive. This can be&lt;br /&gt;
difficult to control so POV-Ray gives the user other ways to blend&lt;br /&gt;
normals.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
One way is to use normal maps. A normal map works the same way as the&lt;br /&gt;
pigment map we used earlier. Let's change our sphere texture as&lt;br /&gt;
follows.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  sphere {&lt;br /&gt;
    &amp;amp;lt;0,0,0&amp;amp;gt;, 1&lt;br /&gt;
    pigment { Gray75 }&lt;br /&gt;
    normal {&lt;br /&gt;
      gradient y&lt;br /&gt;
      frequency 3&lt;br /&gt;
      turbulence .5&lt;br /&gt;
      normal_map {&lt;br /&gt;
        [0.00 granite]&lt;br /&gt;
        [0.25 spotted turbulence .35]&lt;br /&gt;
        [0.50 marble turbulence .5]&lt;br /&gt;
        [0.75 bozo turbulence .25]&lt;br /&gt;
        [1.00 granite]&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;Rendering this we see that the sphere now has a very irregular bumpy&lt;br /&gt;
surface. The gradient pattern type separates the normals into bands but they&lt;br /&gt;
are turbulated, giving the surface a chaotic appearance. But this gives us an&lt;br /&gt;
idea.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
Suppose we use the same pattern for a normal map that we used to create the&lt;br /&gt;
oceans on our planetoid and applied it to the land areas. Does it follow that&lt;br /&gt;
if we use the same pattern and modifiers on a sphere the same size that the&lt;br /&gt;
shape of the pattern would be the same? Would not that make the land areas&lt;br /&gt;
bumpy while leaving the oceans smooth? Let's try it. First, let's&lt;br /&gt;
render the two spheres side-by-side so we can see if the pattern is indeed&lt;br /&gt;
the same. We un-comment the planetoid sphere and make the following&lt;br /&gt;
changes.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  sphere {&lt;br /&gt;
    &amp;amp;lt;0,0,0&amp;amp;gt;, 1&lt;br /&gt;
    texture { LandArea }&lt;br /&gt;
    texture { OceanArea }&lt;br /&gt;
    //texture { CloudArea }  // &amp;amp;lt;-comment this out&lt;br /&gt;
    translate -x             // &amp;amp;lt;- add this transformation&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;Now we change the gray sphere as follows.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  sphere {&lt;br /&gt;
    &amp;amp;lt;0,0,0&amp;amp;gt;, 1&lt;br /&gt;
    pigment { Gray75 }&lt;br /&gt;
    normal {&lt;br /&gt;
      bozo&lt;br /&gt;
      turbulence .5&lt;br /&gt;
      lambda 2&lt;br /&gt;
      normal_map {&lt;br /&gt;
        [0.4 dents .15 scale .01]&lt;br /&gt;
        [0.6 agate turbulence 1]&lt;br /&gt;
        [1.0 dents .15 scale .01]&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    translate x // &amp;amp;lt;- add this transformation&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;We render this to see if the pattern is the same. We see that indeed it&lt;br /&gt;
is. So let's comment out the gray sphere and add the &amp;lt;code&amp;gt;normal&amp;lt;/code&amp;gt;&lt;br /&gt;
block it contains to the land area texture of our planetoid. We remove the&lt;br /&gt;
transformations so that the planetoid is centered in the scene again.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  #declare LandArea = texture {&lt;br /&gt;
    pigment {&lt;br /&gt;
      agate&lt;br /&gt;
      turbulence 1&lt;br /&gt;
      lambda 1.5&lt;br /&gt;
      omega .8&lt;br /&gt;
      octaves 8&lt;br /&gt;
      color_map {&lt;br /&gt;
        [0.00 color rgb &amp;amp;lt;.5, .25, .15&amp;amp;gt;]&lt;br /&gt;
        [0.33 color rgb &amp;amp;lt;.1, .5, .4&amp;amp;gt;]&lt;br /&gt;
        [0.86 color rgb &amp;amp;lt;.6, .3, .1&amp;amp;gt;]&lt;br /&gt;
        [1.00 color rgb &amp;amp;lt;.5, .25, .15&amp;amp;gt;]&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    normal {&lt;br /&gt;
      bozo&lt;br /&gt;
      turbulence .5&lt;br /&gt;
      lambda 2&lt;br /&gt;
      normal_map {&lt;br /&gt;
        [0.4 dents .15 scale .01]&lt;br /&gt;
        [0.6 agate turbulence 1]&lt;br /&gt;
        [1.0 dents .15 scale .01]&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;Looking at the resulting image we see that indeed our idea works! The land&lt;br /&gt;
areas are bumpy while the oceans are smooth. We add the cloud layer back in&lt;br /&gt;
and our planetoid is complete.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
There is much more that we did not cover here due to space constraints. On&lt;br /&gt;
our own, we should take the time to explore slope maps, average and bump&lt;br /&gt;
maps.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Slope Map Tutorial===&lt;br /&gt;
&amp;lt;!--&amp;lt;indexentry &amp;quot;slope_map, tutorial&amp;quot;&amp;gt;---&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;One of the most powerful texturing features of POV-Ray is normal perturbation (which is specified using the &amp;lt;code&amp;gt;normal&amp;lt;/code&amp;gt; block of an object texture). With this feature it's possible to emulate small surface displacement in a very efficient way, without actually having to modify the actual surface (which often would increase the complexity of the object considerably, resulting in much slower renders).&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;Slope maps are used to define more precisely how the normal perturbation is generated from a specified pattern. Slope maps are a very powerful feature often dismissed by many.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;As an example, let's create a simple scene with an object using normal perturbation:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
camera { location &amp;lt;0, 10, -7&amp;gt;*1.4 look_at 0 angle 35 }&lt;br /&gt;
light_source&lt;br /&gt;
{ &amp;lt;100, 80, -30&amp;gt;, 1 area_light z*20, y*20, 12, 12 adaptive 0 }&lt;br /&gt;
plane { y, 0 pigment { rgb 1 } }&lt;br /&gt;
&lt;br /&gt;
cylinder&lt;br /&gt;
{ 0, y, 4&lt;br /&gt;
  pigment { rgb &amp;lt;1, .9, .2&amp;gt; }&lt;br /&gt;
  finish { specular 1 }&lt;br /&gt;
  normal&lt;br /&gt;
  { wood 1&lt;br /&gt;
    rotate x*90&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;[[Image:TutImgSlopemap1.jpg|Normal modifier example]]&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;By default the &amp;lt;code&amp;gt;wood&amp;lt;/code&amp;gt; pattern uses a ramp wave (going from 0 to 1 and then back to 0) arranged in concentric circles, as we can see from the image.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;By default POV-Ray simply takes the values of the pattern as they are in order to calculate the normal perturbation of the surface. However, using a &amp;lt;code&amp;gt;slope_map&amp;lt;/code&amp;gt; we can more precisely define how these values are interpreted. For example, if we add this &amp;lt;code&amp;gt;slope_map&amp;lt;/code&amp;gt; (the meaning of the values are explained later in this tutorial) to the &amp;lt;code&amp;gt;normal&amp;lt;/code&amp;gt; block in the example above:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    slope_map&lt;br /&gt;
    { [0 &amp;lt;0, 0&amp;gt;]&lt;br /&gt;
      [.2 &amp;lt;1, 1&amp;gt;]&lt;br /&gt;
      [.2 &amp;lt;1, 0&amp;gt;]&lt;br /&gt;
      [.8 &amp;lt;1, 0&amp;gt;]&lt;br /&gt;
      [.8 &amp;lt;1, -1&amp;gt;]&lt;br /&gt;
      [1 &amp;lt;0, 0&amp;gt;]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;we get a much more interesting result:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;[[Image:TutImgSlopemap2.jpg|Slope map example 1]]&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;We can also use a slope map to simply smooth out the original ramp wave pattern like this:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    slope_map&lt;br /&gt;
    { [0 &amp;lt;0, 0&amp;gt;]&lt;br /&gt;
      [.5 &amp;lt;.5, 1&amp;gt;]&lt;br /&gt;
      [1 &amp;lt;1, 0&amp;gt;]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;[[Image:TutImgSlopemap3.jpg|Slope map example 2]]&amp;lt;/p&amp;gt;&lt;br /&gt;
====Slopes, what are they?====&lt;br /&gt;
&amp;lt;p&amp;gt;Mathematically speaking the slope of a curve (also called gradient) at a certain point is the &amp;lt;code&amp;gt;tan()&amp;lt;/code&amp;gt; of the angle of the tangent line of that curve at that point. In other words, it's the amount of change of the vertical coordinate with respect to the change of the horizontal coordinate.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;In a more colloquial way, the slope of a completely horizontal part of the curve is 0. The slope of a 45-degree line is 1 (because for each unit in the horizontal direction the line goes up by the same amount). Lines between 0 and 45 degrees have corresponding slopes between 0 and 1 (the relation between them is not linear, though, but one usually doesn't have to worry about that). Lines with an angle of over 45 degrees have correspondently slopes increasingly larger than 1 (a line of 90 degrees has an infinite slope).&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;Usually when defining slope maps it's enough to keep between slopes of 0 and 1, even though higher slopes are sometimes useful too to get steeper changes. Usually it's enough to think that a slope of 0 means a horizontal part of the curve while a slope of 1 means a 45-degree steep part of the curve (and slopes between 0 and 1 correspond to degrees between 0 and 45 respectively).&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;A slope can be negative too. A negative slope simply means that the curve is going down instead of going up.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;The following figure shows some basic slopes in a curve (note that the slope values are only approximate):&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;[[Image:TutImgSlopemap4.png|Slopes in a curve]]&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Syntax of a slope map====&lt;br /&gt;
&amp;lt;p&amp;gt;In the exact same way as for example a &amp;lt;code&amp;gt;color_map&amp;lt;/code&amp;gt; assigns colors to pattern values, a &amp;lt;code&amp;gt;slope_map&amp;lt;/code&amp;gt; assign slopes to pattern values. If you are fluent in defining color maps for a pattern, defining a slope map shouldn't be any more difficult.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;Each entry in a slope map takes two values: The &amp;quot;displacement&amp;quot; of the surface (although one should remember that this displacement is only simulated, not real) and the slope of the surface at that point.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;You can think of the first parameter as an &amp;quot;altitude&amp;quot; value which tells how much the surface (in relative terms) is displaced from its original location. Usually values between 0 and 1 are used for this. You can think of 0 meaning that the surface is not displaced and 1 as the surface having maximum displacement (outwards).&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;Let's examine the slope map we used to &amp;quot;smooth out&amp;quot; the wood pattern at the beginning of this tutorial:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    slope_map&lt;br /&gt;
    { [0 &amp;lt;0, 0&amp;gt;]&lt;br /&gt;
      [.5 &amp;lt;.5, 1&amp;gt;]&lt;br /&gt;
      [1 &amp;lt;1, 0&amp;gt;]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;This means:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;When the pattern has a value of 0, the surface is not displaced and the slope of the surface is 0 (ie. it's horizontal).&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;When the pattern has a value of 0.5, the surface is displaced by 0.5 and the slope of the surface is 1.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;When the pattern has a value of 1, the surface has maximum displacement and the slope is again 0, ie. horizontal.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;When the pattern is linear (as the wood pattern is), this kind of slope map corresponds approximately to a half sine wave. Since the wood pattern uses a ramp wave (ie. after going from 0 to 1 it then goes from 1 to 0), the result is basically a complete (approximate) sine wave.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;As with a color map, all the values in between are interpolated and that's why we get a smooth transition between these values.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Examples of slope maps====&lt;br /&gt;
&amp;lt;p&amp;gt;As we saw in the first slope map example in this tutorial, it is possible to create sharp transitions, not just smooth ones. This is achieved in the same way as how sharp transitions are achieved with color maps: By repeating the same pattern value. Here is an example:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    slope_map&lt;br /&gt;
    { [0 &amp;lt;0, 1&amp;gt;]&lt;br /&gt;
      [.5 &amp;lt;1, 1&amp;gt;]&lt;br /&gt;
      [.5 &amp;lt;1, -.3&amp;gt;]&lt;br /&gt;
      [1 &amp;lt;.7, -.3&amp;gt;]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;[[Image:TutImgSlopemap5.jpg|Slope map example 3]]&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;There's a sharp transition at the pattern value 0.5, where the surface goes from slope 1 to slope -0.3 (ie. from going strongly upwards to going slightly downwards). Due to how the wood pattern repeats itself, there are also sharp transitions at the pattern values 0 and 1.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;We can combine sharp and smooth transitions for nice effects. For example, this simple slope map achieves a nice result:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    slope_map&lt;br /&gt;
    { [0 &amp;lt;0, 1&amp;gt;]&lt;br /&gt;
      [1 &amp;lt;1, 0&amp;gt;]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;[[Image:TutImgSlopemap6.jpg|Slope map example 4]]&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;At the pattern value 0 the &amp;quot;displacement&amp;quot; of the surface is 0 and the slope is 1 (ie. strongly upwards).&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;At the pattern value 1 the surface is fully &amp;quot;displaced&amp;quot; and horizontal.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Due to the ramp-wave-repetition quality of the wood pattern (which effectively reverses this pattern), the surface then continues smoothly from this point until it &amp;quot;descends&amp;quot; to 0, where the slope is now effectively -1. Now there's a sharp transition from -1 back to 1 as the pattern starts over.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;One application where slope maps are really useful is when creating tiled floors. When the tiles on a floor are not too close to the camera and there is a very large amount of tiles, instead of creating hundreds or thousands of individual tile objects, it may be more efficient to simply create a normal pattern which emulates the tiles.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;This example shows how to create a floor made of wooden &amp;amp;quote;planks&amp;amp;quote;:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
camera { location &amp;lt;2, 10, -12&amp;gt;*.5 look_at 0 angle 35 }&lt;br /&gt;
light_source&lt;br /&gt;
{ &amp;lt;100, 150, 0&amp;gt;, 1 area_light z*40, y*40, 12, 12 adaptive 0 }&lt;br /&gt;
sphere { y*.5, .5 pigment { rgb x } finish { specular .5 } }&lt;br /&gt;
&lt;br /&gt;
plane&lt;br /&gt;
{ y, 0&lt;br /&gt;
  pigment&lt;br /&gt;
  { wood color_map { [0 rgb &amp;lt;.9,.7,.3&amp;gt;][1 rgb &amp;lt;.8,.5,.2&amp;gt;] }&lt;br /&gt;
    turbulence .5&lt;br /&gt;
    scale &amp;lt;1, 1, 20&amp;gt;*.2&lt;br /&gt;
  }&lt;br /&gt;
  finish { specular 1 }&lt;br /&gt;
  normal&lt;br /&gt;
  { gradient x 1&lt;br /&gt;
    slope_map&lt;br /&gt;
    { [0 &amp;lt;0, 1&amp;gt;] // 0 height, strong slope up&lt;br /&gt;
      [.05 &amp;lt;1, 0&amp;gt;] // maximum height, horizontal&lt;br /&gt;
      [.95 &amp;lt;1, 0&amp;gt;] // maximum height, horizontal&lt;br /&gt;
      [1 &amp;lt;0, -1&amp;gt;] // 0 height, strong slope down&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;[[Image:TutImgSlopemap7.jpg|Slope map example 5]]&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;In this case a gradient pattern was used. Since the gradient pattern goes from 0 to 1 and then immediately back to 0, we have to mirror the slope map (around 0.5) in order to get a repetitive symmetric result.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;In this example the slope map starts from 0 height and a strong slope up, and goes quickly to maximum height, where the surface is horizontal. Then there's a large horizontal area (from pattern value 0.5 to 0.95) after which the slope goes rapidly back down to 0 height and a strong slope down. (After this there's a sharp transition to the beginning due to the gradient pattern starting over.)&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;If we want square tiles instead of just &amp;quot;planks&amp;quot;, we can achieve that by eg. using an average normal map like this:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  #declare TileNormal =&lt;br /&gt;
    normal&lt;br /&gt;
    { gradient x 2 // Double the strength because of the averaging&lt;br /&gt;
      slope_map&lt;br /&gt;
      { [0 &amp;lt;0, 1&amp;gt;] // 0 height, strong slope up&lt;br /&gt;
        [.05 &amp;lt;1, 0&amp;gt;] // maximum height, horizontal&lt;br /&gt;
        [.95 &amp;lt;1, 0&amp;gt;] // maximum height, horizontal&lt;br /&gt;
        [1 &amp;lt;0, -1&amp;gt;] // 0 height, strong slope down&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
  normal&lt;br /&gt;
  { average normal_map&lt;br /&gt;
    { [1 TileNormal]&lt;br /&gt;
      [1 TileNormal rotate y*90]&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;[[Image:TutImgSlopemap8.jpg|Slope map example 6]]&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;If we change the pigment of the plane a bit, we get a nice tiled floor:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  pigment&lt;br /&gt;
  { checker&lt;br /&gt;
    pigment { granite color_map { [0 rgb 1][1 rgb .9] } }&lt;br /&gt;
    pigment { granite color_map { [0 rgb .9][1 rgb .7] } }&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;[[Image:TutImgSlopemap9.jpg|Slope map example 7]]&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;As you can see in the image, close to the camera it's more evident that the tiles are not truely three-dimensional (and that only a normal perturbation trick has been used), but farther away from the camera the effect is pretty convincing.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Finishes===&lt;br /&gt;
&amp;lt;!--&amp;lt;indexentry &amp;quot;finish, tutorial&amp;quot;&amp;gt;---&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;The final part of a POV-Ray texture is the &amp;lt;code&amp;gt;&amp;lt;!--&amp;lt;linkto &amp;quot;finish&amp;quot;&amp;gt;finish&amp;lt;/linkto&amp;gt;---&amp;gt;[[Documentation:Reference Section 5.1#Finish|finish]]&amp;lt;/code&amp;gt;. It&lt;br /&gt;
controls the properties of the surface of an object. It can make it shiny and&lt;br /&gt;
reflective, or dull and flat. It can also specify what happens to light that&lt;br /&gt;
passes through transparent pigments, what happens to light that is scattered&lt;br /&gt;
by less-than-perfectly-smooth surfaces and what happens to light that is&lt;br /&gt;
reflected by surfaces with thin-film interference properties. There are&lt;br /&gt;
twelve different properties available in POV-Ray to specify the finish of a&lt;br /&gt;
given object. These are controlled by the following keywords: &amp;lt;code&amp;gt;&amp;lt;!--&amp;lt;linkto &amp;quot;ambient&amp;quot;&amp;gt;ambient&amp;lt;/linkto&amp;gt;---&amp;gt;[[Documentation:Reference Section 5.1#Ambient|ambient]]&amp;lt;/code&amp;gt;,&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;!--&amp;lt;linkto &amp;quot;diffuse&amp;quot;&amp;gt;diffuse&amp;lt;/linkto&amp;gt;---&amp;gt;[[Documentation:Reference Section 5.1#Diffuse|diffuse]]&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;&amp;lt;!--&amp;lt;linkto &amp;quot;brilliance&amp;quot;&amp;gt;brilliance&amp;lt;/linkto&amp;gt;---&amp;gt;[[Documentation:Reference Section 5.1#Brilliance|brilliance]]&amp;lt;/code&amp;gt;,&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;!--&amp;lt;linkto &amp;quot;phong&amp;quot;&amp;gt;phong&amp;lt;/linkto&amp;gt;---&amp;gt;[[Documentation:Reference Section 5.1#Phong Highlights|phong]]&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;&amp;lt;!--&amp;lt;linkto &amp;quot;specular&amp;quot;&amp;gt;specular&amp;lt;/linkto&amp;gt;---&amp;gt;[[Documentation:Reference Section 5.1#Specular Highlight|specular]]&amp;lt;/code&amp;gt;,&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;!--&amp;lt;linkto &amp;quot;metallic&amp;quot;&amp;gt;metallic&amp;lt;/linkto&amp;gt;---&amp;gt;[[Documentation:Reference Section 5.1#Metallic Highlight Modifier|metallic]]&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;&amp;lt;!--&amp;lt;linkto &amp;quot;reflection&amp;quot;&amp;gt;reflection&amp;lt;/linkto&amp;gt;---&amp;gt;[[Documentation:Reference Section 5.2#Specular Reflection|reflection]]&amp;lt;/code&amp;gt;,&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;!--&amp;lt;linkto &amp;quot;crand&amp;quot;&amp;gt;crand&amp;lt;/linkto&amp;gt;---&amp;gt;[[Documentation:Reference Section 5.1#Crand Graininess|crand]]&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;&amp;lt;!--&amp;lt;linkto &amp;quot;iridescence&amp;quot;&amp;gt;iridescence&amp;lt;/linkto&amp;gt;---&amp;gt;[[Documentation:Reference Section 5.2#Iridescence|iridescence]]&amp;lt;/code&amp;gt;.&lt;br /&gt;
Let's design a couple of textures that make use of these parameters.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Using Ambient===&lt;br /&gt;
&amp;lt;!--&amp;lt;indexentry &amp;quot;Ambient, using&amp;quot;&amp;gt;---&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;Since objects in POV-Ray are illuminated by light sources, the portions of&lt;br /&gt;
those objects that are in shadow would be completely black were it not for&lt;br /&gt;
the first two finish properties, &amp;lt;code&amp;gt;&amp;lt;!--&amp;lt;linkto &amp;quot;ambient&amp;quot;&amp;gt;ambient&amp;lt;/linkto&amp;gt;---&amp;gt;[[Documentation:Reference Section 5.1#Ambient|ambient]]&amp;lt;/code&amp;gt; and&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;!--&amp;lt;linkto &amp;quot;diffuse&amp;quot;&amp;gt;diffuse&amp;lt;/linkto&amp;gt;---&amp;gt;[[Documentation:Reference Section 5.1#Diffuse|diffuse]]&amp;lt;/code&amp;gt;. Ambient is used to simulate the light that is scattered&lt;br /&gt;
around the scene that does not come directly from a light source. Diffuse&lt;br /&gt;
determines how much of the light that is seen comes directly from a light&lt;br /&gt;
source. These two keywords work together to control the simulation of ambient&lt;br /&gt;
light. Let's use our gray sphere to demonstrate this. Let's also&lt;br /&gt;
change our plane back to its original green and white checkered pattern.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  plane {&lt;br /&gt;
    y, -1.5&lt;br /&gt;
    pigment {checker Green, White}&lt;br /&gt;
  }&lt;br /&gt;
  sphere {&lt;br /&gt;
    &amp;amp;lt;0,0,0&amp;amp;gt;, 1&lt;br /&gt;
    pigment { Gray75 }&lt;br /&gt;
    finish {&lt;br /&gt;
      ambient .2&lt;br /&gt;
      diffuse .6&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;In the above example, the default values for ambient and diffuse are used.&lt;br /&gt;
We render this to see what the effect is and then make the following change&lt;br /&gt;
to the finish.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  ambient 0&lt;br /&gt;
  diffuse 0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;The sphere is black because we have specified that none of the light&lt;br /&gt;
coming from any light source will be reflected by the sphere. Let's&lt;br /&gt;
change &amp;lt;code&amp;gt;diffuse&amp;lt;/code&amp;gt; back to the default of 0.6.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
Now we see the gray surface color where the light from the light source&lt;br /&gt;
falls directly on the sphere but the shaded side is still absolutely black.&lt;br /&gt;
Now let's change &amp;lt;code&amp;gt;diffuse&amp;lt;/code&amp;gt; to 0.3 and &amp;lt;code&amp;gt;ambient&amp;lt;/code&amp;gt; to&lt;br /&gt;
0.3.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
The sphere now looks almost flat. This is because we have specified a fairly&lt;br /&gt;
high degree of ambient light and only a low amount of the light coming from&lt;br /&gt;
the light source is diffusely reflected towards the camera. The default&lt;br /&gt;
values of &amp;lt;code&amp;gt; ambient&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;diffuse&amp;lt;/code&amp;gt; are pretty good&lt;br /&gt;
averages and a good starting point. In most cases, an ambient value of 0.1&lt;br /&gt;
... 0.2 is sufficient and a diffuse value of 0.5 ... 0.7 will usually do the&lt;br /&gt;
job. There are a couple of exceptions. If we have a completely transparent&lt;br /&gt;
surface with high refractive and/or reflective values, low values of both&lt;br /&gt;
ambient and diffuse may be best. Here is an example:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sphere {&lt;br /&gt;
   &amp;amp;lt;0,0,0&amp;amp;gt;, 1&lt;br /&gt;
   pigment { White filter 1 }&lt;br /&gt;
   finish {&lt;br /&gt;
      ambient 0&lt;br /&gt;
      diffuse 0&lt;br /&gt;
      reflection .25&lt;br /&gt;
      specular 1&lt;br /&gt;
      roughness .001&lt;br /&gt;
   }&lt;br /&gt;
   interior { ior 1.33 }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;This is glass, obviously. Glass is a material that takes nearly all of its&lt;br /&gt;
appearance from its surroundings. Very little of the surface is seen because&lt;br /&gt;
it transmits or reflects practically all of the light that shines on it. See&lt;br /&gt;
&amp;lt;code&amp;gt;glass.inc&amp;lt;/code&amp;gt; for some other examples.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
If we ever need an object to be completely illuminated independently of the&lt;br /&gt;
lighting situation in a given scene we can do this artificially by specifying&lt;br /&gt;
an &amp;lt;code&amp;gt;ambient&amp;lt;/code&amp;gt; value of 1 and a &amp;lt;code&amp;gt;diffuse&amp;lt;/code&amp;gt; value of 0.&lt;br /&gt;
This will eliminate all shading and simply give the object its fullest and&lt;br /&gt;
brightest color value at all points. This is good for simulating objects that&lt;br /&gt;
emit light like light bulbs and for skies in scenes where the sky may not be&lt;br /&gt;
adequately lit by any other means.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
Let's try this with our sphere now.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  sphere {&lt;br /&gt;
     &amp;amp;lt;0,0,0&amp;amp;gt;, 1&lt;br /&gt;
     pigment { White }&lt;br /&gt;
     finish {&lt;br /&gt;
        ambient 1&lt;br /&gt;
        diffuse 0&lt;br /&gt;
     }&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;Rendering this we get a blinding white sphere with no visible highlights&lt;br /&gt;
or shaded parts. It would make a pretty good street light.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;!--&amp;lt;wikinav&amp;gt;---&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;table width=100% border=0 cellspacing=0 cellpadding=5&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td width=50% bgcolor=#EEEEEF&amp;gt;&lt;br /&gt;
[[Documentation:Tutorial Section 3.2#Writing the polynomial vector|Writing the polynomial vector]]&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td width=50% bgcolor=#EEEEEF align=right&amp;gt;&lt;br /&gt;
[[Documentation:Tutorial Section 3.4#Using Surface Highlights|Using Surface Highlights]]&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;!--&amp;lt;/wikinav&amp;gt;---&amp;gt;&lt;br /&gt;
&amp;lt;!--&amp;lt;wikitalk&amp;gt;---&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;table width=100% border=1 cellspacing=0 cellpadding=5&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td width=100% bgcolor=#FFEEEE&amp;gt;&lt;br /&gt;
This document is protected, so submissions, corrections and discussions should be held on this documents [[Documentation_Talk:Tutorial Section 3.3|talk]] page.&lt;br /&gt;
&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;!--&amp;lt;/wikitalk&amp;gt;---&amp;gt;&lt;/div&gt;</summary>
		<author><name>Chrisb</name></author>
	</entry>
	<entry>
		<id>https://wiki.povray.org/content?title=Documentation_Talk:Tutorial_Section_2.1&amp;diff=1926</id>
		<title>Documentation Talk:Tutorial Section 2.1</title>
		<link rel="alternate" type="text/html" href="https://wiki.povray.org/content?title=Documentation_Talk:Tutorial_Section_2.1&amp;diff=1926"/>
		<updated>2009-10-21T20:54:46Z</updated>

		<summary type="html">&lt;p&gt;Chrisb: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Contents&lt;br /&gt;
[hide]&lt;br /&gt;
&lt;br /&gt;
    * 1 CSG Intersection&lt;br /&gt;
    * 2 CSG Difference&lt;br /&gt;
    * 3 CSG Merge&lt;br /&gt;
    * 4 CSG Pitfalls&lt;br /&gt;
    * 5 Co-incident Surfaces&lt;br /&gt;
    * 6 The Light Source&lt;br /&gt;
    * 7 The Pointlight Source&lt;br /&gt;
    * 8 The Spotlight Source&lt;br /&gt;
    * 9 The Cylindrical Light Source&lt;br /&gt;
    * 10 The Area Light Source&lt;br /&gt;
    * 11 The Ambient Light Source&lt;br /&gt;
    * 12 Light Source Specials&lt;br /&gt;
    * 13 Using Shadowless Lights&lt;br /&gt;
    * 14 Assigning an Object to a Light Source&lt;br /&gt;
    * 15 Using Light Fading&lt;br /&gt;
    * 16 Simple Texture Options&lt;br /&gt;
    * 17 Surface Finishes&lt;br /&gt;
&lt;br /&gt;
CSG Intersection&lt;br /&gt;
&lt;br /&gt;
Now let's use these same spheres to illustrate the intersection CSG object. We change the word union to intersection and delete the scale and rotate statements:&lt;br /&gt;
&lt;br /&gt;
  intersection {&lt;br /&gt;
    sphere { &amp;lt;0, 0, 0&amp;gt;, 1&lt;br /&gt;
      translate -0.5*x&lt;br /&gt;
    }&lt;br /&gt;
    sphere { &amp;lt;0, 0, 0&amp;gt;, 1&lt;br /&gt;
      translate 0.5*x&lt;br /&gt;
    }&lt;br /&gt;
    pigment { Red }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
We trace the file and will see a lens-shaped object instead of the two spheres. This is because an intersection consists of the area shared by both shapes, in this case the lens-shaped area where the two spheres overlap. We like this lens-shaped object so we will use it to demonstrate differences.&lt;br /&gt;
CSG Difference&lt;br /&gt;
&lt;br /&gt;
We rotate the lens-shaped intersection about the y-axis so that the broad side is facing the camera.&lt;br /&gt;
&lt;br /&gt;
  intersection{&lt;br /&gt;
    sphere { &amp;lt;0, 0, 0&amp;gt;, 1&lt;br /&gt;
      translate -0.5*x&lt;br /&gt;
    }&lt;br /&gt;
    sphere { &amp;lt;0, 0, 0&amp;gt;, 1&lt;br /&gt;
      translate 0.5*x&lt;br /&gt;
    }&lt;br /&gt;
    pigment { Red }&lt;br /&gt;
    rotate 90*y&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
Let's create a cylinder and stick it right in the middle of the lens.&lt;br /&gt;
&lt;br /&gt;
  cylinder { &amp;lt;0, 0, -1&amp;gt; &amp;lt;0, 0, 1&amp;gt;, .35&lt;br /&gt;
    pigment { Blue }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
We render the scene to see the position of the cylinder. We will place a difference block around both the lens-shaped intersection and the cylinder like this:&lt;br /&gt;
&lt;br /&gt;
  difference {&lt;br /&gt;
    intersection {&lt;br /&gt;
      sphere { &amp;lt;0, 0, 0&amp;gt;, 1&lt;br /&gt;
        translate -0.5*x&lt;br /&gt;
      }&lt;br /&gt;
      sphere { &amp;lt;0, 0, 0&amp;gt;, 1&lt;br /&gt;
        translate 0.5*x&lt;br /&gt;
      }&lt;br /&gt;
      pigment { Red }&lt;br /&gt;
      rotate 90*y&lt;br /&gt;
    }&lt;br /&gt;
    cylinder { &amp;lt;0, 0, -1&amp;gt; &amp;lt;0, 0, 1&amp;gt;, .35&lt;br /&gt;
      pigment { Blue }&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
We render the file again and see the lens-shaped intersection with a neat hole in the middle of it where the cylinder was. The cylinder has been subtracted from the intersection. Note that the pigment of the cylinder causes the surface of the hole to be colored blue. If we eliminate this pigment the surface of the hole will be black, as this is the default color if no color is specified.&lt;br /&gt;
&lt;br /&gt;
OK, let's get a little wilder now. Let's declare our perforated lens object to give it a name. Let's also eliminate all textures in the declared object because we will want them to be in the final union instead.&lt;br /&gt;
&lt;br /&gt;
  #declare Lens_With_Hole = difference {&lt;br /&gt;
    intersection {&lt;br /&gt;
      sphere { &amp;lt;0, 0, 0&amp;gt;, 1&lt;br /&gt;
        translate -0.5*x&lt;br /&gt;
      }&lt;br /&gt;
      sphere { &amp;lt;0, 0, 0&amp;gt;, 1&lt;br /&gt;
        translate 0.5*x&lt;br /&gt;
      }&lt;br /&gt;
      rotate 90*y&lt;br /&gt;
    }&lt;br /&gt;
    cylinder { &amp;lt;0, 0, -1&amp;gt; &amp;lt;0, 0, 1&amp;gt;, .35 }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
Let's use a union to build a complex shape composed of copies of this object.&lt;br /&gt;
&lt;br /&gt;
  union {&lt;br /&gt;
    object { Lens_With_Hole translate &amp;lt;-.65, .65, 0&amp;gt; }&lt;br /&gt;
    object { Lens_With_Hole translate &amp;lt;.65, .65, 0&amp;gt; }&lt;br /&gt;
    object { Lens_With_Hole translate &amp;lt;-.65, -.65, 0&amp;gt; }&lt;br /&gt;
    object { Lens_With_Hole translate &amp;lt;.65, -.65, 0&amp;gt; }&lt;br /&gt;
    pigment { Red }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
We render the scene. An interesting object to be sure. But let's try something more. Let's make it a partially-transparent object by adding some filter to the pigment block.&lt;br /&gt;
&lt;br /&gt;
  union {&lt;br /&gt;
    object { Lens_With_Hole translate &amp;lt;-.65, .65, 0&amp;gt; }&lt;br /&gt;
    object { Lens_With_Hole translate &amp;lt;.65, .65, 0&amp;gt; }&lt;br /&gt;
    object { Lens_With_Hole translate &amp;lt;-.65, -.65, 0&amp;gt; }&lt;br /&gt;
    object { Lens_With_Hole translate &amp;lt;.65, -.65, 0&amp;gt; }&lt;br /&gt;
    pigment { Red filter .5 }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
We render the file again. This looks pretty good... only... we can see parts of each of the lens objects inside the union! This is not good.&lt;br /&gt;
CSG Merge&lt;br /&gt;
&lt;br /&gt;
This brings us to the fourth kind of CSG object, the merge. Merges are the same as unions, but the geometry of the objects in the CSG that is inside the merge is not traced. This should eliminate the problem with our object. Let's try it.&lt;br /&gt;
&lt;br /&gt;
  merge {&lt;br /&gt;
    object { Lens_With_Hole translate &amp;lt;-.65, .65, 0&amp;gt; }&lt;br /&gt;
    object { Lens_With_Hole translate &amp;lt;.65, .65, 0&amp;gt; }&lt;br /&gt;
    object { Lens_With_Hole translate &amp;lt;-.65, -.65, 0&amp;gt; }&lt;br /&gt;
    object { Lens_With_Hole translate &amp;lt;.65, -.65, 0&amp;gt; }&lt;br /&gt;
    pigment { Red filter .5 }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
Sure enough, it does!&lt;br /&gt;
CSG Pitfalls&lt;br /&gt;
&lt;br /&gt;
There is a severe pitfall in the CSG code that we have to be aware of.&lt;br /&gt;
Co-incident Surfaces&lt;br /&gt;
&lt;br /&gt;
POV-Ray uses inside/outside tests to determine the points at which a ray intersects a CSG object. A problem arises when the surfaces of two different shapes coincide because there is no way (due to the computer's floating-point accuracy) to tell whether a point on the coincident surface belongs to one shape or the other.&lt;br /&gt;
&lt;br /&gt;
Look at the following example where a cylinder is used to cut a hole in a larger box.&lt;br /&gt;
&lt;br /&gt;
  difference {&lt;br /&gt;
    box { -1, 1 pigment { Red } }&lt;br /&gt;
    cylinder { -z, z, 0.5 pigment { Green } }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
Note: that the vectors -1 and 1 in the box definition expand to &amp;lt;-1,-1,-1&amp;gt; and &amp;lt;1,1,1&amp;gt; respectively.&lt;br /&gt;
&lt;br /&gt;
If we trace this object we see red speckles where the hole is supposed to be. This is caused by the coincident surfaces of the cylinder and the box. One time the cylinder's surface is hit first by a viewing ray, resulting in the correct rendering of the hole, and another time the box is hit first, leading to a wrong result where the hole vanishes and red speckles appear. This problem can be avoided by increasing the size of the cylinder to get rid of the coincidence surfaces. This is done by:&lt;br /&gt;
&lt;br /&gt;
  difference {&lt;br /&gt;
    box { -1, 1 pigment { Red } }&lt;br /&gt;
    cylinder { -1.001*z, 1.001*z, 0.5 pigment { Green } }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
In general we have to make the subtracted object a little bit larger in a CSG difference. We just have to look for coincident surfaces and increase the subtracted object appropriately to get rid of those surfaces.&lt;br /&gt;
&lt;br /&gt;
The same problem occurs in CSG intersections and is also avoided by scaling some of the involved objects.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Light Source&lt;br /&gt;
&lt;br /&gt;
You know you have been raytracing too long when ...&lt;br /&gt;
... You take a photo course just to learn how to get the lighting right.&lt;br /&gt;
    -- Christoph Rieder &lt;br /&gt;
&lt;br /&gt;
In any ray-traced scene, the light needed to illuminate our objects and their surfaces must come from a light source. There are many kinds of light sources available in POV-Ray and careful use of the correct kind can yield very impressive results. Let's take a moment to explore some of the different kinds of light sources and their various parameters.&lt;br /&gt;
The Pointlight Source&lt;br /&gt;
&lt;br /&gt;
Pointlights are exactly what the name indicates. A pointlight has no size, is invisible and illuminates everything in the scene equally no matter how far away from the light source it may be (this behavior can be changed). This is the simplest and most basic light source. There are only two important parameters, location and color. Let's design a simple scene and place a pointlight source in it.&lt;br /&gt;
&lt;br /&gt;
We create a new file and name it litedemo.pov. We edit it as follows:&lt;br /&gt;
&lt;br /&gt;
  #include &amp;quot;colors.inc&amp;quot;&lt;br /&gt;
  #include &amp;quot;textures.inc&amp;quot;&lt;br /&gt;
  camera {&lt;br /&gt;
    location  &amp;lt;-4, 3, -9&amp;gt;&lt;br /&gt;
    look_at   &amp;lt;0, 0, 0&amp;gt;&lt;br /&gt;
    angle 48&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
We add the following simple objects:&lt;br /&gt;
&lt;br /&gt;
  plane {&lt;br /&gt;
    y, -1&lt;br /&gt;
    texture {&lt;br /&gt;
      pigment {&lt;br /&gt;
        checker&lt;br /&gt;
        color rgb&amp;lt;0.5, 0, 0&amp;gt;&lt;br /&gt;
        color rgb&amp;lt;0, 0.5, 0.5&amp;gt;&lt;br /&gt;
      }&lt;br /&gt;
      finish {&lt;br /&gt;
        diffuse 0.4&lt;br /&gt;
        ambient 0.2&lt;br /&gt;
        phong 1&lt;br /&gt;
        phong_size 100&lt;br /&gt;
        reflection 0.25&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  torus {&lt;br /&gt;
    1.5, 0.5&lt;br /&gt;
    texture { Brown_Agate }&lt;br /&gt;
    rotate &amp;lt;90, 160, 0&amp;gt;&lt;br /&gt;
    translate &amp;lt;-1, 1, 3&amp;gt;&lt;br /&gt;
  }&lt;br /&gt;
  box {&lt;br /&gt;
    &amp;lt;-1, -1, -1&amp;gt;, &amp;lt;1, 1, 1&amp;gt;&lt;br /&gt;
    texture { DMFLightOak }&lt;br /&gt;
    translate &amp;lt;2, 0, 2.3&amp;gt;&lt;br /&gt;
  }&lt;br /&gt;
  cone {&lt;br /&gt;
    &amp;lt;0,1,0&amp;gt;, 0, &amp;lt;0,0,0&amp;gt;, 1&lt;br /&gt;
    texture { PinkAlabaster }&lt;br /&gt;
    scale &amp;lt;1, 3, 1&amp;gt;&lt;br /&gt;
    translate &amp;lt;-2, -1, -1&amp;gt;&lt;br /&gt;
  }&lt;br /&gt;
  sphere {&lt;br /&gt;
    &amp;lt;0,0,0&amp;gt;,1&lt;br /&gt;
    texture { Sapphire_Agate }&lt;br /&gt;
    translate &amp;lt;1.5, 0, -2&amp;gt;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
Now we add a pointlight:&lt;br /&gt;
&lt;br /&gt;
  light_source {&lt;br /&gt;
    &amp;lt;2, 10, -3&amp;gt;&lt;br /&gt;
    color White&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
We render this and see that the objects are clearly visible with sharp shadows. The sides of curved objects nearest the light source are brightest in color with the areas that are facing away from the light source being darkest. We also note that the checkered plane is illuminated evenly all the way to the horizon. This allows us to see the plane, but it is not very realistic.&lt;br /&gt;
The Spotlight Source&lt;br /&gt;
&lt;br /&gt;
Spotlights are a very useful type of light source. They can be used to add highlights and illuminate features much as a photographer uses spots to do the same thing. To create a spotlight simply add the spotlight keyword to a regular point light. There are a few more parameters with spotlights than with pointlights. These are radius, falloff, falloff and point_at. The radius parameter is the angle of the fully illuminated cone. The falloff parameter is the angle of the umbra cone where the light falls off to darkness. The tightness is a parameter that determines the rate of the light falloff. The point_at parameter is just what it says, the location where the spotlight is pointing to. Let's change the light in our scene as follows:&lt;br /&gt;
&lt;br /&gt;
  light_source {&lt;br /&gt;
    &amp;lt;0, 10, -3&amp;gt;&lt;br /&gt;
    color White&lt;br /&gt;
    spotlight&lt;br /&gt;
    radius 15&lt;br /&gt;
    falloff 20&lt;br /&gt;
    tightness 10&lt;br /&gt;
    point_at &amp;lt;0, 0, 0&amp;gt;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
We render this and see that only the objects are illuminated. The rest of the plane and the outer portions of the objects are now unlit. There is a broad falloff area but the shadows are still razor sharp. Let's try fiddling with some of these parameters to see what they do. We change the falloff value to 16 (it must always be larger than the radius value) and render again. Now the falloff is very narrow and the objects are either brightly lit or in total darkness. Now we change falloff back to 20 and change the tightness value to 100 (higher is tighter) and render again. The spotlight appears to have gotten much smaller but what has really happened is that the falloff has become so steep that the radius actually appears smaller.&lt;br /&gt;
&lt;br /&gt;
We decide that a tightness value of 10 (the default) and a falloff value of 18 are best for this spotlight and we now want to put a few spots around the scene for effect. Let's place a slightly narrower blue and a red one in addition to the white one we already have:&lt;br /&gt;
&lt;br /&gt;
  light_source {&lt;br /&gt;
    &amp;lt;10, 10, -1&amp;gt;&lt;br /&gt;
    color Red&lt;br /&gt;
    spotlight&lt;br /&gt;
    radius 12&lt;br /&gt;
    falloff 14&lt;br /&gt;
    tightness 10&lt;br /&gt;
    point_at &amp;lt;2, 0, 0&amp;gt;&lt;br /&gt;
  }&lt;br /&gt;
  light_source {&lt;br /&gt;
    &amp;lt;-12, 10, -1&amp;gt;&lt;br /&gt;
    color Blue&lt;br /&gt;
    spotlight&lt;br /&gt;
    radius 12&lt;br /&gt;
    falloff 14&lt;br /&gt;
    tightness 10&lt;br /&gt;
    point_at &amp;lt;-2, 0, 0&amp;gt;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
Rendering this we see that the scene now has a wonderfully mysterious air to it. The three spotlights all converge on the objects making them blue on one side and red on the other with enough white in the middle to provide a balance.&lt;br /&gt;
The Cylindrical Light Source&lt;br /&gt;
&lt;br /&gt;
Spotlights are cone shaped, meaning that their effect will change with distance. The farther away from the spotlight an object is, the larger the apparent radius will be. But we may want the radius and falloff to be a particular size no matter how far away the spotlight is. For this reason, cylindrical light sources are needed. A cylindrical light source is just like a spotlight, except that the radius and falloff regions are the same no matter how far from the light source our object is. The shape is therefore a cylinder rather than a cone. We can specify a cylindrical light source by replacing the spotlight keyword with the cylinder keyword. We try this now with our scene by replacing all three spotlights with cylinder lights and rendering again. We see that the scene is much dimmer. This is because the cylindrical constraints do not let the light spread out like in a spotlight. Larger radius and falloff values are needed to do the job. We try a radius of 20 and a falloff of 30 for all three lights. That's the ticket!&lt;br /&gt;
The Area Light Source&lt;br /&gt;
&lt;br /&gt;
You know you have been raytracing too long when ...&lt;br /&gt;
... You wear fuzzy clothing to soften your shadow.&lt;br /&gt;
    -- Mark Kadela &lt;br /&gt;
&lt;br /&gt;
So far all of our light sources have one thing in common. They produce sharp shadows. This is because the actual light source is a point that is infinitely small. Objects are either in direct sight of the light, in which case they are fully illuminated, or they are not, in which case they are fully shaded. In real life, this kind of stark light and shadow situation exists only in outer space where the direct light of the sun pierces the total blackness of space. But here on Earth, light bends around objects, bounces off objects, and usually the source has some dimension, meaning that it can be partially hidden from sight (shadows are not sharp anymore). They have what is known as an umbra, or an area of fuzziness where there is neither total light or shade. In order to simulate these soft shadows, a ray-tracer must give its light sources dimension. POV-Ray accomplishes this with a feature known as an area light.&lt;br /&gt;
&lt;br /&gt;
Area lights have dimension in two axis'. These are specified by the first two vectors in the area light syntax. We must also specify how many lights are to be in the array. More will give us cleaner soft shadows but will take longer to render. Usually a 3*3 or a 5*5 array will suffice. We also have the option of specifying an adaptive value. The adaptive keyword tells the ray-tracer that it can adapt to the situation and send only the needed rays to determine the value of the pixel. If adaptive is not used, a separate ray will be sent for every light in the area light. This can really slow things down. The higher the adaptive value the cleaner the umbra will be but the longer the trace will take. Usually an adaptive value of 1 is sufficient. Finally, we probably should use the jitter keyword. This tells the ray-tracer to slightly move the position of each light in the area light so that the shadows appear truly soft instead of giving us an umbra consisting of closely banded shadows.&lt;br /&gt;
&lt;br /&gt;
OK, let's try one. We comment out the cylinder lights and add the following:&lt;br /&gt;
&lt;br /&gt;
  light_source {&lt;br /&gt;
    &amp;lt;2, 10, -3&amp;gt;&lt;br /&gt;
    color White&lt;br /&gt;
    area_light &amp;lt;5, 0, 0&amp;gt;, &amp;lt;0, 0, 5&amp;gt;, 5, 5&lt;br /&gt;
    adaptive 1&lt;br /&gt;
    jitter&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
This is a white area light centered at &amp;lt;2,10,-3&amp;gt;. It is 5 units (along the x-axis) by 5 units (along the z-axis) in size and has 25 (5*5) lights in it. We have specified adaptive 1 and jitter. We render this.&lt;br /&gt;
&lt;br /&gt;
Right away we notice two things. The trace takes quite a bit longer than it did with a point or a spotlight and the shadows are no longer sharp! They all have nice soft umbrae around them. Wait, it gets better.&lt;br /&gt;
&lt;br /&gt;
Spotlights and cylinder lights can be area lights too! Remember those sharp shadows from the spotlights in our scene? It would not make much sense to use a 5*5 array for a spotlight, but a smaller array might do a good job of giving us just the right amount of umbra for a spotlight. Let's try it. We comment out the area light and change the cylinder lights so that they read as follows:&lt;br /&gt;
&lt;br /&gt;
  light_source {&lt;br /&gt;
    &amp;lt;2, 10, -3&amp;gt;&lt;br /&gt;
    color White&lt;br /&gt;
    spotlight&lt;br /&gt;
    radius 15&lt;br /&gt;
    falloff 18&lt;br /&gt;
    tightness 10&lt;br /&gt;
    area_light &amp;lt;1, 0, 0&amp;gt;, &amp;lt;0, 0, 1&amp;gt;, 2, 2&lt;br /&gt;
    adaptive 1&lt;br /&gt;
    jitter&lt;br /&gt;
    point_at &amp;lt;0, 0, 0&amp;gt;&lt;br /&gt;
  }&lt;br /&gt;
  light_source {&lt;br /&gt;
    &amp;lt;10, 10, -1&amp;gt;&lt;br /&gt;
    color Red&lt;br /&gt;
    spotlight&lt;br /&gt;
    radius 12&lt;br /&gt;
    falloff 14&lt;br /&gt;
    tightness 10&lt;br /&gt;
    area_light &amp;lt;1, 0, 0&amp;gt;, &amp;lt;0, 0, 1&amp;gt;, 2, 2&lt;br /&gt;
    adaptive 1&lt;br /&gt;
    jitter&lt;br /&gt;
    point_at &amp;lt;2, 0, 0&amp;gt;&lt;br /&gt;
  }&lt;br /&gt;
  light_source {&lt;br /&gt;
    &amp;lt;-12, 10, -1&amp;gt;&lt;br /&gt;
    color Blue&lt;br /&gt;
    spotlight&lt;br /&gt;
    radius 12&lt;br /&gt;
    falloff 14&lt;br /&gt;
    tightness 10&lt;br /&gt;
    area_light &amp;lt;1, 0, 0&amp;gt;, &amp;lt;0, 0, 1&amp;gt;, 2, 2&lt;br /&gt;
    adaptive 1&lt;br /&gt;
    jitter&lt;br /&gt;
    point_at &amp;lt;-2, 0, 0&amp;gt;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
We now have three area-spotlights, one unit square consisting of an array of four (2*2) lights, three different colors, all shining on our scene. We render this and it appears to work perfectly. All our shadows have small, tight umbrae, just the sort we would expect to find on an object under a real spotlight.&lt;br /&gt;
The Ambient Light Source&lt;br /&gt;
&lt;br /&gt;
The ambient light source is used to simulate the effect of inter-diffuse reflection. If there was not inter-diffuse reflection all areas not directly lit by a light source would be completely dark. POV-Ray uses the ambient keyword to determine how much light coming from the ambient light source is reflected by a surface.&lt;br /&gt;
&lt;br /&gt;
By default the ambient light source, which emits its light everywhere and in all directions, is pure white (rgb &amp;lt;1,1,1&amp;gt;). Changing its color can be used to create interesting effects. First of all the overall light level of the scene can be adjusted easily. Instead of changing all ambient values in every finish only the ambient light source is modified. By assigning different colors we can create nice effects like a moody reddish ambient lighting. For more details about the ambient light source see &amp;quot;Ambient Light&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Below is an example of a red ambient light source.&lt;br /&gt;
&lt;br /&gt;
  global_settings { ambient_light rgb&amp;lt;1, 0, 0&amp;gt; }&lt;br /&gt;
&lt;br /&gt;
Light Source Specials&lt;br /&gt;
Using Shadowless Lights&lt;br /&gt;
&lt;br /&gt;
Light sources can be assigned the shadowless keyword and no shadows will be cast due to its presence in a scene. Sometimes, scenes are difficult to illuminate properly using the lights we have chosen to illuminate our objects. It is impractical and unrealistic to apply a higher ambient value to the texture of every object in the scene. So instead, we would place a couple of fill lights around the scene. Fill lights are simply dimmer lights with the shadowless keyword that act to boost the illumination of other areas of the scene that may not be lit well. Let's try using one in our scene.&lt;br /&gt;
&lt;br /&gt;
Remember the three colored area spotlights? We go back and un-comment them and comment out any other lights we have made. Now we add the following:&lt;br /&gt;
&lt;br /&gt;
  light_source {&lt;br /&gt;
    &amp;lt;0, 20, 0&amp;gt;&lt;br /&gt;
    color Gray50&lt;br /&gt;
    shadowless&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
This is a fairly dim light 20 units over the center of the scene. It will give a dim illumination to all objects including the plane in the background. We render it and see.&lt;br /&gt;
Assigning an Object to a Light Source&lt;br /&gt;
&lt;br /&gt;
Light sources are invisible. They are just a location where the light appears to be coming from. They have no true size or shape. If we want our light source to be a visible shape, we can use the looks_like keyword. We can specify that our light source can look like any object we choose. When we use looks_like, then no_shadow is applied to the object automatically. This is done so that the object will not block any illumination from the light source. If we want some blocking to occur (as in a lamp shade), it is better to simply use a union to do the same thing. Let's add such an object to our scene. Here is a light bulb we have made just for this purpose:&lt;br /&gt;
&lt;br /&gt;
  #declare Lightbulb = union {&lt;br /&gt;
    merge {&lt;br /&gt;
      sphere { &amp;lt;0,0,0&amp;gt;,1 }&lt;br /&gt;
      cylinder {&lt;br /&gt;
        &amp;lt;0,0,1&amp;gt;, &amp;lt;0,0,0&amp;gt;, 1&lt;br /&gt;
        scale &amp;lt;0.35, 0.35, 1.0&amp;gt;&lt;br /&gt;
        translate  0.5*z&lt;br /&gt;
      }&lt;br /&gt;
      texture {&lt;br /&gt;
        pigment {color rgb &amp;lt;1, 1, 1&amp;gt;}&lt;br /&gt;
        finish {ambient .8 diffuse .6}&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    cylinder {&lt;br /&gt;
      &amp;lt;0,0,1&amp;gt;, &amp;lt;0,0,0&amp;gt;, 1&lt;br /&gt;
      scale &amp;lt;0.4, 0.4, 0.5&amp;gt;&lt;br /&gt;
      texture { Brass_Texture }&lt;br /&gt;
      translate  1.5*z&lt;br /&gt;
    }&lt;br /&gt;
    rotate -90*x&lt;br /&gt;
    scale .5&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
Now we add the light source:&lt;br /&gt;
&lt;br /&gt;
  light_source {&lt;br /&gt;
    &amp;lt;0, 2, 0&amp;gt;&lt;br /&gt;
    color White&lt;br /&gt;
    looks_like { Lightbulb }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
Rendering this we see that a fairly believable light bulb now illuminates the scene. However, if we do not specify a high ambient value, the light bulb is not lit by the light source. On the plus side, all of the shadows fall away from the light bulb, just as they would in a real situation. The shadows are sharp, so let's make our bulb an area light:&lt;br /&gt;
&lt;br /&gt;
  light_source {&lt;br /&gt;
    &amp;lt;0, 2, 0&amp;gt;&lt;br /&gt;
    color White&lt;br /&gt;
    area_light &amp;lt;1, 0, 0&amp;gt;, &amp;lt;0, 1, 0&amp;gt;, 2, 2&lt;br /&gt;
    adaptive 1&lt;br /&gt;
    jitter&lt;br /&gt;
    looks_like { Lightbulb }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
We note that we have placed this area light in the x-y-plane instead of the x-z-plane. We also note that the actual appearance of the light bulb is not affected in any way by the light source. The bulb must be illuminated by some other light source or by, as in this case, a high ambient value.&lt;br /&gt;
Using Light Fading&lt;br /&gt;
&lt;br /&gt;
If it is realism we want, it is not realistic for the plane to be evenly illuminated off into the distance. In real life, light gets scattered as it travels so it diminishes its ability to illuminate objects the farther it gets from its source. To simulate this, POV-Ray allows us to use two keywords: fade_distance, which specifies the distance at which full illumination is achieved, and fade_power, an exponential value which determines the actual rate of attenuation. Let's apply these keywords to our fill light.&lt;br /&gt;
&lt;br /&gt;
First, we make the fill light a little brighter by changing Gray50 to Gray75. Now we change that fill light as follows:&lt;br /&gt;
&lt;br /&gt;
  light_source {&lt;br /&gt;
    &amp;lt;0, 20, 0&amp;gt;&lt;br /&gt;
    color Gray75&lt;br /&gt;
    fade_distance 5&lt;br /&gt;
    fade_power 1&lt;br /&gt;
    shadowless&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
This means that the full value of the fill light will be achieved at a distance of 5 units away from the light source. The fade power of 1 means that the falloff will be linear (the light falls off at a constant rate). We render this to see the result.&lt;br /&gt;
&lt;br /&gt;
That definitely worked! Now let's try a fade power of 2 and a fade distance of 10. Again, this works well. The falloff is much faster with a fade power of 2 so we had to raise the fade distance to 10.&lt;br /&gt;
Simple Texture Options&lt;br /&gt;
&lt;br /&gt;
The pictures rendered so far where somewhat boring regarding the appearance of the objects. Let's add some fancy features to the texture.&lt;br /&gt;
Surface Finishes&lt;br /&gt;
&lt;br /&gt;
One of the main features of a ray-tracer is its ability to do interesting things with surface finishes such as highlights and reflection. Let's add a nice little Phong highlight (shiny spot) to a sphere. To do this we need to add a finish keyword followed by a parameter. We change the definition of the sphere to this:&lt;br /&gt;
&lt;br /&gt;
  sphere {&lt;br /&gt;
    &amp;lt;0, 1, 2&amp;gt;, 2&lt;br /&gt;
    texture {&lt;br /&gt;
      pigment { color Yellow } //Yellow is pre-defined in COLORS.INC&lt;br /&gt;
      finish { phong 1 }&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
We render the scene. The phong keyword adds a highlight the same color of the light shining on the object. It adds a lot of credibility to the picture and makes the object look smooth and shiny. Lower values of phong will make the highlight less bright (values should be between 0 and 1).&lt;/div&gt;</summary>
		<author><name>Chrisb</name></author>
	</entry>
	<entry>
		<id>https://wiki.povray.org/content?title=Documentation_Talk:Tutorial_Section_2.1&amp;diff=1925</id>
		<title>Documentation Talk:Tutorial Section 2.1</title>
		<link rel="alternate" type="text/html" href="https://wiki.povray.org/content?title=Documentation_Talk:Tutorial_Section_2.1&amp;diff=1925"/>
		<updated>2009-10-21T20:51:34Z</updated>

		<summary type="html">&lt;p&gt;Chrisb: Created page with 'Contents [hide]      * 1 CSG Intersection     * 2 CSG Difference     * 3 CSG Merge     * 4 CSG Pitfalls     * 5 Co-incident Surfaces     * 6 The Light Source     * 7 The Pointlig…'&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Contents&lt;br /&gt;
[hide]&lt;br /&gt;
&lt;br /&gt;
    * 1 CSG Intersection&lt;br /&gt;
    * 2 CSG Difference&lt;br /&gt;
    * 3 CSG Merge&lt;br /&gt;
    * 4 CSG Pitfalls&lt;br /&gt;
    * 5 Co-incident Surfaces&lt;br /&gt;
    * 6 The Light Source&lt;br /&gt;
    * 7 The Pointlight Source&lt;br /&gt;
    * 8 The Spotlight Source&lt;br /&gt;
    * 9 The Cylindrical Light Source&lt;br /&gt;
    * 10 The Area Light Source&lt;br /&gt;
    * 11 The Ambient Light Source&lt;br /&gt;
    * 12 Light Source Specials&lt;br /&gt;
    * 13 Using Shadowless Lights&lt;br /&gt;
    * 14 Assigning an Object to a Light Source&lt;br /&gt;
    * 15 Using Light Fading&lt;br /&gt;
    * 16 Simple Texture Options&lt;br /&gt;
    * 17 Surface Finishes&lt;br /&gt;
&lt;br /&gt;
CSG Intersection&lt;br /&gt;
&lt;br /&gt;
Now let's use these same spheres to illustrate the intersection CSG object. We change the word union to intersection and delete the scale and rotate statements:&lt;br /&gt;
&lt;br /&gt;
  intersection {&lt;br /&gt;
    sphere { &amp;lt;0, 0, 0&amp;gt;, 1&lt;br /&gt;
      translate -0.5*x&lt;br /&gt;
    }&lt;br /&gt;
    sphere { &amp;lt;0, 0, 0&amp;gt;, 1&lt;br /&gt;
      translate 0.5*x&lt;br /&gt;
    }&lt;br /&gt;
    pigment { Red }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
We trace the file and will see a lens-shaped object instead of the two spheres. This is because an intersection consists of the area shared by both shapes, in this case the lens-shaped area where the two spheres overlap. We like this lens-shaped object so we will use it to demonstrate differences.&lt;br /&gt;
CSG Difference&lt;br /&gt;
&lt;br /&gt;
We rotate the lens-shaped intersection about the y-axis so that the broad side is facing the camera.&lt;br /&gt;
&lt;br /&gt;
  intersection{&lt;br /&gt;
    sphere { &amp;lt;0, 0, 0&amp;gt;, 1&lt;br /&gt;
      translate -0.5*x&lt;br /&gt;
    }&lt;br /&gt;
    sphere { &amp;lt;0, 0, 0&amp;gt;, 1&lt;br /&gt;
      translate 0.5*x&lt;br /&gt;
    }&lt;br /&gt;
    pigment { Red }&lt;br /&gt;
    rotate 90*y&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
Let's create a cylinder and stick it right in the middle of the lens.&lt;br /&gt;
&lt;br /&gt;
  cylinder { &amp;lt;0, 0, -1&amp;gt; &amp;lt;0, 0, 1&amp;gt;, .35&lt;br /&gt;
    pigment { Blue }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
We render the scene to see the position of the cylinder. We will place a difference block around both the lens-shaped intersection and the cylinder like this:&lt;br /&gt;
&lt;br /&gt;
  difference {&lt;br /&gt;
    intersection {&lt;br /&gt;
      sphere { &amp;lt;0, 0, 0&amp;gt;, 1&lt;br /&gt;
        translate -0.5*x&lt;br /&gt;
      }&lt;br /&gt;
      sphere { &amp;lt;0, 0, 0&amp;gt;, 1&lt;br /&gt;
        translate 0.5*x&lt;br /&gt;
      }&lt;br /&gt;
      pigment { Red }&lt;br /&gt;
      rotate 90*y&lt;br /&gt;
    }&lt;br /&gt;
    cylinder { &amp;lt;0, 0, -1&amp;gt; &amp;lt;0, 0, 1&amp;gt;, .35&lt;br /&gt;
      pigment { Blue }&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
We render the file again and see the lens-shaped intersection with a neat hole in the middle of it where the cylinder was. The cylinder has been subtracted from the intersection. Note that the pigment of the cylinder causes the surface of the hole to be colored blue. If we eliminate this pigment the surface of the hole will be black, as this is the default color if no color is specified.&lt;br /&gt;
&lt;br /&gt;
OK, let's get a little wilder now. Let's declare our perforated lens object to give it a name. Let's also eliminate all textures in the declared object because we will want them to be in the final union instead.&lt;br /&gt;
&lt;br /&gt;
  #declare Lens_With_Hole = difference {&lt;br /&gt;
    intersection {&lt;br /&gt;
      sphere { &amp;lt;0, 0, 0&amp;gt;, 1&lt;br /&gt;
        translate -0.5*x&lt;br /&gt;
      }&lt;br /&gt;
      sphere { &amp;lt;0, 0, 0&amp;gt;, 1&lt;br /&gt;
        translate 0.5*x&lt;br /&gt;
      }&lt;br /&gt;
      rotate 90*y&lt;br /&gt;
    }&lt;br /&gt;
    cylinder { &amp;lt;0, 0, -1&amp;gt; &amp;lt;0, 0, 1&amp;gt;, .35 }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
Let's use a union to build a complex shape composed of copies of this object.&lt;br /&gt;
&lt;br /&gt;
  union {&lt;br /&gt;
    object { Lens_With_Hole translate &amp;lt;-.65, .65, 0&amp;gt; }&lt;br /&gt;
    object { Lens_With_Hole translate &amp;lt;.65, .65, 0&amp;gt; }&lt;br /&gt;
    object { Lens_With_Hole translate &amp;lt;-.65, -.65, 0&amp;gt; }&lt;br /&gt;
    object { Lens_With_Hole translate &amp;lt;.65, -.65, 0&amp;gt; }&lt;br /&gt;
    pigment { Red }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
We render the scene. An interesting object to be sure. But let's try something more. Let's make it a partially-transparent object by adding some filter to the pigment block.&lt;br /&gt;
&lt;br /&gt;
  union {&lt;br /&gt;
    object { Lens_With_Hole translate &amp;lt;-.65, .65, 0&amp;gt; }&lt;br /&gt;
    object { Lens_With_Hole translate &amp;lt;.65, .65, 0&amp;gt; }&lt;br /&gt;
    object { Lens_With_Hole translate &amp;lt;-.65, -.65, 0&amp;gt; }&lt;br /&gt;
    object { Lens_With_Hole translate &amp;lt;.65, -.65, 0&amp;gt; }&lt;br /&gt;
    pigment { Red filter .5 }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
We render the file again. This looks pretty good... only... we can see parts of each of the lens objects inside the union! This is not good.&lt;br /&gt;
CSG Merge&lt;br /&gt;
&lt;br /&gt;
This brings us to the fourth kind of CSG object, the merge. Merges are the same as unions, but the geometry of the objects in the CSG that is inside the merge is not traced. This should eliminate the problem with our object. Let's try it.&lt;br /&gt;
&lt;br /&gt;
  merge {&lt;br /&gt;
    object { Lens_With_Hole translate &amp;lt;-.65, .65, 0&amp;gt; }&lt;br /&gt;
    object { Lens_With_Hole translate &amp;lt;.65, .65, 0&amp;gt; }&lt;br /&gt;
    object { Lens_With_Hole translate &amp;lt;-.65, -.65, 0&amp;gt; }&lt;br /&gt;
    object { Lens_With_Hole translate &amp;lt;.65, -.65, 0&amp;gt; }&lt;br /&gt;
    pigment { Red filter .5 }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
Sure enough, it does!&lt;br /&gt;
CSG Pitfalls&lt;br /&gt;
&lt;br /&gt;
There is a severe pitfall in the CSG code that we have to be aware of.&lt;br /&gt;
Co-incident Surfaces&lt;br /&gt;
&lt;br /&gt;
POV-Ray uses inside/outside tests to determine the points at which a ray intersects a CSG object. A problem arises when the surfaces of two different shapes coincide because there is no way (due to the computer's floating-point accuracy) to tell whether a point on the coincident surface belongs to one shape or the other.&lt;br /&gt;
&lt;br /&gt;
Look at the following example where a cylinder is used to cut a hole in a larger box.&lt;br /&gt;
&lt;br /&gt;
  difference {&lt;br /&gt;
    box { -1, 1 pigment { Red } }&lt;br /&gt;
    cylinder { -z, z, 0.5 pigment { Green } }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
Note: that the vectors -1 and 1 in the box definition expand to &amp;lt;-1,-1,-1&amp;gt; and &amp;lt;1,1,1&amp;gt; respectively.&lt;br /&gt;
&lt;br /&gt;
If we trace this object we see red speckles where the hole is supposed to be. This is caused by the coincident surfaces of the cylinder and the box. One time the cylinder's surface is hit first by a viewing ray, resulting in the correct rendering of the hole, and another time the box is hit first, leading to a wrong result where the hole vanishes and red speckles appear. This problem can be avoided by increasing the size of the cylinder to get rid of the coincidence surfaces. This is done by:&lt;br /&gt;
&lt;br /&gt;
  difference {&lt;br /&gt;
    box { -1, 1 pigment { Red } }&lt;br /&gt;
    cylinder { -1.001*z, 1.001*z, 0.5 pigment { Green } }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
In general we have to make the subtracted object a little bit larger in a CSG difference. We just have to look for coincident surfaces and increase the subtracted object appropriately to get rid of those surfaces.&lt;br /&gt;
&lt;br /&gt;
The same problem occurs in CSG intersections and is also avoided by scaling some of the involved objects.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Light Source&lt;br /&gt;
&lt;br /&gt;
You know you have been raytracing too long when ...&lt;br /&gt;
... You take a photo course just to learn how to get the lighting right.&lt;br /&gt;
    -- Christoph Rieder &lt;br /&gt;
&lt;br /&gt;
In any ray-traced scene, the light needed to illuminate our objects and their surfaces must come from a light source. There are many kinds of light sources available in POV-Ray and careful use of the correct kind can yield very impressive results. Let's take a moment to explore some of the different kinds of light sources and their various parameters.&lt;br /&gt;
The Pointlight Source&lt;br /&gt;
&lt;br /&gt;
Pointlights are exactly what the name indicates. A pointlight has no size, is invisible and illuminates everything in the scene equally no matter how far away from the light source it may be (this behavior can be changed). This is the simplest and most basic light source. There are only two important parameters, location and color. Let's design a simple scene and place a pointlight source in it.&lt;br /&gt;
&lt;br /&gt;
We create a new file and name it litedemo.pov. We edit it as follows:&lt;br /&gt;
&lt;br /&gt;
  #include &amp;quot;colors.inc&amp;quot;&lt;br /&gt;
  #include &amp;quot;textures.inc&amp;quot;&lt;br /&gt;
  camera {&lt;br /&gt;
    location  &amp;lt;-4, 3, -9&amp;gt;&lt;br /&gt;
    look_at   &amp;lt;0, 0, 0&amp;gt;&lt;br /&gt;
    angle 48&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
We add the following simple objects:&lt;br /&gt;
&lt;br /&gt;
  plane {&lt;br /&gt;
    y, -1&lt;br /&gt;
    texture {&lt;br /&gt;
      pigment {&lt;br /&gt;
        checker&lt;br /&gt;
        color rgb&amp;lt;0.5, 0, 0&amp;gt;&lt;br /&gt;
        color rgb&amp;lt;0, 0.5, 0.5&amp;gt;&lt;br /&gt;
      }&lt;br /&gt;
      finish {&lt;br /&gt;
        diffuse 0.4&lt;br /&gt;
        ambient 0.2&lt;br /&gt;
        phong 1&lt;br /&gt;
        phong_size 100&lt;br /&gt;
        reflection 0.25&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  torus {&lt;br /&gt;
    1.5, 0.5&lt;br /&gt;
    texture { Brown_Agate }&lt;br /&gt;
    rotate &amp;lt;90, 160, 0&amp;gt;&lt;br /&gt;
    translate &amp;lt;-1, 1, 3&amp;gt;&lt;br /&gt;
  }&lt;br /&gt;
  box {&lt;br /&gt;
    &amp;lt;-1, -1, -1&amp;gt;, &amp;lt;1, 1, 1&amp;gt;&lt;br /&gt;
    texture { DMFLightOak }&lt;br /&gt;
    translate &amp;lt;2, 0, 2.3&amp;gt;&lt;br /&gt;
  }&lt;br /&gt;
  cone {&lt;br /&gt;
    &amp;lt;0,1,0&amp;gt;, 0, &amp;lt;0,0,0&amp;gt;, 1&lt;br /&gt;
    texture { PinkAlabaster }&lt;br /&gt;
    scale &amp;lt;1, 3, 1&amp;gt;&lt;br /&gt;
    translate &amp;lt;-2, -1, -1&amp;gt;&lt;br /&gt;
  }&lt;br /&gt;
  sphere {&lt;br /&gt;
    &amp;lt;0,0,0&amp;gt;,1&lt;br /&gt;
    texture { Sapphire_Agate }&lt;br /&gt;
    translate &amp;lt;1.5, 0, -2&amp;gt;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
Now we add a pointlight:&lt;br /&gt;
&lt;br /&gt;
  light_source {&lt;br /&gt;
    &amp;lt;2, 10, -3&amp;gt;&lt;br /&gt;
    color White&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
We render this at 200x150 -A and see that the objects are clearly visible with sharp shadows. The sides of curved objects nearest the light source are brightest in color with the areas that are facing away from the light source being darkest. We also note that the checkered plane is illuminated evenly all the way to the horizon. This allows us to see the plane, but it is not very realistic.&lt;br /&gt;
The Spotlight Source&lt;br /&gt;
&lt;br /&gt;
Spotlights are a very useful type of light source. They can be used to add highlights and illuminate features much as a photographer uses spots to do the same thing. To create a spotlight simply add the spotlight keyword to a regular point light. There are a few more parameters with spotlights than with pointlights. These are radius, falloff, falloff and point_at. The radius parameter is the angle of the fully illuminated cone. The falloff parameter is the angle of the umbra cone where the light falls off to darkness. The tightness is a parameter that determines the rate of the light falloff. The point_at parameter is just what it says, the location where the spotlight is pointing to. Let's change the light in our scene as follows:&lt;br /&gt;
&lt;br /&gt;
  light_source {&lt;br /&gt;
    &amp;lt;0, 10, -3&amp;gt;&lt;br /&gt;
    color White&lt;br /&gt;
    spotlight&lt;br /&gt;
    radius 15&lt;br /&gt;
    falloff 20&lt;br /&gt;
    tightness 10&lt;br /&gt;
    point_at &amp;lt;0, 0, 0&amp;gt;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
We render this at 200x150 -A and see that only the objects are illuminated. The rest of the plane and the outer portions of the objects are now unlit. There is a broad falloff area but the shadows are still razor sharp. Let's try fiddling with some of these parameters to see what they do. We change the falloff value to 16 (it must always be larger than the radius value) and render again. Now the falloff is very narrow and the objects are either brightly lit or in total darkness. Now we change falloff back to 20 and change the tightness value to 100 (higher is tighter) and render again. The spotlight appears to have gotten much smaller but what has really happened is that the falloff has become so steep that the radius actually appears smaller.&lt;br /&gt;
&lt;br /&gt;
We decide that a tightness value of 10 (the default) and a falloff value of 18 are best for this spotlight and we now want to put a few spots around the scene for effect. Let's place a slightly narrower blue and a red one in addition to the white one we already have:&lt;br /&gt;
&lt;br /&gt;
  light_source {&lt;br /&gt;
    &amp;lt;10, 10, -1&amp;gt;&lt;br /&gt;
    color Red&lt;br /&gt;
    spotlight&lt;br /&gt;
    radius 12&lt;br /&gt;
    falloff 14&lt;br /&gt;
    tightness 10&lt;br /&gt;
    point_at &amp;lt;2, 0, 0&amp;gt;&lt;br /&gt;
  }&lt;br /&gt;
  light_source {&lt;br /&gt;
    &amp;lt;-12, 10, -1&amp;gt;&lt;br /&gt;
    color Blue&lt;br /&gt;
    spotlight&lt;br /&gt;
    radius 12&lt;br /&gt;
    falloff 14&lt;br /&gt;
    tightness 10&lt;br /&gt;
    point_at &amp;lt;-2, 0, 0&amp;gt;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
Rendering this we see that the scene now has a wonderfully mysterious air to it. The three spotlights all converge on the objects making them blue on one side and red on the other with enough white in the middle to provide a balance.&lt;br /&gt;
The Cylindrical Light Source&lt;br /&gt;
&lt;br /&gt;
Spotlights are cone shaped, meaning that their effect will change with distance. The farther away from the spotlight an object is, the larger the apparent radius will be. But we may want the radius and falloff to be a particular size no matter how far away the spotlight is. For this reason, cylindrical light sources are needed. A cylindrical light source is just like a spotlight, except that the radius and falloff regions are the same no matter how far from the light source our object is. The shape is therefore a cylinder rather than a cone. We can specify a cylindrical light source by replacing the spotlight keyword with the cylinder keyword. We try this now with our scene by replacing all three spotlights with cylinder lights and rendering again. We see that the scene is much dimmer. This is because the cylindrical constraints do not let the light spread out like in a spotlight. Larger radius and falloff values are needed to do the job. We try a radius of 20 and a falloff of 30 for all three lights. That's the ticket!&lt;br /&gt;
The Area Light Source&lt;br /&gt;
&lt;br /&gt;
You know you have been raytracing too long when ...&lt;br /&gt;
... You wear fuzzy clothing to soften your shadow.&lt;br /&gt;
    -- Mark Kadela &lt;br /&gt;
&lt;br /&gt;
So far all of our light sources have one thing in common. They produce sharp shadows. This is because the actual light source is a point that is infinitely small. Objects are either in direct sight of the light, in which case they are fully illuminated, or they are not, in which case they are fully shaded. In real life, this kind of stark light and shadow situation exists only in outer space where the direct light of the sun pierces the total blackness of space. But here on Earth, light bends around objects, bounces off objects, and usually the source has some dimension, meaning that it can be partially hidden from sight (shadows are not sharp anymore). They have what is known as an umbra, or an area of fuzziness where there is neither total light or shade. In order to simulate these soft shadows, a ray-tracer must give its light sources dimension. POV-Ray accomplishes this with a feature known as an area light.&lt;br /&gt;
&lt;br /&gt;
Area lights have dimension in two axis'. These are specified by the first two vectors in the area light syntax. We must also specify how many lights are to be in the array. More will give us cleaner soft shadows but will take longer to render. Usually a 3*3 or a 5*5 array will suffice. We also have the option of specifying an adaptive value. The adaptive keyword tells the ray-tracer that it can adapt to the situation and send only the needed rays to determine the value of the pixel. If adaptive is not used, a separate ray will be sent for every light in the area light. This can really slow things down. The higher the adaptive value the cleaner the umbra will be but the longer the trace will take. Usually an adaptive value of 1 is sufficient. Finally, we probably should use the jitter keyword. This tells the ray-tracer to slightly move the position of each light in the area light so that the shadows appear truly soft instead of giving us an umbra consisting of closely banded shadows.&lt;br /&gt;
&lt;br /&gt;
OK, let's try one. We comment out the cylinder lights and add the following:&lt;br /&gt;
&lt;br /&gt;
  light_source {&lt;br /&gt;
    &amp;lt;2, 10, -3&amp;gt;&lt;br /&gt;
    color White&lt;br /&gt;
    area_light &amp;lt;5, 0, 0&amp;gt;, &amp;lt;0, 0, 5&amp;gt;, 5, 5&lt;br /&gt;
    adaptive 1&lt;br /&gt;
    jitter&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
This is a white area light centered at &amp;lt;2,10,-3&amp;gt;. It is 5 units (along the x-axis) by 5 units (along the z-axis) in size and has 25 (5*5) lights in it. We have specified adaptive 1 and jitter. We render this at 200x150 -A.&lt;br /&gt;
&lt;br /&gt;
Right away we notice two things. The trace takes quite a bit longer than it did with a point or a spotlight and the shadows are no longer sharp! They all have nice soft umbrae around them. Wait, it gets better.&lt;br /&gt;
&lt;br /&gt;
Spotlights and cylinder lights can be area lights too! Remember those sharp shadows from the spotlights in our scene? It would not make much sense to use a 5*5 array for a spotlight, but a smaller array might do a good job of giving us just the right amount of umbra for a spotlight. Let's try it. We comment out the area light and change the cylinder lights so that they read as follows:&lt;br /&gt;
&lt;br /&gt;
  light_source {&lt;br /&gt;
    &amp;lt;2, 10, -3&amp;gt;&lt;br /&gt;
    color White&lt;br /&gt;
    spotlight&lt;br /&gt;
    radius 15&lt;br /&gt;
    falloff 18&lt;br /&gt;
    tightness 10&lt;br /&gt;
    area_light &amp;lt;1, 0, 0&amp;gt;, &amp;lt;0, 0, 1&amp;gt;, 2, 2&lt;br /&gt;
    adaptive 1&lt;br /&gt;
    jitter&lt;br /&gt;
    point_at &amp;lt;0, 0, 0&amp;gt;&lt;br /&gt;
  }&lt;br /&gt;
  light_source {&lt;br /&gt;
    &amp;lt;10, 10, -1&amp;gt;&lt;br /&gt;
    color Red&lt;br /&gt;
    spotlight&lt;br /&gt;
    radius 12&lt;br /&gt;
    falloff 14&lt;br /&gt;
    tightness 10&lt;br /&gt;
    area_light &amp;lt;1, 0, 0&amp;gt;, &amp;lt;0, 0, 1&amp;gt;, 2, 2&lt;br /&gt;
    adaptive 1&lt;br /&gt;
    jitter&lt;br /&gt;
    point_at &amp;lt;2, 0, 0&amp;gt;&lt;br /&gt;
  }&lt;br /&gt;
  light_source {&lt;br /&gt;
    &amp;lt;-12, 10, -1&amp;gt;&lt;br /&gt;
    color Blue&lt;br /&gt;
    spotlight&lt;br /&gt;
    radius 12&lt;br /&gt;
    falloff 14&lt;br /&gt;
    tightness 10&lt;br /&gt;
    area_light &amp;lt;1, 0, 0&amp;gt;, &amp;lt;0, 0, 1&amp;gt;, 2, 2&lt;br /&gt;
    adaptive 1&lt;br /&gt;
    jitter&lt;br /&gt;
    point_at &amp;lt;-2, 0, 0&amp;gt;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
We now have three area-spotlights, one unit square consisting of an array of four (2*2) lights, three different colors, all shining on our scene. We render this at 200x150 -A. It appears to work perfectly. All our shadows have small, tight umbrae, just the sort we would expect to find on an object under a real spotlight.&lt;br /&gt;
The Ambient Light Source&lt;br /&gt;
&lt;br /&gt;
The ambient light source is used to simulate the effect of inter-diffuse reflection. If there was not inter-diffuse reflection all areas not directly lit by a light source would be completely dark. POV-Ray uses the ambient keyword to determine how much light coming from the ambient light source is reflected by a surface.&lt;br /&gt;
&lt;br /&gt;
By default the ambient light source, which emits its light everywhere and in all directions, is pure white (rgb &amp;lt;1,1,1&amp;gt;). Changing its color can be used to create interesting effects. First of all the overall light level of the scene can be adjusted easily. Instead of changing all ambient values in every finish only the ambient light source is modified. By assigning different colors we can create nice effects like a moody reddish ambient lighting. For more details about the ambient light source see &amp;quot;Ambient Light&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Below is an example of a red ambient light source.&lt;br /&gt;
&lt;br /&gt;
  global_settings { ambient_light rgb&amp;lt;1, 0, 0&amp;gt; }&lt;br /&gt;
&lt;br /&gt;
Light Source Specials&lt;br /&gt;
Using Shadowless Lights&lt;br /&gt;
&lt;br /&gt;
Light sources can be assigned the shadowless keyword and no shadows will be cast due to its presence in a scene. Sometimes, scenes are difficult to illuminate properly using the lights we have chosen to illuminate our objects. It is impractical and unrealistic to apply a higher ambient value to the texture of every object in the scene. So instead, we would place a couple of fill lights around the scene. Fill lights are simply dimmer lights with the shadowless keyword that act to boost the illumination of other areas of the scene that may not be lit well. Let's try using one in our scene.&lt;br /&gt;
&lt;br /&gt;
Remember the three colored area spotlights? We go back and un-comment them and comment out any other lights we have made. Now we add the following:&lt;br /&gt;
&lt;br /&gt;
  light_source {&lt;br /&gt;
    &amp;lt;0, 20, 0&amp;gt;&lt;br /&gt;
    color Gray50&lt;br /&gt;
    shadowless&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
This is a fairly dim light 20 units over the center of the scene. It will give a dim illumination to all objects including the plane in the background. We render it and see.&lt;br /&gt;
Assigning an Object to a Light Source&lt;br /&gt;
&lt;br /&gt;
Light sources are invisible. They are just a location where the light appears to be coming from. They have no true size or shape. If we want our light source to be a visible shape, we can use the looks_like keyword. We can specify that our light source can look like any object we choose. When we use looks_like, then no_shadow is applied to the object automatically. This is done so that the object will not block any illumination from the light source. If we want some blocking to occur (as in a lamp shade), it is better to simply use a union to do the same thing. Let's add such an object to our scene. Here is a light bulb we have made just for this purpose:&lt;br /&gt;
&lt;br /&gt;
  #declare Lightbulb = union {&lt;br /&gt;
    merge {&lt;br /&gt;
      sphere { &amp;lt;0,0,0&amp;gt;,1 }&lt;br /&gt;
      cylinder {&lt;br /&gt;
        &amp;lt;0,0,1&amp;gt;, &amp;lt;0,0,0&amp;gt;, 1&lt;br /&gt;
        scale &amp;lt;0.35, 0.35, 1.0&amp;gt;&lt;br /&gt;
        translate  0.5*z&lt;br /&gt;
      }&lt;br /&gt;
      texture {&lt;br /&gt;
        pigment {color rgb &amp;lt;1, 1, 1&amp;gt;}&lt;br /&gt;
        finish {ambient .8 diffuse .6}&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    cylinder {&lt;br /&gt;
      &amp;lt;0,0,1&amp;gt;, &amp;lt;0,0,0&amp;gt;, 1&lt;br /&gt;
      scale &amp;lt;0.4, 0.4, 0.5&amp;gt;&lt;br /&gt;
      texture { Brass_Texture }&lt;br /&gt;
      translate  1.5*z&lt;br /&gt;
    }&lt;br /&gt;
    rotate -90*x&lt;br /&gt;
    scale .5&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
Now we add the light source:&lt;br /&gt;
&lt;br /&gt;
  light_source {&lt;br /&gt;
    &amp;lt;0, 2, 0&amp;gt;&lt;br /&gt;
    color White&lt;br /&gt;
    looks_like { Lightbulb }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
Rendering this we see that a fairly believable light bulb now illuminates the scene. However, if we do not specify a high ambient value, the light bulb is not lit by the light source. On the plus side, all of the shadows fall away from the light bulb, just as they would in a real situation. The shadows are sharp, so let's make our bulb an area light:&lt;br /&gt;
&lt;br /&gt;
  light_source {&lt;br /&gt;
    &amp;lt;0, 2, 0&amp;gt;&lt;br /&gt;
    color White&lt;br /&gt;
    area_light &amp;lt;1, 0, 0&amp;gt;, &amp;lt;0, 1, 0&amp;gt;, 2, 2&lt;br /&gt;
    adaptive 1&lt;br /&gt;
    jitter&lt;br /&gt;
    looks_like { Lightbulb }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
We note that we have placed this area light in the x-y-plane instead of the x-z-plane. We also note that the actual appearance of the light bulb is not affected in any way by the light source. The bulb must be illuminated by some other light source or by, as in this case, a high ambient value.&lt;br /&gt;
Using Light Fading&lt;br /&gt;
&lt;br /&gt;
If it is realism we want, it is not realistic for the plane to be evenly illuminated off into the distance. In real life, light gets scattered as it travels so it diminishes its ability to illuminate objects the farther it gets from its source. To simulate this, POV-Ray allows us to use two keywords: fade_distance, which specifies the distance at which full illumination is achieved, and fade_power, an exponential value which determines the actual rate of attenuation. Let's apply these keywords to our fill light.&lt;br /&gt;
&lt;br /&gt;
First, we make the fill light a little brighter by changing Gray50 to Gray75. Now we change that fill light as follows:&lt;br /&gt;
&lt;br /&gt;
  light_source {&lt;br /&gt;
    &amp;lt;0, 20, 0&amp;gt;&lt;br /&gt;
    color Gray75&lt;br /&gt;
    fade_distance 5&lt;br /&gt;
    fade_power 1&lt;br /&gt;
    shadowless&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
This means that the full value of the fill light will be achieved at a distance of 5 units away from the light source. The fade power of 1 means that the falloff will be linear (the light falls off at a constant rate). We render this to see the result.&lt;br /&gt;
&lt;br /&gt;
That definitely worked! Now let's try a fade power of 2 and a fade distance of 10. Again, this works well. The falloff is much faster with a fade power of 2 so we had to raise the fade distance to 10.&lt;br /&gt;
Simple Texture Options&lt;br /&gt;
&lt;br /&gt;
The pictures rendered so far where somewhat boring regarding the appearance of the objects. Let's add some fancy features to the texture.&lt;br /&gt;
Surface Finishes&lt;br /&gt;
&lt;br /&gt;
One of the main features of a ray-tracer is its ability to do interesting things with surface finishes such as highlights and reflection. Let's add a nice little Phong highlight (shiny spot) to a sphere. To do this we need to add a finish keyword followed by a parameter. We change the definition of the sphere to this:&lt;br /&gt;
&lt;br /&gt;
  sphere {&lt;br /&gt;
    &amp;lt;0, 1, 2&amp;gt;, 2&lt;br /&gt;
    texture {&lt;br /&gt;
      pigment { color Yellow } //Yellow is pre-defined in COLORS.INC&lt;br /&gt;
      finish { phong 1 }&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
We render the scene. The phong keyword adds a highlight the same color of the light shining on the object. It adds a lot of credibility to the picture and makes the object look smooth and shiny. Lower values of phong will make the highlight less bright (values should be between 0 and 1).&lt;/div&gt;</summary>
		<author><name>Chrisb</name></author>
	</entry>
	<entry>
		<id>https://wiki.povray.org/content?title=Documentation_Talk:Reference_Section_1.1&amp;diff=1885</id>
		<title>Documentation Talk:Reference Section 1.1</title>
		<link rel="alternate" type="text/html" href="https://wiki.povray.org/content?title=Documentation_Talk:Reference_Section_1.1&amp;diff=1885"/>
		<updated>2009-10-09T12:42:06Z</updated>

		<summary type="html">&lt;p&gt;Chrisb: /* Output File Type */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;===Output File Type===&lt;br /&gt;
&amp;lt;table width=&amp;quot;100%&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td width=&amp;quot;30%&amp;quot;&amp;gt;&amp;lt;code&amp;gt;Output_File_Type=&amp;lt;/code&amp;gt;x&amp;lt;!--&amp;lt;indexentry primary &amp;quot;Output_File_Type, ini-option&amp;quot;&amp;gt;&amp;lt;/td&amp;gt;---&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;td width=&amp;quot;70%&amp;quot;&amp;gt;Sets file output format to x&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&amp;lt;code&amp;gt;+F&amp;lt;/code&amp;gt;xn&amp;lt;!--&amp;lt;indexentry &amp;quot;+f&amp;quot;&amp;gt;&amp;lt;/td&amp;gt;---&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;td&amp;gt;Sets file output on; sets format x, depth n&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&amp;lt;code&amp;gt;-F&amp;lt;/code&amp;gt;xn&amp;lt;!--&amp;lt;indexentry &amp;quot;-f&amp;quot;&amp;gt;&amp;lt;/td&amp;gt;---&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;td&amp;gt;Sets file output off; but in future use format x, depth n&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&amp;lt;code&amp;gt;Output_Alpha=&amp;lt;/code&amp;gt;bool&amp;lt;!--&amp;lt;indexentry primary &amp;quot;Output_Alpha, ini-option&amp;quot;&amp;gt;&amp;lt;/td&amp;gt;---&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;td&amp;gt;Sets alpha output on/off&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&amp;lt;code&amp;gt;+UA&amp;lt;/code&amp;gt;&amp;lt;!--&amp;lt;indexentry &amp;quot;+ua&amp;quot;&amp;gt;&amp;lt;/td&amp;gt;---&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;td&amp;gt;Sets alpha output on&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&amp;lt;code&amp;gt;-UA&amp;lt;/code&amp;gt;&amp;lt;!--&amp;lt;indexentry &amp;quot;-ua&amp;quot;&amp;gt;&amp;lt;/td&amp;gt;---&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;td&amp;gt;Sets alpha output off&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&amp;lt;code&amp;gt;Bits_Per_Color=&amp;lt;/code&amp;gt;n&amp;lt;!--&amp;lt;indexentry primary &amp;quot;Bits_Per_Color, ini-option&amp;quot;&amp;gt;&amp;lt;/td&amp;gt;---&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;td&amp;gt;Sets file output bits/color to n&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&amp;lt;indexentry primary &amp;quot;output formats&amp;quot;&amp;gt;---&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;The default type of image file depends on which platform you are using.&lt;br /&gt;
MS-DOS and most others default to 24-bit uncompressed Targa. Windows defaults&lt;br /&gt;
to 'sys', which is 24-bit BMP. See your platform-specific documentation to&lt;br /&gt;
see what your default file type is. You may select one of several different&lt;br /&gt;
file types using &amp;lt;code&amp;gt;Output_File_Type=&amp;lt;/code&amp;gt;&amp;lt;em&amp;gt;x&amp;lt;/em&amp;gt; or &amp;lt;code&amp;gt;+F&amp;lt;/code&amp;gt;&amp;lt;em&amp;gt;x&amp;lt;/em&amp;gt;&lt;br /&gt;
where &amp;lt;em&amp;gt;x&amp;lt;/em&amp;gt; is one of the following...&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table width=&amp;quot;100%&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td width=&amp;quot;30%&amp;quot;&amp;gt;&amp;lt;code&amp;gt;.. C&amp;lt;/code&amp;gt;&amp;lt;!--&amp;lt;indexentry primary &amp;quot;Targa output, compressed&amp;quot; &amp;quot;Output, Targa, compressed&amp;quot;&amp;gt;&amp;lt;indexentry &amp;quot;+fc&amp;quot;&amp;gt;&amp;lt;/td&amp;gt;---&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;td width=&amp;quot;70%&amp;quot;&amp;gt;&amp;lt;strong&amp;gt;C&amp;lt;/strong&amp;gt;ompressed Targa-24 format (RLE, run length&lt;br /&gt;
encoded)&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td width=&amp;quot;30%&amp;quot;&amp;gt;&amp;lt;code&amp;gt;.. J&amp;lt;/code&amp;gt;&amp;lt;!--&amp;lt;indexentry primary &amp;quot;JPEG output, compressed&amp;quot; &amp;quot;Output, JPEG, compressed&amp;quot;&amp;gt;&amp;lt;indexentry &amp;quot;+fj&amp;quot;&amp;gt;&amp;lt;/td&amp;gt;---&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;td width=&amp;quot;70%&amp;quot;&amp;gt;&amp;lt;strong&amp;gt;J&amp;lt;/strong&amp;gt;PEG format (Note: This format is not loss-free and will generate compression artifacts)&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&amp;lt;code&amp;gt;.. N&amp;lt;/code&amp;gt;&amp;lt;!--&amp;lt;indexentry primary &amp;quot;PNG output&amp;quot; &amp;quot;Output, PNG&amp;quot;&amp;gt;&amp;lt;indexentry &amp;quot;+fn&amp;quot;&amp;gt;&amp;lt;/td&amp;gt;---&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;td&amp;gt;P&amp;lt;strong&amp;gt;N&amp;lt;/strong&amp;gt;G (portable network graphics) format&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&amp;lt;code&amp;gt;.. P&amp;lt;/code&amp;gt;&amp;lt;!--&amp;lt;indexentry primary &amp;quot;PPM output&amp;quot; &amp;quot;Output, PPM&amp;quot;&amp;gt;&amp;lt;indexentry &amp;quot;+fp&amp;quot;&amp;gt;&amp;lt;/td&amp;gt;---&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;td&amp;gt;Unix &amp;lt;strong&amp;gt;P&amp;lt;/strong&amp;gt;PM format&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&amp;lt;code&amp;gt;.. S&amp;lt;/code&amp;gt;&amp;lt;!--&amp;lt;indexentry primary &amp;quot;System-specific output&amp;quot; &amp;quot;Output, system-specific&amp;quot; &amp;quot;Output, BMP&amp;quot; &amp;quot;BMP output&amp;quot;&amp;gt;&amp;lt;indexentry &amp;quot;+fs&amp;quot;&amp;gt;&amp;lt;/td&amp;gt;---&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;td&amp;gt;&amp;lt;strong&amp;gt;S&amp;lt;/strong&amp;gt;ystem-specific such as Mac Pict or Windows BMP&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&amp;lt;code&amp;gt;.. T&amp;lt;/code&amp;gt;&amp;lt;!--&amp;lt;indexentry primary &amp;quot;Targa output, uncompressed&amp;quot; &amp;quot;Output, Targa, uncompressed&amp;quot;&amp;gt;&amp;lt;indexentry &amp;quot;+ft&amp;quot;&amp;gt;&amp;lt;/td&amp;gt;---&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;td&amp;gt;Uncompressed &amp;lt;strong&amp;gt;T&amp;lt;/strong&amp;gt;arga-24 format&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p class=&amp;quot;Note&amp;quot;&amp;gt;&amp;lt;strong&amp;gt;Note:&amp;lt;/strong&amp;gt; the obsolete &amp;lt;code&amp;gt;+FD&amp;lt;/code&amp;gt; dump format and &amp;lt;code&amp;gt;+FR&amp;lt;/code&amp;gt;&lt;br /&gt;
raw format have been dropped because they were rarely used&lt;br /&gt;
and no longer necessary. PPM, PNG, and system specific formats have been&lt;br /&gt;
added. PPM format images are uncompressed, and have a simple text header,&lt;br /&gt;
which makes it a widely portable image format. &lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;PNG is an image format&lt;br /&gt;
designed not only to replace GIF, but to improve on its shortcomings. PNG&lt;br /&gt;
offers the highest compression available without loss for high quality&lt;br /&gt;
applications, such as ray-tracing. The system specific format depends on the&lt;br /&gt;
platform used and is covered in the appropriate system specific&lt;br /&gt;
documentation.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
JPEG is particularly good at achieving high compression rates with photographic or photorealistic images, making it one of the most frequently used formats on the Internet. However, it is not loss-free. Images generated with this option will always contain compression artifacts (image defects). If you need to keep a high-quality image you should render using one of the loss-free formats. &lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
From POV-Ray 3.7 the JPEG compression quality can be controlled using the 'Compression' ini file option which, if set, needs to be an integer between 0 and 100. If values of 0 or 1 are specified then the default compression quality setting of 95% is used. Otherwise the value specified (2-100) is used as the compression quality setting. A value of 2 produces the smallest file (maximum compression), but looks terrible. A value of 100 produces the largest file (least compression) but can still contain some compression artifacts. Values lower than 0 are clipped to 0. Values greater than 100 are clipped to 100.&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
GIF is good at achieving high compression rates when there are large areas of flat color. This image format is frequently used for banners and logos on the Internet. Most raytraced images contain subtle color changes which do not compress well with GIF compression, but POV-Ray can be used to generate flat-color images using high ambient values and no light sources. &lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
Most of these formats output 24 bits per pixel with 8 bits for each of red,&lt;br /&gt;
green and blue data. PNG and PPM allow you to optionally specify the output bit&lt;br /&gt;
depth from 5 to 16 bits for each of the red, green, and blue colors, giving&lt;br /&gt;
from 15 to 48 bits of color information per pixel. The default output depth&lt;br /&gt;
for all formats is 8 bits/color (16 million possible colors), but this may be&lt;br /&gt;
changed for PNG and PPM format files by setting &amp;lt;code&amp;gt;Bits_Per_Color=&amp;lt;/code&amp;gt;&amp;lt;em&amp;gt;n&amp;lt;/em&amp;gt;&lt;br /&gt;
or by specifying &amp;lt;code&amp;gt;+FN&amp;lt;/code&amp;gt;&amp;lt;em&amp;gt;n&amp;lt;/em&amp;gt; or &amp;lt;code&amp;gt;+FP&amp;lt;/code&amp;gt;&amp;lt;em&amp;gt;n&amp;lt;/em&amp;gt;, &lt;br /&gt;
where n is the desired bit depth.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
Specifying a smaller color depth like 5 bits/color (32768 colors) may be&lt;br /&gt;
enough for people with 8- or 16-bit (256 or 65536 color) displays, and will&lt;br /&gt;
improve compression of the PNG file. Higher bit depths like 10 or 12 may be&lt;br /&gt;
useful for video or publishing applications, and 16 bits/color is good for&lt;br /&gt;
grayscale height field output (See section &amp;amp;quot;&amp;lt;!--&amp;lt;linkto &amp;quot;Height Field&amp;quot;&amp;gt;Height Field&amp;lt;/linkto&amp;gt;---&amp;gt;[[Documentation:Reference Section 4#Height Field|Height Field]]&amp;amp;quot; for&lt;br /&gt;
details on height fields).&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
Targa format also allows 8 bits of alpha transparency data to be output,&lt;br /&gt;
while PNG format allows 5 to 16 bits of alpha transparency data, depending on&lt;br /&gt;
the color bit depth as specified above. You may turn this option on with&lt;br /&gt;
&amp;lt;code&amp;gt; Output_Alpha=on&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;+UA&amp;lt;/code&amp;gt;. The default is off or&lt;br /&gt;
&amp;lt;code&amp;gt; -UA&amp;lt;/code&amp;gt;. &amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;The alpha channel stores a transparency value for each pixel, just like&lt;br /&gt;
there is also stored a value for red green and blue light for each pixel. In&lt;br /&gt;
POV-Ray, when the alpha channel is turned on, all areas of the image&lt;br /&gt;
where the background is partly or fully visible will be partly or fully&lt;br /&gt;
transparent. Refractions of the background will also be transparent, but not&lt;br /&gt;
reflections. Also anti-aliasing is taken into account&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;The philosophy of the alpha channel feature in POV-Ray is that the&lt;br /&gt;
background color should not be present in the color of the image when the&lt;br /&gt;
alpha channel is used. Instead, the amount of visible background is kept in&lt;br /&gt;
the alpha and *only* in the alpha channel. That ensures that images look&lt;br /&gt;
correct when viewed with the alpha channel.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;See section &amp;amp;quot;&amp;lt;!--&amp;lt;linkto &amp;quot;Using the Alpha Channel&amp;quot;&amp;gt;Using the Alpha Channel&amp;lt;/linkto&amp;gt;---&amp;gt;[[Documentation:Reference Section 5#Using the Alpha Channel|Using the Alpha Channel]]&amp;amp;quot; for&lt;br /&gt;
further details on using transparency in imagemaps in your scene.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
In addition to support for variable bit-depths, alpha channel, and grayscale&lt;br /&gt;
formats, PNG files also store the &amp;lt;code&amp;gt; Display_Gamma&amp;lt;/code&amp;gt; value so the&lt;br /&gt;
image displays properly on all systems (see section &amp;amp;quot;&amp;lt;!--&amp;lt;linkto &amp;quot;Display Hardware Settings&amp;quot;&amp;gt;Display Hardware Settings&amp;lt;/linkto&amp;gt;---&amp;gt;[[Documentation:Reference Section 1.1#Display Hardware Settings|Display Hardware Settings]]&amp;amp;quot;).&lt;br /&gt;
The &amp;lt;code&amp;gt;hf_gray_16&amp;lt;/code&amp;gt; global setting, as described in section &lt;br /&gt;
&amp;amp;quot;&amp;lt;!--&amp;lt;linkto &amp;quot;HF_Gray_16&amp;quot;&amp;gt;HF_Gray_16&amp;lt;/linkto&amp;gt;---&amp;gt;[[Documentation:Reference Section 3.1#HF_Gray_16|HF_Gray_16]]&amp;amp;quot; will also affect the &lt;br /&gt;
type of data written to the output file.&amp;lt;/p&amp;gt;&lt;/div&gt;</summary>
		<author><name>Chrisb</name></author>
	</entry>
	<entry>
		<id>https://wiki.povray.org/content?title=Documentation_Talk:Reference_Section_1.1&amp;diff=1881</id>
		<title>Documentation Talk:Reference Section 1.1</title>
		<link rel="alternate" type="text/html" href="https://wiki.povray.org/content?title=Documentation_Talk:Reference_Section_1.1&amp;diff=1881"/>
		<updated>2009-10-05T17:15:53Z</updated>

		<summary type="html">&lt;p&gt;Chrisb: /* Output File Type */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;===Output File Type===&lt;br /&gt;
&amp;lt;table width=&amp;quot;100%&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td width=&amp;quot;30%&amp;quot;&amp;gt;&amp;lt;code&amp;gt;Output_File_Type=&amp;lt;/code&amp;gt;x&amp;lt;!--&amp;lt;indexentry primary &amp;quot;Output_File_Type, ini-option&amp;quot;&amp;gt;&amp;lt;/td&amp;gt;---&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;td width=&amp;quot;70%&amp;quot;&amp;gt;Sets file output format to x&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&amp;lt;code&amp;gt;+F&amp;lt;/code&amp;gt;xn&amp;lt;!--&amp;lt;indexentry &amp;quot;+f&amp;quot;&amp;gt;&amp;lt;/td&amp;gt;---&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;td&amp;gt;Sets file output on; sets format x, depth n&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&amp;lt;code&amp;gt;-F&amp;lt;/code&amp;gt;xn&amp;lt;!--&amp;lt;indexentry &amp;quot;-f&amp;quot;&amp;gt;&amp;lt;/td&amp;gt;---&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;td&amp;gt;Sets file output off; but in future use format x, depth n&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&amp;lt;code&amp;gt;Output_Alpha=&amp;lt;/code&amp;gt;bool&amp;lt;!--&amp;lt;indexentry primary &amp;quot;Output_Alpha, ini-option&amp;quot;&amp;gt;&amp;lt;/td&amp;gt;---&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;td&amp;gt;Sets alpha output on/off&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&amp;lt;code&amp;gt;+UA&amp;lt;/code&amp;gt;&amp;lt;!--&amp;lt;indexentry &amp;quot;+ua&amp;quot;&amp;gt;&amp;lt;/td&amp;gt;---&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;td&amp;gt;Sets alpha output on&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&amp;lt;code&amp;gt;-UA&amp;lt;/code&amp;gt;&amp;lt;!--&amp;lt;indexentry &amp;quot;-ua&amp;quot;&amp;gt;&amp;lt;/td&amp;gt;---&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;td&amp;gt;Sets alpha output off&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&amp;lt;code&amp;gt;Bits_Per_Color=&amp;lt;/code&amp;gt;n&amp;lt;!--&amp;lt;indexentry primary &amp;quot;Bits_Per_Color, ini-option&amp;quot;&amp;gt;&amp;lt;/td&amp;gt;---&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;td&amp;gt;Sets file output bits/color to n&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&amp;lt;indexentry primary &amp;quot;output formats&amp;quot;&amp;gt;---&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;The default type of image file depends on which platform you are using.&lt;br /&gt;
MS-DOS and most others default to 24-bit uncompressed Targa. Windows defaults&lt;br /&gt;
to 'sys', which is 24-bit BMP. See your platform-specific documentation to&lt;br /&gt;
see what your default file type is. You may select one of several different&lt;br /&gt;
file types using &amp;lt;code&amp;gt;Output_File_Type=&amp;lt;/code&amp;gt;&amp;lt;em&amp;gt;x&amp;lt;/em&amp;gt; or &amp;lt;code&amp;gt;+F&amp;lt;/code&amp;gt;&amp;lt;em&amp;gt;x&amp;lt;/em&amp;gt;&lt;br /&gt;
where &amp;lt;em&amp;gt;x&amp;lt;/em&amp;gt; is one of the following...&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table width=&amp;quot;100%&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td width=&amp;quot;30%&amp;quot;&amp;gt;&amp;lt;code&amp;gt;.. C&amp;lt;/code&amp;gt;&amp;lt;!--&amp;lt;indexentry primary &amp;quot;Targa output, compressed&amp;quot; &amp;quot;Output, Targa, compressed&amp;quot;&amp;gt;&amp;lt;indexentry &amp;quot;+fc&amp;quot;&amp;gt;&amp;lt;/td&amp;gt;---&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;td width=&amp;quot;70%&amp;quot;&amp;gt;&amp;lt;strong&amp;gt;C&amp;lt;/strong&amp;gt;ompressed Targa-24 format (RLE, run length&lt;br /&gt;
encoded)&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td width=&amp;quot;30%&amp;quot;&amp;gt;&amp;lt;code&amp;gt;.. J&amp;lt;/code&amp;gt;&amp;lt;!--&amp;lt;indexentry primary &amp;quot;JPEG output, compressed&amp;quot; &amp;quot;Output, JPEG, compressed&amp;quot;&amp;gt;&amp;lt;indexentry &amp;quot;+fj&amp;quot;&amp;gt;&amp;lt;/td&amp;gt;---&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;td width=&amp;quot;70%&amp;quot;&amp;gt;&amp;lt;strong&amp;gt;J&amp;lt;/strong&amp;gt;PEG format (Note: This format is not loss-free and will generate compression artifacts)&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&amp;lt;code&amp;gt;.. N&amp;lt;/code&amp;gt;&amp;lt;!--&amp;lt;indexentry primary &amp;quot;PNG output&amp;quot; &amp;quot;Output, PNG&amp;quot;&amp;gt;&amp;lt;indexentry &amp;quot;+fn&amp;quot;&amp;gt;&amp;lt;/td&amp;gt;---&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;td&amp;gt;P&amp;lt;strong&amp;gt;N&amp;lt;/strong&amp;gt;G (portable network graphics) format&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&amp;lt;code&amp;gt;.. P&amp;lt;/code&amp;gt;&amp;lt;!--&amp;lt;indexentry primary &amp;quot;PPM output&amp;quot; &amp;quot;Output, PPM&amp;quot;&amp;gt;&amp;lt;indexentry &amp;quot;+fp&amp;quot;&amp;gt;&amp;lt;/td&amp;gt;---&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;td&amp;gt;Unix &amp;lt;strong&amp;gt;P&amp;lt;/strong&amp;gt;PM format&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&amp;lt;code&amp;gt;.. S&amp;lt;/code&amp;gt;&amp;lt;!--&amp;lt;indexentry primary &amp;quot;System-specific output&amp;quot; &amp;quot;Output, system-specific&amp;quot; &amp;quot;Output, BMP&amp;quot; &amp;quot;BMP output&amp;quot;&amp;gt;&amp;lt;indexentry &amp;quot;+fs&amp;quot;&amp;gt;&amp;lt;/td&amp;gt;---&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;td&amp;gt;&amp;lt;strong&amp;gt;S&amp;lt;/strong&amp;gt;ystem-specific such as Mac Pict or Windows BMP&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&amp;lt;code&amp;gt;.. T&amp;lt;/code&amp;gt;&amp;lt;!--&amp;lt;indexentry primary &amp;quot;Targa output, uncompressed&amp;quot; &amp;quot;Output, Targa, uncompressed&amp;quot;&amp;gt;&amp;lt;indexentry &amp;quot;+ft&amp;quot;&amp;gt;&amp;lt;/td&amp;gt;---&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;td&amp;gt;Uncompressed &amp;lt;strong&amp;gt;T&amp;lt;/strong&amp;gt;arga-24 format&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p class=&amp;quot;Note&amp;quot;&amp;gt;&amp;lt;strong&amp;gt;Note:&amp;lt;/strong&amp;gt; the obsolete &amp;lt;code&amp;gt;+FD&amp;lt;/code&amp;gt; dump format and &amp;lt;code&amp;gt;+FR&amp;lt;/code&amp;gt;&lt;br /&gt;
raw format have been dropped because they were rarely used&lt;br /&gt;
and no longer necessary. PPM, PNG, and system specific formats have been&lt;br /&gt;
added. PPM format images are uncompressed, and have a simple text header,&lt;br /&gt;
which makes it a widely portable image format. &lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;PNG is an image format&lt;br /&gt;
designed not only to replace GIF, but to improve on its shortcomings. PNG&lt;br /&gt;
offers the highest compression available without loss for high quality&lt;br /&gt;
applications, such as ray-tracing. The system specific format depends on the&lt;br /&gt;
platform used and is covered in the appropriate system specific&lt;br /&gt;
documentation.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
JPEG is particularly good at achieving high compression rates with photographic or photorealistic images, making it one of the most frequently used formats on the Internet. However, it is not loss-free. Images generated with this option will always contain compression artifacts (image defects). If you need to keep a high-quality image you should render using one of the loss-free formats. &lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
GIF is good at achieving high compression rates when there are large areas of flat color. This image format is frequently used for banners and logos on the Internet. Most raytraced images contain subtle color changes which do not compress well with GIF compression, but POV-Ray can be used to generate flat-color images using high ambient values and no light sources. &lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
Most of these formats output 24 bits per pixel with 8 bits for each of red,&lt;br /&gt;
green and blue data. PNG and PPM allow you to optionally specify the output bit&lt;br /&gt;
depth from 5 to 16 bits for each of the red, green, and blue colors, giving&lt;br /&gt;
from 15 to 48 bits of color information per pixel. The default output depth&lt;br /&gt;
for all formats is 8 bits/color (16 million possible colors), but this may be&lt;br /&gt;
changed for PNG and PPM format files by setting &amp;lt;code&amp;gt;Bits_Per_Color=&amp;lt;/code&amp;gt;&amp;lt;em&amp;gt;n&amp;lt;/em&amp;gt;&lt;br /&gt;
or by specifying &amp;lt;code&amp;gt;+FN&amp;lt;/code&amp;gt;&amp;lt;em&amp;gt;n&amp;lt;/em&amp;gt; or &amp;lt;code&amp;gt;+FP&amp;lt;/code&amp;gt;&amp;lt;em&amp;gt;n&amp;lt;/em&amp;gt;, &lt;br /&gt;
where n is the desired bit depth.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
Specifying a smaller color depth like 5 bits/color (32768 colors) may be&lt;br /&gt;
enough for people with 8- or 16-bit (256 or 65536 color) displays, and will&lt;br /&gt;
improve compression of the PNG file. Higher bit depths like 10 or 12 may be&lt;br /&gt;
useful for video or publishing applications, and 16 bits/color is good for&lt;br /&gt;
grayscale height field output (See section &amp;amp;quot;&amp;lt;!--&amp;lt;linkto &amp;quot;Height Field&amp;quot;&amp;gt;Height Field&amp;lt;/linkto&amp;gt;---&amp;gt;[[Documentation:Reference Section 4#Height Field|Height Field]]&amp;amp;quot; for&lt;br /&gt;
details on height fields).&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
Targa format also allows 8 bits of alpha transparency data to be output,&lt;br /&gt;
while PNG format allows 5 to 16 bits of alpha transparency data, depending on&lt;br /&gt;
the color bit depth as specified above. You may turn this option on with&lt;br /&gt;
&amp;lt;code&amp;gt; Output_Alpha=on&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;+UA&amp;lt;/code&amp;gt;. The default is off or&lt;br /&gt;
&amp;lt;code&amp;gt; -UA&amp;lt;/code&amp;gt;. &amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;The alpha channel stores a transparency value for each pixel, just like&lt;br /&gt;
there is also stored a value for red green and blue light for each pixel. In&lt;br /&gt;
POV-Ray, when the alpha channel is turned on, all areas of the image&lt;br /&gt;
where the background is partly or fully visible will be partly or fully&lt;br /&gt;
transparent. Refractions of the background will also be transparent, but not&lt;br /&gt;
reflections. Also anti-aliasing is taken into account&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;The philosophy of the alpha channel feature in POV-Ray is that the&lt;br /&gt;
background color should not be present in the color of the image when the&lt;br /&gt;
alpha channel is used. Instead, the amount of visible background is kept in&lt;br /&gt;
the alpha and *only* in the alpha channel. That ensures that images look&lt;br /&gt;
correct when viewed with the alpha channel.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;See section &amp;amp;quot;&amp;lt;!--&amp;lt;linkto &amp;quot;Using the Alpha Channel&amp;quot;&amp;gt;Using the Alpha Channel&amp;lt;/linkto&amp;gt;---&amp;gt;[[Documentation:Reference Section 5#Using the Alpha Channel|Using the Alpha Channel]]&amp;amp;quot; for&lt;br /&gt;
further details on using transparency in imagemaps in your scene.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
In addition to support for variable bit-depths, alpha channel, and grayscale&lt;br /&gt;
formats, PNG files also store the &amp;lt;code&amp;gt; Display_Gamma&amp;lt;/code&amp;gt; value so the&lt;br /&gt;
image displays properly on all systems (see section &amp;amp;quot;&amp;lt;!--&amp;lt;linkto &amp;quot;Display Hardware Settings&amp;quot;&amp;gt;Display Hardware Settings&amp;lt;/linkto&amp;gt;---&amp;gt;[[Documentation:Reference Section 1.1#Display Hardware Settings|Display Hardware Settings]]&amp;amp;quot;).&lt;br /&gt;
The &amp;lt;code&amp;gt;hf_gray_16&amp;lt;/code&amp;gt; global setting, as described in section &lt;br /&gt;
&amp;amp;quot;&amp;lt;!--&amp;lt;linkto &amp;quot;HF_Gray_16&amp;quot;&amp;gt;HF_Gray_16&amp;lt;/linkto&amp;gt;---&amp;gt;[[Documentation:Reference Section 3.1#HF_Gray_16|HF_Gray_16]]&amp;amp;quot; will also affect the &lt;br /&gt;
type of data written to the output file.&amp;lt;/p&amp;gt;&lt;/div&gt;</summary>
		<author><name>Chrisb</name></author>
	</entry>
	<entry>
		<id>https://wiki.povray.org/content?title=HowTo:Create_animations&amp;diff=523</id>
		<title>HowTo:Create animations</title>
		<link rel="alternate" type="text/html" href="https://wiki.povray.org/content?title=HowTo:Create_animations&amp;diff=523"/>
		<updated>2008-06-21T10:24:19Z</updated>

		<summary type="html">&lt;p&gt;Chrisb: Added checklist to intro&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Animation is the rapid display of a sequence of images in order to create an illusion of movement (see [[Wikipedia:Animation]]). POV-Ray can be used to create such a sequence of images. Creating these images in POV-Ray may be very different from using other graphical tools that you are used to. As with other forms of animation, small sequences can be done quite easily, but when animations grow, a little planning and preparation goes a long way so:&lt;br /&gt;
*Define what it is that interests you (what type of animations do you want to produce)&lt;br /&gt;
*Establish which categories of tool you will need&lt;br /&gt;
*Identify applications that address those needs, attempting to minimise the number of different applications you'll have to learn&lt;br /&gt;
*Join the various communities that use those tools so that you can keep abreast of changes that may impact you&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Basics==&lt;br /&gt;
POV-Ray provides a number of features to help produce a sequence of individual still images but does not put them together into an animation. You'll therefore need a separate piece of software to assemble the animation. There are lots of application programs available that will do this, including several free and open source products. You'll need to pick one that can generate the animation file format you wish to produce, e.g. AVI, MPEG, FLI/FLC, QuickTime, or animated GIF files (popularly used on Web pages). Try Googling [http://www.google.com/search?q=animation+utilities animation utilities].&lt;br /&gt;
&lt;br /&gt;
When animating, we use the ini-file (or equivalent command line options) to tell the renderer what frames to render, and what clock values the renderer should use. Our scene file can then use settings such as the clock variable to control the generation of a particular image or 'frame' in the sequence. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
+W150&lt;br /&gt;
+H150         &lt;br /&gt;
Input_File_Name=robot.pov&lt;br /&gt;
Initial_Frame=1&lt;br /&gt;
Final_Frame=30&lt;br /&gt;
Initial_Clock=0&lt;br /&gt;
Final_Clock=1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When using the above INI-file, POV-Ray will render 30 frames and the clock variable will run from 0 to 1. The clock setting as defined in the ini-file or on the command line will be available when your scene is parsed at render time as the variable 'clock'. If not specified, the value of the clock variable will pass from 0 to 1 through the animation sequence.  The frame number will be available to your scene file as the variable 'frame_number'. To be of interest something should change during the animation, often with each frame. This change is usually controlled by using the clock variable or the frame_number variable in your scene file.&lt;br /&gt;
&lt;br /&gt;
==Animating objects==&lt;br /&gt;
To animate a ball we could use the clock variable to control its attributes, position, orientation etc. For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
sphere { &amp;lt;0,clock,0&amp;gt;,1 pigment {rgb 1}}&lt;br /&gt;
 or&lt;br /&gt;
sphere { &amp;lt;0,0,0&amp;gt;,1 translate &amp;lt;0,clock,0&amp;gt; pigment {rgb 1}}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Both examples move a sphere up the Y-axis by a fixed amount per frame.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
 sphere { &amp;lt;0,0,0&amp;gt;,0.5*(1+clock) pigment {rgb 1}}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Increases the radius of the sphere from 0.5 units to 1 unit as the animation sequence progresses.&lt;br /&gt;
&lt;br /&gt;
==Animating object properties==&lt;br /&gt;
More interesting behaviour is possible is you imagine everything can be animated. Allthough impossible in the real world you can show how a piece of glass would look if it's index of refraction would slowly change.&lt;br /&gt;
&lt;br /&gt;
==Animating the camera==&lt;br /&gt;
Animating a camera requires some planning when complex movements are required. Smooth movement is possible if you can specify a 'neat' set of position functions, and a flyby look-and-feel is possible if you also take into account gravity, speed and acceleration, so you can adjust the 'roll' of the camera according to the current down direction.&lt;br /&gt;
This dynamical downdirection is a lineair combination of the gravity vector, and the centrifugal forces caused by direction changes.  &lt;br /&gt;
&lt;br /&gt;
==Creating complex behaviour==&lt;br /&gt;
[[Image:Birds_2_02.gif|right]]&lt;br /&gt;
&lt;br /&gt;
When you want to show complex behaviour in your animation, you will have a lot of programming to do. Sometimes however it is not necessary to define everything in detail. Sometimes simple sets of rules (working on a simple set of variables) wil exhibit complex behavior which will nonetheless be recognizable. &lt;br /&gt;
&lt;br /&gt;
It is possible to define an array of object, say birds or fish, setting up variables for position, orientation and speed, and creating a macro to draw them (with this orientation and speed). Now every time a frame is rendered you call the macro which draws all birds or fish,  and call a macro which calculates the new state for every object (position, speed) and stores it for use in the next frame. This calculation macro is in fact a simple set of -more or less- high-level rules. Changing these rules, you setup behavior, not exact positions for the objects.  You can 'guide' each bird, not exactly, but with simple rules like &amp;quot;stay above the ground&amp;quot; and &amp;quot;if you are going to collide, turn left a bit&amp;quot; you have some control.  These sets of rules will generate almost random behavior, which has recognizable dynamics like flocking for birds, traffic-jamming for cars, or bending in the 'wind' for trees.&lt;br /&gt;
&lt;br /&gt;
===State variables===&lt;br /&gt;
The state variables are the core of this method, and you will need to carefully analyse the behavior of the object you are trying to mimic. You the capture these in a simple data structure. You might create something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
#declare Blocation = array[max_birds];&lt;br /&gt;
#declare Bvelocity = array[max_birds];&lt;br /&gt;
#declare Bphase = array[max_birds];&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The amount of detail in the dissemination of the object tends to grow in time, see below for further explanation of the phase-parameter. &lt;br /&gt;
&lt;br /&gt;
To make this work you will need to 'transfer' the state of the objects (birds) from each frame to the next. This can easily be done using macro's to write out, and readback the variables to a file on disk. The following macro's can be easily extended to save and load more complex data-sets.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
#macro SaveState()    &lt;br /&gt;
       #fopen wfile &amp;quot;state.txt&amp;quot; write&lt;br /&gt;
       #local i = 0;&lt;br /&gt;
       # while (i&amp;lt;max_birds)&lt;br /&gt;
               #write ( wfile, Blocation[i], &amp;quot;,&amp;quot;, Bvelocity[i], &amp;quot;,&amp;quot; , Bphase[i], &amp;quot;,&amp;quot;)&lt;br /&gt;
               #local i=i+1;                &lt;br /&gt;
       #end     &lt;br /&gt;
       #fclose file     &lt;br /&gt;
#end    &lt;br /&gt;
&lt;br /&gt;
#macro LoadState()    &lt;br /&gt;
       #fopen rfile &amp;quot;state.txt&amp;quot; read&lt;br /&gt;
       #local i = 0;&lt;br /&gt;
       #while (i&amp;lt;max_birds)&lt;br /&gt;
               #read ( rfile, Blocation[i] ,Bvelocity[i], Bphase[i] )&lt;br /&gt;
               #local i=i+1;                &lt;br /&gt;
       #end         &lt;br /&gt;
       #fclose file&lt;br /&gt;
#end    &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Drawing the objects===&lt;br /&gt;
You will need a macro or set of macros to draw the objects into the scene. The macro to draw the object will have to take into account all relevant parameters. For instance a bird rolls when taking a turn, according with it's changing down-vector. Also the wings will have a current state (a phase) which determines where the wings are in the up-down direction. &lt;br /&gt;
&lt;br /&gt;
===Rules===&lt;br /&gt;
In the main file you will want to execute some 'business rules' for every bird to define it's solitary behaviour, and maybe you will want to run some other rules for each bird-pair, so social behaviour can be controlled. These rules act on the state variables, but can also gather information elsewhere provided the variables needed are in [[scope]].&lt;br /&gt;
&lt;br /&gt;
You can embed these rules in a macro which you run each frame. In this macro you could create some intermediate variables, deduced from the state variables to make the rule definition somewhat more comfortable. In the example above, we could define a speed, which is easier to compare than a velocity vector.&lt;br /&gt;
&lt;br /&gt;
 #local Speed = vlength(Bvelocity[i]);&lt;br /&gt;
&lt;br /&gt;
Now further on you can create a rule to stop birds from stalling:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
// Do not stall&lt;br /&gt;
#if (Speed&amp;lt;1) &lt;br /&gt;
    #declare Bvelocity[i]=Bvelocity[i]*1.2; &lt;br /&gt;
#end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Detailed control===&lt;br /&gt;
As said you cannot control these objects at the position-level using these rules. At rendertime you have access to all the variables so you could do extra checks and 'force then around'. However this will not work at parse-time. Suppose you create a scene with mountains and buildings, and want to add some birds. Now when the birds calculate their 'next move' the information about buildings and mountains is NOT available. Detailed interaction with the scene requires capturing behaviour in rules, and creating an environment where data about say buildings and mountains can be stored. Now the extra rules can act on this data.&lt;br /&gt;
&lt;br /&gt;
===More to try===&lt;br /&gt;
*You could consider animating things like fish, cars, trees, houses and much more.&lt;br /&gt;
*Try animating different species with specific interactions.&lt;br /&gt;
&lt;br /&gt;
==Cyclic animations==&lt;br /&gt;
Suppose you want to make an animation that loops, so that after the last frame has been rendered it should hop back to the first frame and play everything again. To make the jump from the last to the first frame seamless, the animation must end with exactly the same scene as it started with, i.e. parsing the file with clock = 0 and clock = 1 must generate the same image. When animating this however, you will find a slight glitch in the animation: since the first and last frame are identical it will look like like the animation stops for a while. You could prevent this simply by deleting the last frame after you have rendered them, or only render a subset of the frames to leave out the last one, but POV-ray offers a much better solution. Simply add&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
Cyclic_Animation=On&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
to the INI-file, or +KC to the command line. POV-ray will now automatically do the following:&lt;br /&gt;
&lt;br /&gt;
* Increase the number of frames by one (so if you chose to have 50 frames in the animation, POV-ray will make it 51)&lt;br /&gt;
* but not render the last frame (so you'll still only get 50 images rendered, since the 51st one would be identical to the first)&lt;br /&gt;
&lt;br /&gt;
When these images are compiled into a looping animation, you'll get a nice, smooth, and glitch-free animation.  For example, here's [[HowTo:Encode_animations_as_Ogg_Theora_Video|how to create an Ogg Theora video file]].&lt;/div&gt;</summary>
		<author><name>Chrisb</name></author>
	</entry>
	<entry>
		<id>https://wiki.povray.org/content?title=HowTo:Contents&amp;diff=522</id>
		<title>HowTo:Contents</title>
		<link rel="alternate" type="text/html" href="https://wiki.povray.org/content?title=HowTo:Contents&amp;diff=522"/>
		<updated>2008-06-10T20:28:27Z</updated>

		<summary type="html">&lt;p&gt;Chrisb: /* Completed articles */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The following is a list of the currently-available 'How To' articles. If you add a new article, please list it here.&lt;br /&gt;
&lt;br /&gt;
Please also read our '''[[Help:Editing_Guidelines|Editing Guidelines]]''' prior to creating any articles.&lt;br /&gt;
&lt;br /&gt;
==Suggestions==&lt;br /&gt;
&lt;br /&gt;
It would be handy if some users co-operated in working out a 'wishlist' of articles and a hierarchy for them, and then created the links to the empty pages from this page.&lt;br /&gt;
&lt;br /&gt;
Discussions should be held on the [[HowTo_Talk:Contents|talk]] page, not here.&lt;br /&gt;
&lt;br /&gt;
==Completed articles==&lt;br /&gt;
&lt;br /&gt;
*[[HowTo:Use constructive solid geometry | How to: Use constructive solid geometry]]&lt;br /&gt;
*[[HowTo:Use conditional structures | How to: Use conditional structures]]&lt;br /&gt;
*[[HowTo:Use macros and loops | How to: Use macros and loops]]&lt;br /&gt;
&lt;br /&gt;
==Work-in-Progress Articles==&lt;br /&gt;
&lt;br /&gt;
====Animating your creations====&lt;br /&gt;
*[[HowTo:Create animations | How to: Create animations]]&lt;br /&gt;
*[[HowTo:Create more complex animations | How to: Create more complex animations]]&lt;br /&gt;
*[[HowTo:Animation pitfalls | How to: Animation pitfalls]]&lt;br /&gt;
*[[HowTo:Encode animations as Ogg Theora Video | How to: Encode animations as Ogg Theora Video]]  (A non-proprietary video file format)&lt;br /&gt;
&lt;br /&gt;
====Objects====&lt;br /&gt;
*[[HowTo:Use constructive solid geometry | How to: Use constructive solid geometry]]&lt;br /&gt;
*[[HowTo:Use the blob object | How to: Use the blob object]]&lt;br /&gt;
*[[HowTo:Use the isosurface object | How to: Use the isosurface object]]&lt;br /&gt;
*[[HowTo:Use the lathe object | How to: Use the lathe object]]&lt;br /&gt;
*[[HowTo:Use the plane object | How to: Use the plane object]]&lt;br /&gt;
*[[HowTo:Use spline and bezier curves | How to: Use spline and bezier curves]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Texturing====&lt;br /&gt;
*[[HowTo:Use UV-mapping | How to: Use UV-mapping]]&lt;br /&gt;
*[[HowTo:Use an image as a texture | How to: Use an image as a texture]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Lighting====&lt;br /&gt;
*[[HowTo:Use the area_light | How to: Use the area_light]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Special effects in POV-Ray====&lt;br /&gt;
*[[HowTo:Use fog and media | How to: Use fog and media]]&lt;br /&gt;
*[[HowTo:Use rainbow | How to: Use rainbow]]&lt;br /&gt;
*[[HowTo:Use photons | How to: Use photons]]&lt;br /&gt;
*[[HowTo:Use radiosity | How to: Use radiosity]]&lt;br /&gt;
*[[HowTo:Use sky_sphere and background | How to: Use sky_sphere and background]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Special output in POV-Ray====&lt;br /&gt;
*[[HowTo:Create anaglyph images | How to: Create anaglyph images]]&lt;br /&gt;
*[[HowTo:Create multi-phase web buttons | How to: Create multi-phase web buttons]]&lt;br /&gt;
*[[HowTo:Create images for use as a heightfield | How to: Create images for use as a heightfield]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Working with POV-Ray ====&lt;br /&gt;
*[[HowTo:Plan your scenes | How to: Plan your scenes]]&lt;br /&gt;
*[[HowTo:Build a basic scene | How to: Build a basic scene]]&lt;br /&gt;
*[[HowTo:Take full advantage of the Insert menu | How to: Take full advantage of the Insert menu]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Scene Description Language====&lt;br /&gt;
*[[HowTo:Manage your variables | How to: Manage your variables]]&lt;br /&gt;
*[[HowTo:Use conditional structures | How to: Use conditional structures]]&lt;br /&gt;
*[[HowTo:Use macros and loops | How to: Use macros and loops]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Troubleshooting your scene====&lt;br /&gt;
This section is for figuring out why your scene isn't rendering as expected.  For problems related to installation or removal of POV-Ray, updates, crashes, or other software-related issues, see [[#General POV-Ray troubleshooting | General POV-Ray troubleshooting]].&lt;br /&gt;
*[[HowTo:Fix unexpected image output | Why is my image completely black?]]&lt;br /&gt;
*[[HowTo:Fix unexpected invisiblity#Objects | Why aren't all of my objects showing up?]]&lt;br /&gt;
*[[HowTo:Fix unexpected invisiblity#Media | Why doesn't my fog or other media show up?]]&lt;br /&gt;
*[[HowTo:Fix artifacts#Coincident surfaces | What are all of these weird speckles on my object?]]&lt;br /&gt;
*[[HowTo:Fix artifacts#Isosurfaces | What is the best way to fix holes in my isosurface?]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====General POV-Ray troubleshooting====&lt;br /&gt;
This section is for software problems with POV-Ray.  If you are trying to figure out why your scene isn't rendering as expected, see [[#Troubleshooting Your Scene|Troubleshooting Your Scene]].&lt;br /&gt;
*[[HowTo:Install multiple versions of POV-Ray | How to: Install multiple versions of POV-Ray]]&lt;/div&gt;</summary>
		<author><name>Chrisb</name></author>
	</entry>
	<entry>
		<id>https://wiki.povray.org/content?title=HowTo:Use_macros_and_loops&amp;diff=521</id>
		<title>HowTo:Use macros and loops</title>
		<link rel="alternate" type="text/html" href="https://wiki.povray.org/content?title=HowTo:Use_macros_and_loops&amp;diff=521"/>
		<updated>2008-06-10T20:08:46Z</updated>

		<summary type="html">&lt;p&gt;Chrisb: /* Loops */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Loops and Macros are usually created to do one set of code many times. The beauty of the loop is that the code can reference an array or a spline to write a rollercoaster track or a roadway such that very complicated scenes can be created with the use of simple declared variables.&lt;br /&gt;
&lt;br /&gt;
== Loops ==&lt;br /&gt;
See also [[HowTo:Use_conditional_structures#The_.23while.2C_.23end_construct_.28Loops.29|HowTo:Use_conditional_structures#The #while, #end construct]]&lt;br /&gt;
&lt;br /&gt;
Loops may be constructed through the use of the #while statement. A typical loop may be constructed as follows.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
#declare step = 0;&lt;br /&gt;
#declare steps = 100;&lt;br /&gt;
#while (step &amp;lt;= steps)&lt;br /&gt;
  #sphere { step*x, 0.4 pigment {Blue} }&lt;br /&gt;
  #declare step = step + 1;&lt;br /&gt;
#end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Nested loops may be created to generate a two or three dimensional aspect to the scene. Beware that creating extra nested loops may dramatically increase the parse time for the scene.&lt;br /&gt;
&lt;br /&gt;
The following nested loop will draw a series of Blue balls on the XZ plain&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
#declare xpos = 0;&lt;br /&gt;
#declare zpos = 0;&lt;br /&gt;
#declare xfinal = 10;&lt;br /&gt;
#declare zfinal = 10;&lt;br /&gt;
#while (xpos &amp;lt;= xfinal)&lt;br /&gt;
  #while (zpos &amp;lt;= zfinal)&lt;br /&gt;
    #sphere { &amp;lt;xpos,0,zpos&amp;gt; 0.4 pigment {Blue} }&lt;br /&gt;
    #declare zpos = zpos + 1;&lt;br /&gt;
  #end&lt;br /&gt;
  #declare xpos = xpos + 1;&lt;br /&gt;
  #declare zpos = 0;&lt;br /&gt;
#end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Macros ==&lt;br /&gt;
The essential custom functions of PoV-Ray. These are blocks of code that make calculations, or make objects, or if used in a series can make many objects with all of them different. &lt;br /&gt;
&lt;br /&gt;
Macros are declared like this:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;#macro {Macro_Name}({Macro_Parameters})&lt;br /&gt;
  {Macro_Body}&lt;br /&gt;
#end&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Macro Name===&lt;br /&gt;
The name of the macro. Can be as simple or as complex as you want it to be. From a programmer's perspective, it's best to name it in a semi-descriptive way of what you're trying to do.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;#macro MakeSpheres()&lt;br /&gt;
//Make a layer of spheres&lt;br /&gt;
#end&amp;lt;/source&amp;gt;&lt;br /&gt;
is much more understandable than&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;#macro MS()&lt;br /&gt;
//Make a layer of spheres&lt;br /&gt;
#end&amp;lt;/source&amp;gt;&lt;br /&gt;
Where as the latter of the two could be confused with &amp;quot;MakeSplines&amp;quot; or something. You never know.&lt;br /&gt;
&lt;br /&gt;
===Macro Parameters===&lt;br /&gt;
A comma delineated list of variables that you will use in the macro.&lt;br /&gt;
They can be changed if needed, but don't have to be always.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;#macro MakeSpheres(height, layer_color)&lt;br /&gt;
//Make a layer of spheres&lt;br /&gt;
//  height - height of layer&lt;br /&gt;
//  layer_color - pigment of the layer&lt;br /&gt;
#end&amp;lt;/source&amp;gt;&lt;br /&gt;
Here, parameters for height and color are added.  These can change the macro's behavior.&lt;br /&gt;
&lt;br /&gt;
===Macro Body===&lt;br /&gt;
The real juice of the macro. This is where you do loops or object creation or loops with object creation, whatever. This is where you get the job done.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;#macro MakeSpheres(height, layer_color)&lt;br /&gt;
//Make a layer of spheres&lt;br /&gt;
//  height - height of layer&lt;br /&gt;
//  layer_color - pigment of the layer&lt;br /&gt;
  #declare xpos = 0;&lt;br /&gt;
  #declare zpos = 0;&lt;br /&gt;
  #declare xfinal = 10;&lt;br /&gt;
  #declare zfinal = 10;&lt;br /&gt;
  #while (xpos &amp;lt;= xfinal)&lt;br /&gt;
    #while (zpos &amp;lt;= zfinal)&lt;br /&gt;
      // Notice that height and layer_color are inserted here.&lt;br /&gt;
      #sphere { &amp;lt;xpos,height,zpos&amp;gt; 0.4 pigment { layer_color } }&lt;br /&gt;
      #declare zpos = zpos + 1;&lt;br /&gt;
    #end&lt;br /&gt;
    #declare xpos = xpos + 1;&lt;br /&gt;
    #declare zpos = 0;&lt;br /&gt;
  #end&lt;br /&gt;
#end                &lt;br /&gt;
&lt;br /&gt;
// The macro is invoked three times with different parameters&lt;br /&gt;
MakeSpheres(0, Blue)&lt;br /&gt;
MakeSpheres(2, Red)&lt;br /&gt;
MakeSpheres(1, White)&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Chrisb</name></author>
	</entry>
	<entry>
		<id>https://wiki.povray.org/content?title=HowTo:Use_conditional_structures&amp;diff=520</id>
		<title>HowTo:Use conditional structures</title>
		<link rel="alternate" type="text/html" href="https://wiki.povray.org/content?title=HowTo:Use_conditional_structures&amp;diff=520"/>
		<updated>2008-06-10T20:01:37Z</updated>

		<summary type="html">&lt;p&gt;Chrisb: /* The #switch, #case, #range and #break Directives */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Conditional constructs in POV-Ray are scripting features which perform different computations or actions depending on whether a condition evaluates to true or false. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==The #if, #else, #end construct==&lt;br /&gt;
The simplest conditional directive is the #if directive. This evaluates an expression, which must evaluate to a floating point number (often an integer value). This floating point number is interpreted as a boolean value, that is to say that if the expression evaluates to '0', it is considered 'false' and if it evaluates to anything else it is considered 'true'. If the condition is true then directives between the #if statement and a corresponding #else or #end statement are evaluated.&lt;br /&gt;
Note: extremely small values of about 1e-10 are considered zero (false) as a result of floating point number accuracy limits. &lt;br /&gt;
&lt;br /&gt;
The #else directive is optional but, if specified and the conditional expression was false, then directives between the #else and the corresponding #end statement are evaluated.&lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=pov&amp;gt;&lt;br /&gt;
#declare CameraDistance=25.8;&lt;br /&gt;
 &lt;br /&gt;
 ... Definition of some complex object that looks like a sphere at great distances. ...&lt;br /&gt;
 &lt;br /&gt;
#if (CameraDistance&amp;gt;100)&lt;br /&gt;
   sphere { &amp;lt;0,0,0&amp;gt;, 1.2 pigment {rgb 1}}&lt;br /&gt;
#else&lt;br /&gt;
   object {MyComplexObject}&lt;br /&gt;
#end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here the 'greater than' comparitive operator '&amp;gt;' is used to see whether the value of the CameraDistance variable is greater than 100. In this example, the expression 'CameraDistance&amp;gt;100' evaluates to 0 ('false') because the CameraDistance variable is less than 100.&lt;br /&gt;
&lt;br /&gt;
===Conditional Conjunctions ===&lt;br /&gt;
You can combine conditional terms to build more complex conditional expressions using '&amp;amp;' (And), '|' (Or) and '!' (Not). Use brackets to control the sequence of evaluation. You can also use POV-Ray functions within terms so long as they can be resolved to numeric values. The built-in float identifiers on, off, yes, no, true, and false are designed for use as boolean constants and simply evaluate to 0 (off, no and false) or 1 (on, yes and true).&lt;br /&gt;
&lt;br /&gt;
Here's an example that might take a little thinking about:&lt;br /&gt;
&amp;lt;source lang=pov&amp;gt;&lt;br /&gt;
#declare Clothing=&amp;quot;Jeans&amp;quot;;&lt;br /&gt;
#declare JeansPermitted=false;&lt;br /&gt;
// Check to see if Jeans are permitted&lt;br /&gt;
#if (strcmp(Clothing,&amp;quot;Jeans&amp;quot;)=0 &amp;amp; !JeansPermitted)&lt;br /&gt;
   #debug &amp;quot;Sorry. Jeans are not permitted\n&amp;quot;&lt;br /&gt;
#end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this example, the strcmp function returns a zero because there is no difference between the two strings it has compared.&lt;br /&gt;
The term 'strcmp(Clothing,&amp;quot;Jeans&amp;quot;)=0' therefore returns a 1 (this term is true). The '!' (Not) symbol is used to check for the condition where jeans are not permitted. The '&amp;amp;' symbol is used to combine the two and to therefore test for the condition where Clothing is &amp;quot;Jeans&amp;quot; and jeans are not permitted.&lt;br /&gt;
&lt;br /&gt;
As you've probably realised, there are many ways of expressing the same thing with conditional expressions and the art is in writing it in a way that is clear enough that you will understand it when you read it through again later. It can help to write the condition out as a comment before you build it into an expression. Leaving the comment in place helps anyone reading it later.&lt;br /&gt;
&lt;br /&gt;
== The #ifdef and #ifndef, #else and #end constructs ==&lt;br /&gt;
&lt;br /&gt;
The #ifdef and #ifndef statements can be used to determine whether or not an identifier has been defined and to conditionally execute statements. If the identifier passed to the #ifdef directive exists then the statements between the #ifdef statement and a corresponding #else or #end statement are evaluated. The #else directive is optional but, if specified and the identifier passed to the #ifdef directive does not exist, then directives between the #else and the corresponding #end statement are evaluated.&lt;br /&gt;
&lt;br /&gt;
These statements can help to trap potential errors in a scene file or to set default values.&lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=pov&amp;gt;&lt;br /&gt;
#infdef(ObjectHeight) #declare ObjectHeight=1; #end&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
&lt;br /&gt;
==The #switch, #case, #range and #break Directives==&lt;br /&gt;
The #switch directive provides another way of specifying conditional expressions but allows you to handle a succession of conditions as defined by a #case clause or a #range clause. This directive can seem a little daunting compared to using one or more #if directives, but there are some powerful ways of using it. Like the #if directive it uses float values rather than boolean, so two values whose difference is less than 1e-10 are considered equal.&lt;br /&gt;
&lt;br /&gt;
This trivial example illustrates a number of basic points about the #switch directive. &lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;If a #case or #range clause is not a match it skips to the next one, ignoring everything else in between. &lt;br /&gt;
&amp;lt;li&amp;gt;If a #break is encountered within a matching #case or #range clause the #switch directive stops processing further lines, causing an immediate jump to the #end without processing subsequent sections, even if a subsequent condition would also have been satisfied. &lt;br /&gt;
&amp;lt;li&amp;gt;When processing a matching #case or #range clause, if a #break is not encountered it continues through successive #case statements whether they match or not.&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Although it doesn't contain a camera or any objects, the following example is a complete scene file. When you render it it'll generate a black image, but you'll be able to view the text that it writes out in the message stream.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
#declare MyVariable = 5.2;&lt;br /&gt;
#debug concat(&amp;quot;MyVariable: &amp;quot;,str(MyVariable,3,3),&amp;quot;\n&amp;quot;)&lt;br /&gt;
#switch (MyVariable)&lt;br /&gt;
  #case (0)&lt;br /&gt;
    #debug &amp;quot;As close to nothing as makes a tiny difference.\n&amp;quot;&lt;br /&gt;
  #break &lt;br /&gt;
  #case (1)&lt;br /&gt;
  #case (2)&lt;br /&gt;
  #case (3)&lt;br /&gt;
  #case (5)&lt;br /&gt;
  #case (7)&lt;br /&gt;
    #debug &amp;quot;A Prime number between 1 and 10 (actually within 1e-10 of a prime).\n&amp;quot;&lt;br /&gt;
  #break &lt;br /&gt;
  #range (0,10)&lt;br /&gt;
    #debug &amp;quot;A number between 1 and 10 that is not within 1e-10 of a Prime number\n&amp;quot;&lt;br /&gt;
  #break&lt;br /&gt;
  #range (10,100)&lt;br /&gt;
    #debug &amp;quot;A number between 10 and 100 (actually 10+(1e-10) to 100+(1e-10)).\n&amp;quot;&lt;br /&gt;
  #break&lt;br /&gt;
  #else&lt;br /&gt;
    #debug &amp;quot;Everything else.\n&amp;quot;&lt;br /&gt;
    #debug &amp;quot;ie. Less than zero or greater than 100.\n&amp;quot;&lt;br /&gt;
#end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the parameter to a #case clause matches the parameter to the #switch clause then everything up to the next #break, #else or #end clause is evaluated. Similarly, if the parameter to the #switch clause is between the minimum and maximum values of a #range clause then everything up to the next #break, #else or #end clause is evaluated. &lt;br /&gt;
&lt;br /&gt;
If you are interested, you can explore the sensitivity to the accuracy of the floating point number comparison by setting a value using 'e' as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
#declare MyVariable = 5+(0.5e-10);&lt;br /&gt;
  or&lt;br /&gt;
#declare MyVariable = 5+(1.5e-10);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Using #switch with text values===&lt;br /&gt;
The #switch, #case and #range clauses accept parameters that evaluate to float numbers. This includes the strcmp function which compares two strings and returns a zero if two strings match. By turning the #switch clause on its head a little, you can therefore use it with strings. Using the #switch directive with text can be particularly handy when writing macros that can generate an object in a large number of differently styles, because you can give each style a name and set parameters based on the name of the style specified. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Example of using #switch with text:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
#declare MyVariable = &amp;quot;Ostrich&amp;quot;;&lt;br /&gt;
#switch (0)&lt;br /&gt;
  #case (strcmp(strupr(MyVariable),&amp;quot;DOG&amp;quot;))&lt;br /&gt;
    #debug &amp;quot;Dog, DOG, or dog.\n&amp;quot;&lt;br /&gt;
    // Settings to be used for a dog&lt;br /&gt;
  #break &lt;br /&gt;
  #case (strcmp(strupr(MyVariable),&amp;quot;CAT&amp;quot;))&lt;br /&gt;
    #debug &amp;quot;Cat, CAT, or cat.\n&amp;quot;&lt;br /&gt;
    // Settings to be used for a cat&lt;br /&gt;
  #break &lt;br /&gt;
  #case (strcmp(strupr(MyVariable),&amp;quot;OSTRICH&amp;quot;))&lt;br /&gt;
    #debug &amp;quot;Ostrich, OSTRICH, or ostrich.\n&amp;quot;&lt;br /&gt;
    // Settings to be used for an ostrich&lt;br /&gt;
  #break &lt;br /&gt;
  #else&lt;br /&gt;
    #debug &amp;quot;Not a dog, cat or ostrich.\n&amp;quot;&lt;br /&gt;
    // Stuff to do if an unexpected creature was encountered.&lt;br /&gt;
#end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that the strupr function is used to remove case sensitivity. &lt;br /&gt;
&lt;br /&gt;
The following example illustrates the use of multiple #case clauses for a set of associated conditions to work out how many legs an animal has:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
#declare Animal   = &amp;quot;Ostrich&amp;quot;;&lt;br /&gt;
#switch (0)&lt;br /&gt;
  #case (strcmp(strupr(Animal),&amp;quot;DOG&amp;quot;))&lt;br /&gt;
  #case (strcmp(strupr(Animal),&amp;quot;CAT&amp;quot;))&lt;br /&gt;
  #case (strcmp(strupr(Animal),&amp;quot;RHINOCEROS&amp;quot;))&lt;br /&gt;
  #case (strcmp(strupr(Animal),&amp;quot;TABLE&amp;quot;))&lt;br /&gt;
    #declare LegCount = 4;&lt;br /&gt;
  #break &lt;br /&gt;
  #case (strcmp(strupr(Animal),&amp;quot;OSTRICH&amp;quot;))&lt;br /&gt;
  #case (strcmp(strupr(Animal),&amp;quot;DUCK&amp;quot;))&lt;br /&gt;
    #declare LegCount = 2;&lt;br /&gt;
  #break &lt;br /&gt;
  #case (strcmp(strupr(Animal),&amp;quot;WORM&amp;quot;))&lt;br /&gt;
  #case (strcmp(strupr(Animal),&amp;quot;DOLPHIN&amp;quot;))&lt;br /&gt;
    #declare LegCount = 0;&lt;br /&gt;
  #break &lt;br /&gt;
  #else&lt;br /&gt;
    #declare LegCount = -1; // Unknown&lt;br /&gt;
#end&lt;br /&gt;
&lt;br /&gt;
#debug concat(&amp;quot;Animal: &amp;quot;,Animal,&amp;quot;\n&amp;quot;) &lt;br /&gt;
#if (LegCount&amp;lt;0) #debug &amp;quot;Number of Legs Unknown\n&amp;quot;&lt;br /&gt;
#else #debug concat(&amp;quot;Number of Legs: &amp;quot;,str(LegCount,3,0),&amp;quot;\n&amp;quot;)&lt;br /&gt;
#end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can also test for abbreviations using the following construct:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
  #case (strcmp(strupr(Animal),substr(&amp;quot;RHINOCEROS&amp;quot;,1,strlen(Animal))))&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This would match 'Rhino' or 'Rhinoceros', but you clearly need to be a little careful with this as it would also match 'Rhinoc', 'R' and &amp;lt;nowiki&amp;gt;''&amp;lt;/nowiki&amp;gt;. To set a minimum abbreviation length use the max function:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
  #case (strcmp(strupr(Animal),substr(&amp;quot;RHINOCEROS&amp;quot;,1,max(strlen(Animal),5))))&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This would match 'Rhino', 'Rhinoceros' and everything in between, but not 'R', 'Rhin' or &amp;lt;nowiki&amp;gt;''&amp;lt;/nowiki&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== The #while, #end construct (Loops) ==&lt;br /&gt;
See also - [[HowTo:Use_macros_and_loops]].&lt;br /&gt;
&lt;br /&gt;
The #while, #end construct encapsulates a sequence of POV-Ray statements that are repeatedly executed for as long as the conditional expression specified is true. The conditional expression can be simple or complex and adheres to the same rules as apply to the #if statement described above. &lt;br /&gt;
&lt;br /&gt;
As with the #if statement, the conditional expression must evaluate to a floating point number (often an integer value). This floating point number is interpreted as a boolean value, that is to say that if the expression evaluates to '0', it is considered 'false' and if it evaluates to anything else it is considered 'true'. If the condition is true then directives between the #while statement and a corresponding #end statement are evaluated. The conditional expression is then re-evaluated and, if still true the directives between the #while statement and the corresponding #end statement are repeated. &lt;br /&gt;
&lt;br /&gt;
The statements repeat in a loop until the condition evaluates to false. It is up to you to control the loop by defining a suitable condition that will not loop indefinitely. If the condition never evaluates to false then the program will continue to evaluate the statements forever, until you hit the stop button, until the memory of your computer is exhausted or until you terminate the application (whichever happens first) see [[Wikipedia:Infinite_loop]]. &lt;br /&gt;
&lt;br /&gt;
Note: extremely small values of about 1e-10 are considered zero (false) as a result of floating point number accuracy limits.&lt;br /&gt;
&lt;br /&gt;
Here is an example of a simple loop: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=pov&amp;gt;&lt;br /&gt;
#declare Count=0;&lt;br /&gt;
#while (Count &amp;lt; 5)&lt;br /&gt;
  object { MyObject translate x*3*Count }&lt;br /&gt;
  #declare Count=Count+1;&lt;br /&gt;
#end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
This example places five copies of MyObject in a row spaced three units apart in the x-direction. &lt;br /&gt;
&lt;br /&gt;
As described above (for the #if statement), you can combine conditional terms to build more complex conditional expressions using '&amp;amp;' (And), '|' (Or) and '!' (Not). &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Nested Loops===&lt;br /&gt;
Loops can be nested. This capability is often used to lay out very large numbers of objects using an economical amount of code.&lt;br /&gt;
&lt;br /&gt;
Here's a very simple but complete scene file containing a nested loop that you can play with:&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;source lang=pov&amp;gt;&lt;br /&gt;
#include &amp;quot;colors.inc&amp;quot;&lt;br /&gt;
#include &amp;quot;woods.inc&amp;quot;&lt;br /&gt;
&lt;br /&gt;
camera {location &amp;lt;-1.5,0.9,-0.08&amp;gt; look_at &amp;lt;0,0.7,0.5&amp;gt;}  &lt;br /&gt;
light_source {   &amp;lt;-20,75,-100&amp;gt; rgb White}&lt;br /&gt;
background {LightBlue}&lt;br /&gt;
plane {y,0 pigment {color GreenYellow}}&lt;br /&gt;
&lt;br /&gt;
#declare RandomSeed = seed(1);&lt;br /&gt;
#declare XCount=0;&lt;br /&gt;
#while (XCount &amp;lt; 200)&lt;br /&gt;
  #declare ZCount=0;&lt;br /&gt;
  #while (ZCount &amp;lt; 200)&lt;br /&gt;
    box {&amp;lt;-0.05,0,-0.05&amp;gt;&amp;lt;0.05,1,0.05&amp;gt;&lt;br /&gt;
      rotate &amp;lt;3*rand(RandomSeed),5*rand(RandomSeed),3*rand(RandomSeed)&amp;gt;&lt;br /&gt;
      texture {T_Wood1 translate &amp;lt;rand(RandomSeed),ZCount,rand(RandomSeed)&amp;gt; rotate x*90 scale 0.07}&lt;br /&gt;
      translate &amp;lt;XCount,0,ZCount&amp;gt; &lt;br /&gt;
    }&lt;br /&gt;
    #declare ZCount=ZCount+1;&lt;br /&gt;
  #end &lt;br /&gt;
  #declare XCount=XCount+1;&lt;br /&gt;
#end &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This example uses 2 nested loops. Each nested loop has its own control variable. It starts with both XCount and YCount equal to zero. With XCount at zero, YCount loops from 0 to 199, then XCount is incremented to 1, YCount is reset to zero and the second loop repeats. &lt;br /&gt;
&lt;br /&gt;
This example also introduces a degree of randomness in each iteration using the POV-Ray seed and rand functions. When generating a large number of objects using #while loops you'll find that a little randomness goes a long way. This example generates 40,000 wooden posts, each with a little bit of a wobble and each with a slightly different wood texture pattern. It should take about 10 or 20 seconds to render.&lt;/div&gt;</summary>
		<author><name>Chrisb</name></author>
	</entry>
	<entry>
		<id>https://wiki.povray.org/content?title=HowTo:Use_conditional_structures&amp;diff=519</id>
		<title>HowTo:Use conditional structures</title>
		<link rel="alternate" type="text/html" href="https://wiki.povray.org/content?title=HowTo:Use_conditional_structures&amp;diff=519"/>
		<updated>2008-06-10T19:59:31Z</updated>

		<summary type="html">&lt;p&gt;Chrisb: /* The #switch, #case, #range and #break Directives */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Conditional constructs in POV-Ray are scripting features which perform different computations or actions depending on whether a condition evaluates to true or false. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==The #if, #else, #end construct==&lt;br /&gt;
The simplest conditional directive is the #if directive. This evaluates an expression, which must evaluate to a floating point number (often an integer value). This floating point number is interpreted as a boolean value, that is to say that if the expression evaluates to '0', it is considered 'false' and if it evaluates to anything else it is considered 'true'. If the condition is true then directives between the #if statement and a corresponding #else or #end statement are evaluated.&lt;br /&gt;
Note: extremely small values of about 1e-10 are considered zero (false) as a result of floating point number accuracy limits. &lt;br /&gt;
&lt;br /&gt;
The #else directive is optional but, if specified and the conditional expression was false, then directives between the #else and the corresponding #end statement are evaluated.&lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=pov&amp;gt;&lt;br /&gt;
#declare CameraDistance=25.8;&lt;br /&gt;
 &lt;br /&gt;
 ... Definition of some complex object that looks like a sphere at great distances. ...&lt;br /&gt;
 &lt;br /&gt;
#if (CameraDistance&amp;gt;100)&lt;br /&gt;
   sphere { &amp;lt;0,0,0&amp;gt;, 1.2 pigment {rgb 1}}&lt;br /&gt;
#else&lt;br /&gt;
   object {MyComplexObject}&lt;br /&gt;
#end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here the 'greater than' comparitive operator '&amp;gt;' is used to see whether the value of the CameraDistance variable is greater than 100. In this example, the expression 'CameraDistance&amp;gt;100' evaluates to 0 ('false') because the CameraDistance variable is less than 100.&lt;br /&gt;
&lt;br /&gt;
===Conditional Conjunctions ===&lt;br /&gt;
You can combine conditional terms to build more complex conditional expressions using '&amp;amp;' (And), '|' (Or) and '!' (Not). Use brackets to control the sequence of evaluation. You can also use POV-Ray functions within terms so long as they can be resolved to numeric values. The built-in float identifiers on, off, yes, no, true, and false are designed for use as boolean constants and simply evaluate to 0 (off, no and false) or 1 (on, yes and true).&lt;br /&gt;
&lt;br /&gt;
Here's an example that might take a little thinking about:&lt;br /&gt;
&amp;lt;source lang=pov&amp;gt;&lt;br /&gt;
#declare Clothing=&amp;quot;Jeans&amp;quot;;&lt;br /&gt;
#declare JeansPermitted=false;&lt;br /&gt;
// Check to see if Jeans are permitted&lt;br /&gt;
#if (strcmp(Clothing,&amp;quot;Jeans&amp;quot;)=0 &amp;amp; !JeansPermitted)&lt;br /&gt;
   #debug &amp;quot;Sorry. Jeans are not permitted\n&amp;quot;&lt;br /&gt;
#end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this example, the strcmp function returns a zero because there is no difference between the two strings it has compared.&lt;br /&gt;
The term 'strcmp(Clothing,&amp;quot;Jeans&amp;quot;)=0' therefore returns a 1 (this term is true). The '!' (Not) symbol is used to check for the condition where jeans are not permitted. The '&amp;amp;' symbol is used to combine the two and to therefore test for the condition where Clothing is &amp;quot;Jeans&amp;quot; and jeans are not permitted.&lt;br /&gt;
&lt;br /&gt;
As you've probably realised, there are many ways of expressing the same thing with conditional expressions and the art is in writing it in a way that is clear enough that you will understand it when you read it through again later. It can help to write the condition out as a comment before you build it into an expression. Leaving the comment in place helps anyone reading it later.&lt;br /&gt;
&lt;br /&gt;
== The #ifdef and #ifndef, #else and #end constructs ==&lt;br /&gt;
&lt;br /&gt;
The #ifdef and #ifndef statements can be used to determine whether or not an identifier has been defined and to conditionally execute statements. If the identifier passed to the #ifdef directive exists then the statements between the #ifdef statement and a corresponding #else or #end statement are evaluated. The #else directive is optional but, if specified and the identifier passed to the #ifdef directive does not exist, then directives between the #else and the corresponding #end statement are evaluated.&lt;br /&gt;
&lt;br /&gt;
These statements can help to trap potential errors in a scene file or to set default values.&lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=pov&amp;gt;&lt;br /&gt;
#infdef(ObjectHeight) #declare ObjectHeight=1; #end&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
&lt;br /&gt;
==The #switch, #case, #range and #break Directives==&lt;br /&gt;
The #switch directive provides another way of specifying conditional expressions but allows you to handle a succession of conditions as defined by a #case clause or a #range clause. This directive can seem a little daunting compared to using one or more #if directives, but there are some powerful ways of using it. Like the #if directive it uses float values rather than boolean, so two values whose difference is less than 1e-10 are considered equal.&lt;br /&gt;
&lt;br /&gt;
This trivial example illustrates a number of basic points about the #switch directive. &lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;If a #case or #range clause is not a match it skips to the next one, ignoring everything else in between. &lt;br /&gt;
&amp;lt;li&amp;gt;If a #break is encountered within a matching #case or #range clause the #switch directive stops processing further lines, causing an immediate jump to the #end without processing subsequent sections, even if a subsequent condition would also have been satisfied. &lt;br /&gt;
&amp;lt;li&amp;gt;When processing a matching #case or #range clause, if a #break is not encountered it continues through successive #case statements whether they match or not.&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Although it doesn't contain a camera or any objects, the following example is a complete scene file. When you render it it'll generate a black image, but you'll be able to view the text that it writes out in the message stream.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
#declare MyVariable = 5.2;&lt;br /&gt;
#debug concat(&amp;quot;MyVariable: &amp;quot;,str(MyVariable,3,3),&amp;quot;\n&amp;quot;)&lt;br /&gt;
#switch (MyVariable)&lt;br /&gt;
  #case (0)&lt;br /&gt;
    #debug &amp;quot;As close to nothing as makes a tiny difference.\n&amp;quot;&lt;br /&gt;
  #break &lt;br /&gt;
  #case (1)&lt;br /&gt;
  #case (2)&lt;br /&gt;
  #case (3)&lt;br /&gt;
  #case (5)&lt;br /&gt;
  #case (7)&lt;br /&gt;
    #debug &amp;quot;A Prime number between 1 and 10 (actually within 1e-10 of a prime).\n&amp;quot;&lt;br /&gt;
  #break &lt;br /&gt;
  #range (0,10)&lt;br /&gt;
    #debug &amp;quot;A number between 1 and 10 that is not within 1e-10 of a Prime number\n&amp;quot;&lt;br /&gt;
  #break&lt;br /&gt;
  #range (10,100)&lt;br /&gt;
    #debug &amp;quot;A number between 10 and 100 (actually 10+(1e-10) to 100+(1e-10)).\n&amp;quot;&lt;br /&gt;
  #break&lt;br /&gt;
  #else&lt;br /&gt;
    #debug &amp;quot;Everything else.\n&amp;quot;&lt;br /&gt;
    #debug &amp;quot;ie. Less than zero or greater than 100.\n&amp;quot;&lt;br /&gt;
#end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the parameter to a #case clause matches the parameter to the #switch clause then everything up to the next #break, #else or #end clause is evaluated. Similarly, if the parameter to the #switch clause is between the minimum and maximum values of a #range clause then everything up to the next #break, #else or #end clause is evaluated. To explore the sensitivity to the accuracy of the floating point number comparison you can set a value using 'e' as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
#declare MyVariable = 5+(0.5e-10);&lt;br /&gt;
  or&lt;br /&gt;
#declare MyVariable = 5+(1.5e-10);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Using #switch with text values===&lt;br /&gt;
The #switch, #case and #range clauses accept parameters that evaluate to float numbers. This includes the strcmp function which compares two strings and returns a zero if two strings match. By turning the #switch clause on its head a little, you can therefore use it with strings. Using the #switch directive with text can be particularly handy when writing macros that can generate an object in a large number of differently styles, because you can give each style a name and set parameters based on the name of the style specified. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Example of using #switch with text:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
#declare MyVariable = &amp;quot;Ostrich&amp;quot;;&lt;br /&gt;
#switch (0)&lt;br /&gt;
  #case (strcmp(strupr(MyVariable),&amp;quot;DOG&amp;quot;))&lt;br /&gt;
    #debug &amp;quot;Dog, DOG, or dog.\n&amp;quot;&lt;br /&gt;
    // Settings to be used for a dog&lt;br /&gt;
  #break &lt;br /&gt;
  #case (strcmp(strupr(MyVariable),&amp;quot;CAT&amp;quot;))&lt;br /&gt;
    #debug &amp;quot;Cat, CAT, or cat.\n&amp;quot;&lt;br /&gt;
    // Settings to be used for a cat&lt;br /&gt;
  #break &lt;br /&gt;
  #case (strcmp(strupr(MyVariable),&amp;quot;OSTRICH&amp;quot;))&lt;br /&gt;
    #debug &amp;quot;Ostrich, OSTRICH, or ostrich.\n&amp;quot;&lt;br /&gt;
    // Settings to be used for an ostrich&lt;br /&gt;
  #break &lt;br /&gt;
  #else&lt;br /&gt;
    #debug &amp;quot;Not a dog, cat or ostrich.\n&amp;quot;&lt;br /&gt;
    // Stuff to do if an unexpected creature was encountered.&lt;br /&gt;
#end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that the strupr function is used to remove case sensitivity. &lt;br /&gt;
&lt;br /&gt;
The following example illustrates the use of multiple #case clauses for a set of associated conditions to work out how many legs an animal has:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
#declare Animal   = &amp;quot;Ostrich&amp;quot;;&lt;br /&gt;
#switch (0)&lt;br /&gt;
  #case (strcmp(strupr(Animal),&amp;quot;DOG&amp;quot;))&lt;br /&gt;
  #case (strcmp(strupr(Animal),&amp;quot;CAT&amp;quot;))&lt;br /&gt;
  #case (strcmp(strupr(Animal),&amp;quot;RHINOCEROS&amp;quot;))&lt;br /&gt;
  #case (strcmp(strupr(Animal),&amp;quot;TABLE&amp;quot;))&lt;br /&gt;
    #declare LegCount = 4;&lt;br /&gt;
  #break &lt;br /&gt;
  #case (strcmp(strupr(Animal),&amp;quot;OSTRICH&amp;quot;))&lt;br /&gt;
  #case (strcmp(strupr(Animal),&amp;quot;DUCK&amp;quot;))&lt;br /&gt;
    #declare LegCount = 2;&lt;br /&gt;
  #break &lt;br /&gt;
  #case (strcmp(strupr(Animal),&amp;quot;WORM&amp;quot;))&lt;br /&gt;
  #case (strcmp(strupr(Animal),&amp;quot;DOLPHIN&amp;quot;))&lt;br /&gt;
    #declare LegCount = 0;&lt;br /&gt;
  #break &lt;br /&gt;
  #else&lt;br /&gt;
    #declare LegCount = -1; // Unknown&lt;br /&gt;
#end&lt;br /&gt;
&lt;br /&gt;
#debug concat(&amp;quot;Animal: &amp;quot;,Animal,&amp;quot;\n&amp;quot;) &lt;br /&gt;
#if (LegCount&amp;lt;0) #debug &amp;quot;Number of Legs Unknown\n&amp;quot;&lt;br /&gt;
#else #debug concat(&amp;quot;Number of Legs: &amp;quot;,str(LegCount,3,0),&amp;quot;\n&amp;quot;)&lt;br /&gt;
#end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can also test for abbreviations using the following construct:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
  #case (strcmp(strupr(Animal),substr(&amp;quot;RHINOCEROS&amp;quot;,1,strlen(Animal))))&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This would match 'Rhino' or 'Rhinoceros', but you clearly need to be a little careful with this as it would also match 'Rhinoc', 'R' and &amp;lt;nowiki&amp;gt;''&amp;lt;/nowiki&amp;gt;. To set a minimum abbreviation length use the max function:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
  #case (strcmp(strupr(Animal),substr(&amp;quot;RHINOCEROS&amp;quot;,1,max(strlen(Animal),5))))&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This would match 'Rhino', 'Rhinoceros' and everything in between, but not 'R', 'Rhin' or &amp;lt;nowiki&amp;gt;''&amp;lt;/nowiki&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== The #while, #end construct (Loops) ==&lt;br /&gt;
See also - [[HowTo:Use_macros_and_loops]].&lt;br /&gt;
&lt;br /&gt;
The #while, #end construct encapsulates a sequence of POV-Ray statements that are repeatedly executed for as long as the conditional expression specified is true. The conditional expression can be simple or complex and adheres to the same rules as apply to the #if statement described above. &lt;br /&gt;
&lt;br /&gt;
As with the #if statement, the conditional expression must evaluate to a floating point number (often an integer value). This floating point number is interpreted as a boolean value, that is to say that if the expression evaluates to '0', it is considered 'false' and if it evaluates to anything else it is considered 'true'. If the condition is true then directives between the #while statement and a corresponding #end statement are evaluated. The conditional expression is then re-evaluated and, if still true the directives between the #while statement and the corresponding #end statement are repeated. &lt;br /&gt;
&lt;br /&gt;
The statements repeat in a loop until the condition evaluates to false. It is up to you to control the loop by defining a suitable condition that will not loop indefinitely. If the condition never evaluates to false then the program will continue to evaluate the statements forever, until you hit the stop button, until the memory of your computer is exhausted or until you terminate the application (whichever happens first) see [[Wikipedia:Infinite_loop]]. &lt;br /&gt;
&lt;br /&gt;
Note: extremely small values of about 1e-10 are considered zero (false) as a result of floating point number accuracy limits.&lt;br /&gt;
&lt;br /&gt;
Here is an example of a simple loop: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=pov&amp;gt;&lt;br /&gt;
#declare Count=0;&lt;br /&gt;
#while (Count &amp;lt; 5)&lt;br /&gt;
  object { MyObject translate x*3*Count }&lt;br /&gt;
  #declare Count=Count+1;&lt;br /&gt;
#end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
This example places five copies of MyObject in a row spaced three units apart in the x-direction. &lt;br /&gt;
&lt;br /&gt;
As described above (for the #if statement), you can combine conditional terms to build more complex conditional expressions using '&amp;amp;' (And), '|' (Or) and '!' (Not). &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Nested Loops===&lt;br /&gt;
Loops can be nested. This capability is often used to lay out very large numbers of objects using an economical amount of code.&lt;br /&gt;
&lt;br /&gt;
Here's a very simple but complete scene file containing a nested loop that you can play with:&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;source lang=pov&amp;gt;&lt;br /&gt;
#include &amp;quot;colors.inc&amp;quot;&lt;br /&gt;
#include &amp;quot;woods.inc&amp;quot;&lt;br /&gt;
&lt;br /&gt;
camera {location &amp;lt;-1.5,0.9,-0.08&amp;gt; look_at &amp;lt;0,0.7,0.5&amp;gt;}  &lt;br /&gt;
light_source {   &amp;lt;-20,75,-100&amp;gt; rgb White}&lt;br /&gt;
background {LightBlue}&lt;br /&gt;
plane {y,0 pigment {color GreenYellow}}&lt;br /&gt;
&lt;br /&gt;
#declare RandomSeed = seed(1);&lt;br /&gt;
#declare XCount=0;&lt;br /&gt;
#while (XCount &amp;lt; 200)&lt;br /&gt;
  #declare ZCount=0;&lt;br /&gt;
  #while (ZCount &amp;lt; 200)&lt;br /&gt;
    box {&amp;lt;-0.05,0,-0.05&amp;gt;&amp;lt;0.05,1,0.05&amp;gt;&lt;br /&gt;
      rotate &amp;lt;3*rand(RandomSeed),5*rand(RandomSeed),3*rand(RandomSeed)&amp;gt;&lt;br /&gt;
      texture {T_Wood1 translate &amp;lt;rand(RandomSeed),ZCount,rand(RandomSeed)&amp;gt; rotate x*90 scale 0.07}&lt;br /&gt;
      translate &amp;lt;XCount,0,ZCount&amp;gt; &lt;br /&gt;
    }&lt;br /&gt;
    #declare ZCount=ZCount+1;&lt;br /&gt;
  #end &lt;br /&gt;
  #declare XCount=XCount+1;&lt;br /&gt;
#end &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This example uses 2 nested loops. Each nested loop has its own control variable. It starts with both XCount and YCount equal to zero. With XCount at zero, YCount loops from 0 to 199, then XCount is incremented to 1, YCount is reset to zero and the second loop repeats. &lt;br /&gt;
&lt;br /&gt;
This example also introduces a degree of randomness in each iteration using the POV-Ray seed and rand functions. When generating a large number of objects using #while loops you'll find that a little randomness goes a long way. This example generates 40,000 wooden posts, each with a little bit of a wobble and each with a slightly different wood texture pattern. It should take about 10 or 20 seconds to render.&lt;/div&gt;</summary>
		<author><name>Chrisb</name></author>
	</entry>
	<entry>
		<id>https://wiki.povray.org/content?title=HowTo:Use_conditional_structures&amp;diff=518</id>
		<title>HowTo:Use conditional structures</title>
		<link rel="alternate" type="text/html" href="https://wiki.povray.org/content?title=HowTo:Use_conditional_structures&amp;diff=518"/>
		<updated>2008-06-10T19:52:01Z</updated>

		<summary type="html">&lt;p&gt;Chrisb: Added #ifdef and #ifndef&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Conditional constructs in POV-Ray are scripting features which perform different computations or actions depending on whether a condition evaluates to true or false. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==The #if, #else, #end construct==&lt;br /&gt;
The simplest conditional directive is the #if directive. This evaluates an expression, which must evaluate to a floating point number (often an integer value). This floating point number is interpreted as a boolean value, that is to say that if the expression evaluates to '0', it is considered 'false' and if it evaluates to anything else it is considered 'true'. If the condition is true then directives between the #if statement and a corresponding #else or #end statement are evaluated.&lt;br /&gt;
Note: extremely small values of about 1e-10 are considered zero (false) as a result of floating point number accuracy limits. &lt;br /&gt;
&lt;br /&gt;
The #else directive is optional but, if specified and the conditional expression was false, then directives between the #else and the corresponding #end statement are evaluated.&lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=pov&amp;gt;&lt;br /&gt;
#declare CameraDistance=25.8;&lt;br /&gt;
 &lt;br /&gt;
 ... Definition of some complex object that looks like a sphere at great distances. ...&lt;br /&gt;
 &lt;br /&gt;
#if (CameraDistance&amp;gt;100)&lt;br /&gt;
   sphere { &amp;lt;0,0,0&amp;gt;, 1.2 pigment {rgb 1}}&lt;br /&gt;
#else&lt;br /&gt;
   object {MyComplexObject}&lt;br /&gt;
#end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here the 'greater than' comparitive operator '&amp;gt;' is used to see whether the value of the CameraDistance variable is greater than 100. In this example, the expression 'CameraDistance&amp;gt;100' evaluates to 0 ('false') because the CameraDistance variable is less than 100.&lt;br /&gt;
&lt;br /&gt;
===Conditional Conjunctions ===&lt;br /&gt;
You can combine conditional terms to build more complex conditional expressions using '&amp;amp;' (And), '|' (Or) and '!' (Not). Use brackets to control the sequence of evaluation. You can also use POV-Ray functions within terms so long as they can be resolved to numeric values. The built-in float identifiers on, off, yes, no, true, and false are designed for use as boolean constants and simply evaluate to 0 (off, no and false) or 1 (on, yes and true).&lt;br /&gt;
&lt;br /&gt;
Here's an example that might take a little thinking about:&lt;br /&gt;
&amp;lt;source lang=pov&amp;gt;&lt;br /&gt;
#declare Clothing=&amp;quot;Jeans&amp;quot;;&lt;br /&gt;
#declare JeansPermitted=false;&lt;br /&gt;
// Check to see if Jeans are permitted&lt;br /&gt;
#if (strcmp(Clothing,&amp;quot;Jeans&amp;quot;)=0 &amp;amp; !JeansPermitted)&lt;br /&gt;
   #debug &amp;quot;Sorry. Jeans are not permitted\n&amp;quot;&lt;br /&gt;
#end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this example, the strcmp function returns a zero because there is no difference between the two strings it has compared.&lt;br /&gt;
The term 'strcmp(Clothing,&amp;quot;Jeans&amp;quot;)=0' therefore returns a 1 (this term is true). The '!' (Not) symbol is used to check for the condition where jeans are not permitted. The '&amp;amp;' symbol is used to combine the two and to therefore test for the condition where Clothing is &amp;quot;Jeans&amp;quot; and jeans are not permitted.&lt;br /&gt;
&lt;br /&gt;
As you've probably realised, there are many ways of expressing the same thing with conditional expressions and the art is in writing it in a way that is clear enough that you will understand it when you read it through again later. It can help to write the condition out as a comment before you build it into an expression. Leaving the comment in place helps anyone reading it later.&lt;br /&gt;
&lt;br /&gt;
== The #ifdef and #ifndef, #else and #end constructs ==&lt;br /&gt;
&lt;br /&gt;
The #ifdef and #ifndef statements can be used to determine whether or not an identifier has been defined and to conditionally execute statements. If the identifier passed to the #ifdef directive exists then the statements between the #ifdef statement and a corresponding #else or #end statement are evaluated. The #else directive is optional but, if specified and the identifier passed to the #ifdef directive does not exist, then directives between the #else and the corresponding #end statement are evaluated.&lt;br /&gt;
&lt;br /&gt;
These statements can help to trap potential errors in a scene file or to set default values.&lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=pov&amp;gt;&lt;br /&gt;
#infdef(ObjectHeight) #declare ObjectHeight=1; #end&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
&lt;br /&gt;
==The #switch, #case, #range and #break Directives==&lt;br /&gt;
The #switch directive provides another way of specifying conditional expressions but allows you to handle a succession of conditions as defined by a #case clause or a #range clause. This directive can seem a little daunting compared to using one or more #if directives, but there are some powerful ways of using it. Like the #if directive it uses float values rather than boolean, so two values whose difference is less than 1e-10 are considered equal.&lt;br /&gt;
&lt;br /&gt;
This trivial example illustrates a number of basic points about the #switch directive. &lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;If a #case or #range clause is not a match it skips to the next one, ignoring everything else in between. &lt;br /&gt;
&amp;lt;li&amp;gt;If a #break is encountered within a matching #case or #range clause the #switch directive stops processing further lines, causing an immediate jump to the #end without processing subsequent sections, even if a subsequent condition would also have been satisfied. &lt;br /&gt;
&amp;lt;li&amp;gt;When processing a matching #case or #range clause, if a #break is not encountered it continues through successive #case statements whether they match or not.&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
#declare MyVariable = 5.2;&lt;br /&gt;
#debug concat(&amp;quot;MyVariable: &amp;quot;,str(MyVariable,3,3),&amp;quot;\n&amp;quot;)&lt;br /&gt;
#switch (MyVariable)&lt;br /&gt;
  #case (0)&lt;br /&gt;
    #debug &amp;quot;As close to nothing as makes a tiny difference.\n&amp;quot;&lt;br /&gt;
  #break &lt;br /&gt;
  #case (1)&lt;br /&gt;
  #case (2)&lt;br /&gt;
  #case (3)&lt;br /&gt;
  #case (5)&lt;br /&gt;
  #case (7)&lt;br /&gt;
    #debug &amp;quot;A Prime number between 1 and 10 (actually within 1e-10 of a prime).\n&amp;quot;&lt;br /&gt;
  #break &lt;br /&gt;
  #range (0,10)&lt;br /&gt;
    #debug &amp;quot;A number between 1 and 10 that is not within 1e-10 of a Prime number\n&amp;quot;&lt;br /&gt;
  #break&lt;br /&gt;
  #range (10,100)&lt;br /&gt;
    #debug &amp;quot;A number between 10 and 100 (actually 10+(1e-10) to 100+(1e-10)).\n&amp;quot;&lt;br /&gt;
  #break&lt;br /&gt;
  #else&lt;br /&gt;
    #debug &amp;quot;Everything else.\n&amp;quot;&lt;br /&gt;
    #debug &amp;quot;ie. Less than zero or greater than 100.\n&amp;quot;&lt;br /&gt;
#end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the parameter to a #case clause matches the parameter to the #switch clause then everything up to the next #break, #else or #end clause is evaluated. Similarly, if the parameter to the #switch clause is between the minimum and maximum values of a #range clause then everything up to the next #break, #else or #end clause is evaluated. To explore the sensitivity to the accuracy of the floating point number comparison you can set a value using 'e' as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
#declare MyVariable = 5+(0.5e-10);&lt;br /&gt;
  or&lt;br /&gt;
#declare MyVariable = 5+(1.5e-10);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Using #switch with text values===&lt;br /&gt;
The #switch, #case and #range clauses accept parameters that evaluate to float numbers. This includes the strcmp function which compares two strings and returns a zero if two strings match. By turning the #switch clause on its head a little, you can therefore use it with strings. Using the #switch directive with text can be particularly handy when writing macros that can generate an object in a large number of differently styles, because you can give each style a name and set parameters based on the name of the style specified. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Example of using #switch with text:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
#declare MyVariable = &amp;quot;Ostrich&amp;quot;;&lt;br /&gt;
#switch (0)&lt;br /&gt;
  #case (strcmp(strupr(MyVariable),&amp;quot;DOG&amp;quot;))&lt;br /&gt;
    #debug &amp;quot;Dog, DOG, or dog.\n&amp;quot;&lt;br /&gt;
    // Settings to be used for a dog&lt;br /&gt;
  #break &lt;br /&gt;
  #case (strcmp(strupr(MyVariable),&amp;quot;CAT&amp;quot;))&lt;br /&gt;
    #debug &amp;quot;Cat, CAT, or cat.\n&amp;quot;&lt;br /&gt;
    // Settings to be used for a cat&lt;br /&gt;
  #break &lt;br /&gt;
  #case (strcmp(strupr(MyVariable),&amp;quot;OSTRICH&amp;quot;))&lt;br /&gt;
    #debug &amp;quot;Ostrich, OSTRICH, or ostrich.\n&amp;quot;&lt;br /&gt;
    // Settings to be used for an ostrich&lt;br /&gt;
  #break &lt;br /&gt;
  #else&lt;br /&gt;
    #debug &amp;quot;Not a dog, cat or ostrich.\n&amp;quot;&lt;br /&gt;
    // Stuff to do if an unexpected creature was encountered.&lt;br /&gt;
#end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that the strupr function is used to remove case sensitivity. &lt;br /&gt;
&lt;br /&gt;
The following example illustrates the use of multiple #case clauses for a set of associated conditions to work out how many legs an animal has:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
#declare Animal   = &amp;quot;Ostrich&amp;quot;;&lt;br /&gt;
#switch (0)&lt;br /&gt;
  #case (strcmp(strupr(Animal),&amp;quot;DOG&amp;quot;))&lt;br /&gt;
  #case (strcmp(strupr(Animal),&amp;quot;CAT&amp;quot;))&lt;br /&gt;
  #case (strcmp(strupr(Animal),&amp;quot;RHINOCEROS&amp;quot;))&lt;br /&gt;
  #case (strcmp(strupr(Animal),&amp;quot;TABLE&amp;quot;))&lt;br /&gt;
    #declare LegCount = 4;&lt;br /&gt;
  #break &lt;br /&gt;
  #case (strcmp(strupr(Animal),&amp;quot;OSTRICH&amp;quot;))&lt;br /&gt;
  #case (strcmp(strupr(Animal),&amp;quot;DUCK&amp;quot;))&lt;br /&gt;
    #declare LegCount = 2;&lt;br /&gt;
  #break &lt;br /&gt;
  #case (strcmp(strupr(Animal),&amp;quot;WORM&amp;quot;))&lt;br /&gt;
  #case (strcmp(strupr(Animal),&amp;quot;DOLPHIN&amp;quot;))&lt;br /&gt;
    #declare LegCount = 0;&lt;br /&gt;
  #break &lt;br /&gt;
  #else&lt;br /&gt;
    #declare LegCount = -1; // Unknown&lt;br /&gt;
#end&lt;br /&gt;
&lt;br /&gt;
#debug concat(&amp;quot;Animal: &amp;quot;,Animal,&amp;quot;\n&amp;quot;) &lt;br /&gt;
#if (LegCount&amp;lt;0) #debug &amp;quot;Number of Legs Unknown\n&amp;quot;&lt;br /&gt;
#else #debug concat(&amp;quot;Number of Legs: &amp;quot;,str(LegCount,3,0),&amp;quot;\n&amp;quot;)&lt;br /&gt;
#end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can also test for abbreviations using the following construct:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
  #case (strcmp(strupr(Animal),substr(&amp;quot;RHINOCEROS&amp;quot;,1,strlen(Animal))))&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This would match 'Rhino' or 'Rhinoceros', but you clearly need to be a little careful with this as it would also match 'Rhinoc', 'R' and &amp;lt;nowiki&amp;gt;''&amp;lt;/nowiki&amp;gt;. To set a minimum abbreviation length use the max function:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
  #case (strcmp(strupr(Animal),substr(&amp;quot;RHINOCEROS&amp;quot;,1,max(strlen(Animal),5))))&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This would match 'Rhino', 'Rhinoceros' and everything in between, but not 'R', 'Rhin' or &amp;lt;nowiki&amp;gt;''&amp;lt;/nowiki&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== The #while, #end construct (Loops) ==&lt;br /&gt;
See also - [[HowTo:Use_macros_and_loops]].&lt;br /&gt;
&lt;br /&gt;
The #while, #end construct encapsulates a sequence of POV-Ray statements that are repeatedly executed for as long as the conditional expression specified is true. The conditional expression can be simple or complex and adheres to the same rules as apply to the #if statement described above. &lt;br /&gt;
&lt;br /&gt;
As with the #if statement, the conditional expression must evaluate to a floating point number (often an integer value). This floating point number is interpreted as a boolean value, that is to say that if the expression evaluates to '0', it is considered 'false' and if it evaluates to anything else it is considered 'true'. If the condition is true then directives between the #while statement and a corresponding #end statement are evaluated. The conditional expression is then re-evaluated and, if still true the directives between the #while statement and the corresponding #end statement are repeated. &lt;br /&gt;
&lt;br /&gt;
The statements repeat in a loop until the condition evaluates to false. It is up to you to control the loop by defining a suitable condition that will not loop indefinitely. If the condition never evaluates to false then the program will continue to evaluate the statements forever, until you hit the stop button, until the memory of your computer is exhausted or until you terminate the application (whichever happens first) see [[Wikipedia:Infinite_loop]]. &lt;br /&gt;
&lt;br /&gt;
Note: extremely small values of about 1e-10 are considered zero (false) as a result of floating point number accuracy limits.&lt;br /&gt;
&lt;br /&gt;
Here is an example of a simple loop: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=pov&amp;gt;&lt;br /&gt;
#declare Count=0;&lt;br /&gt;
#while (Count &amp;lt; 5)&lt;br /&gt;
  object { MyObject translate x*3*Count }&lt;br /&gt;
  #declare Count=Count+1;&lt;br /&gt;
#end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
This example places five copies of MyObject in a row spaced three units apart in the x-direction. &lt;br /&gt;
&lt;br /&gt;
As described above (for the #if statement), you can combine conditional terms to build more complex conditional expressions using '&amp;amp;' (And), '|' (Or) and '!' (Not). &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Nested Loops===&lt;br /&gt;
Loops can be nested. This capability is often used to lay out very large numbers of objects using an economical amount of code.&lt;br /&gt;
&lt;br /&gt;
Here's a very simple but complete scene file containing a nested loop that you can play with:&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;source lang=pov&amp;gt;&lt;br /&gt;
#include &amp;quot;colors.inc&amp;quot;&lt;br /&gt;
#include &amp;quot;woods.inc&amp;quot;&lt;br /&gt;
&lt;br /&gt;
camera {location &amp;lt;-1.5,0.9,-0.08&amp;gt; look_at &amp;lt;0,0.7,0.5&amp;gt;}  &lt;br /&gt;
light_source {   &amp;lt;-20,75,-100&amp;gt; rgb White}&lt;br /&gt;
background {LightBlue}&lt;br /&gt;
plane {y,0 pigment {color GreenYellow}}&lt;br /&gt;
&lt;br /&gt;
#declare RandomSeed = seed(1);&lt;br /&gt;
#declare XCount=0;&lt;br /&gt;
#while (XCount &amp;lt; 200)&lt;br /&gt;
  #declare ZCount=0;&lt;br /&gt;
  #while (ZCount &amp;lt; 200)&lt;br /&gt;
    box {&amp;lt;-0.05,0,-0.05&amp;gt;&amp;lt;0.05,1,0.05&amp;gt;&lt;br /&gt;
      rotate &amp;lt;3*rand(RandomSeed),5*rand(RandomSeed),3*rand(RandomSeed)&amp;gt;&lt;br /&gt;
      texture {T_Wood1 translate &amp;lt;rand(RandomSeed),ZCount,rand(RandomSeed)&amp;gt; rotate x*90 scale 0.07}&lt;br /&gt;
      translate &amp;lt;XCount,0,ZCount&amp;gt; &lt;br /&gt;
    }&lt;br /&gt;
    #declare ZCount=ZCount+1;&lt;br /&gt;
  #end &lt;br /&gt;
  #declare XCount=XCount+1;&lt;br /&gt;
#end &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This example uses 2 nested loops. Each nested loop has its own control variable. It starts with both XCount and YCount equal to zero. With XCount at zero, YCount loops from 0 to 199, then XCount is incremented to 1, YCount is reset to zero and the second loop repeats. &lt;br /&gt;
&lt;br /&gt;
This example also introduces a degree of randomness in each iteration using the POV-Ray seed and rand functions. When generating a large number of objects using #while loops you'll find that a little randomness goes a long way. This example generates 40,000 wooden posts, each with a little bit of a wobble and each with a slightly different wood texture pattern. It should take about 10 or 20 seconds to render.&lt;/div&gt;</summary>
		<author><name>Chrisb</name></author>
	</entry>
	<entry>
		<id>https://wiki.povray.org/content?title=HowTo:Use_conditional_structures&amp;diff=517</id>
		<title>HowTo:Use conditional structures</title>
		<link rel="alternate" type="text/html" href="https://wiki.povray.org/content?title=HowTo:Use_conditional_structures&amp;diff=517"/>
		<updated>2008-06-10T19:48:37Z</updated>

		<summary type="html">&lt;p&gt;Chrisb: Added section on #while conditions&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Conditional constructs in POV-Ray are scripting features which perform different computations or actions depending on whether a condition evaluates to true or false. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==The #if, #else, #end construct==&lt;br /&gt;
The simplest conditional directive is the #if directive. This evaluates an expression, which must evaluate to a floating point number (often an integer value). This floating point number is interpreted as a boolean value, that is to say that if the expression evaluates to '0', it is considered 'false' and if it evaluates to anything else it is considered 'true'. If the condition is true then directives between the #if statement and a corresponding #else or #end statement are evaluated.&lt;br /&gt;
Note: extremely small values of about 1e-10 are considered zero (false) as a result of floating point number accuracy limits. &lt;br /&gt;
&lt;br /&gt;
The #else directive is optional but, if specified and the conditional expression was false, then directives between the #else and the corresponding #end statement are evaluated.&lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=pov&amp;gt;&lt;br /&gt;
#declare CameraDistance=25.8;&lt;br /&gt;
 &lt;br /&gt;
 ... Definition of some complex object that looks like a sphere at great distances. ...&lt;br /&gt;
 &lt;br /&gt;
#if (CameraDistance&amp;gt;100)&lt;br /&gt;
   sphere { &amp;lt;0,0,0&amp;gt;, 1.2 pigment {rgb 1}}&lt;br /&gt;
#else&lt;br /&gt;
   object {MyComplexObject}&lt;br /&gt;
#end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here the 'greater than' comparitive operator '&amp;gt;' is used to see whether the value of the CameraDistance variable is greater than 100. In this example, the expression 'CameraDistance&amp;gt;100' evaluates to 0 ('false') because the CameraDistance variable is less than 100.&lt;br /&gt;
&lt;br /&gt;
===Conditional Conjunctions ===&lt;br /&gt;
You can combine conditional terms to build more complex conditional expressions using '&amp;amp;' (And), '|' (Or) and '!' (Not). Use brackets to control the sequence of evaluation. You can also use POV-Ray functions within terms so long as they can be resolved to numeric values. The built-in float identifiers on, off, yes, no, true, and false are designed for use as boolean constants and simply evaluate to 0 (off, no and false) or 1 (on, yes and true).&lt;br /&gt;
&lt;br /&gt;
Here's an example that might take a little thinking about:&lt;br /&gt;
&amp;lt;source lang=pov&amp;gt;&lt;br /&gt;
#declare Clothing=&amp;quot;Jeans&amp;quot;;&lt;br /&gt;
#declare JeansPermitted=false;&lt;br /&gt;
// Check to see if Jeans are permitted&lt;br /&gt;
#if (strcmp(Clothing,&amp;quot;Jeans&amp;quot;)=0 &amp;amp; !JeansPermitted)&lt;br /&gt;
   #debug &amp;quot;Sorry. Jeans are not permitted\n&amp;quot;&lt;br /&gt;
#end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this example, the strcmp function returns a zero because there is no difference between the two strings it has compared.&lt;br /&gt;
The term 'strcmp(Clothing,&amp;quot;Jeans&amp;quot;)=0' therefore returns a 1 (this term is true). The '!' (Not) symbol is used to check for the condition where jeans are not permitted. The '&amp;amp;' symbol is used to combine the two and to therefore test for the condition where Clothing is &amp;quot;Jeans&amp;quot; and jeans are not permitted.&lt;br /&gt;
&lt;br /&gt;
As you've probably realised, there are many ways of expressing the same thing with conditional expressions and the art is in writing it in a way that is clear enough that you will understand it when you read it through again later. It can help to write the condition out as a comment before you build it into an expression. Leaving the comment in place helps anyone reading it later.&lt;br /&gt;
&lt;br /&gt;
==The #switch, #case, #range and #break Directives==&lt;br /&gt;
The #switch directive provides another way of specifying conditional expressions but allows you to handle a succession of conditions as defined by a #case clause or a #range clause. This directive can seem a little daunting compared to using one or more #if directives, but there are some powerful ways of using it. Like the #if directive it uses float values rather than boolean, so two values whose difference is less than 1e-10 are considered equal.&lt;br /&gt;
&lt;br /&gt;
This trivial example illustrates a number of basic points about the #switch directive. &lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;If a #case or #range clause is not a match it skips to the next one, ignoring everything else in between. &lt;br /&gt;
&amp;lt;li&amp;gt;If a #break is encountered within a matching #case or #range clause the #switch directive stops processing further lines, causing an immediate jump to the #end without processing subsequent sections, even if a subsequent condition would also have been satisfied. &lt;br /&gt;
&amp;lt;li&amp;gt;When processing a matching #case or #range clause, if a #break is not encountered it continues through successive #case statements whether they match or not.&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
#declare MyVariable = 5.2;&lt;br /&gt;
#debug concat(&amp;quot;MyVariable: &amp;quot;,str(MyVariable,3,3),&amp;quot;\n&amp;quot;)&lt;br /&gt;
#switch (MyVariable)&lt;br /&gt;
  #case (0)&lt;br /&gt;
    #debug &amp;quot;As close to nothing as makes a tiny difference.\n&amp;quot;&lt;br /&gt;
  #break &lt;br /&gt;
  #case (1)&lt;br /&gt;
  #case (2)&lt;br /&gt;
  #case (3)&lt;br /&gt;
  #case (5)&lt;br /&gt;
  #case (7)&lt;br /&gt;
    #debug &amp;quot;A Prime number between 1 and 10 (actually within 1e-10 of a prime).\n&amp;quot;&lt;br /&gt;
  #break &lt;br /&gt;
  #range (0,10)&lt;br /&gt;
    #debug &amp;quot;A number between 1 and 10 that is not within 1e-10 of a Prime number\n&amp;quot;&lt;br /&gt;
  #break&lt;br /&gt;
  #range (10,100)&lt;br /&gt;
    #debug &amp;quot;A number between 10 and 100 (actually 10+(1e-10) to 100+(1e-10)).\n&amp;quot;&lt;br /&gt;
  #break&lt;br /&gt;
  #else&lt;br /&gt;
    #debug &amp;quot;Everything else.\n&amp;quot;&lt;br /&gt;
    #debug &amp;quot;ie. Less than zero or greater than 100.\n&amp;quot;&lt;br /&gt;
#end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the parameter to a #case clause matches the parameter to the #switch clause then everything up to the next #break, #else or #end clause is evaluated. Similarly, if the parameter to the #switch clause is between the minimum and maximum values of a #range clause then everything up to the next #break, #else or #end clause is evaluated. To explore the sensitivity to the accuracy of the floating point number comparison you can set a value using 'e' as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
#declare MyVariable = 5+(0.5e-10);&lt;br /&gt;
  or&lt;br /&gt;
#declare MyVariable = 5+(1.5e-10);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Using #switch with text values===&lt;br /&gt;
The #switch, #case and #range clauses accept parameters that evaluate to float numbers. This includes the strcmp function which compares two strings and returns a zero if two strings match. By turning the #switch clause on its head a little, you can therefore use it with strings. Using the #switch directive with text can be particularly handy when writing macros that can generate an object in a large number of differently styles, because you can give each style a name and set parameters based on the name of the style specified. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Example of using #switch with text:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
#declare MyVariable = &amp;quot;Ostrich&amp;quot;;&lt;br /&gt;
#switch (0)&lt;br /&gt;
  #case (strcmp(strupr(MyVariable),&amp;quot;DOG&amp;quot;))&lt;br /&gt;
    #debug &amp;quot;Dog, DOG, or dog.\n&amp;quot;&lt;br /&gt;
    // Settings to be used for a dog&lt;br /&gt;
  #break &lt;br /&gt;
  #case (strcmp(strupr(MyVariable),&amp;quot;CAT&amp;quot;))&lt;br /&gt;
    #debug &amp;quot;Cat, CAT, or cat.\n&amp;quot;&lt;br /&gt;
    // Settings to be used for a cat&lt;br /&gt;
  #break &lt;br /&gt;
  #case (strcmp(strupr(MyVariable),&amp;quot;OSTRICH&amp;quot;))&lt;br /&gt;
    #debug &amp;quot;Ostrich, OSTRICH, or ostrich.\n&amp;quot;&lt;br /&gt;
    // Settings to be used for an ostrich&lt;br /&gt;
  #break &lt;br /&gt;
  #else&lt;br /&gt;
    #debug &amp;quot;Not a dog, cat or ostrich.\n&amp;quot;&lt;br /&gt;
    // Stuff to do if an unexpected creature was encountered.&lt;br /&gt;
#end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that the strupr function is used to remove case sensitivity. &lt;br /&gt;
&lt;br /&gt;
The following example illustrates the use of multiple #case clauses for a set of associated conditions to work out how many legs an animal has:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
#declare Animal   = &amp;quot;Ostrich&amp;quot;;&lt;br /&gt;
#switch (0)&lt;br /&gt;
  #case (strcmp(strupr(Animal),&amp;quot;DOG&amp;quot;))&lt;br /&gt;
  #case (strcmp(strupr(Animal),&amp;quot;CAT&amp;quot;))&lt;br /&gt;
  #case (strcmp(strupr(Animal),&amp;quot;RHINOCEROS&amp;quot;))&lt;br /&gt;
  #case (strcmp(strupr(Animal),&amp;quot;TABLE&amp;quot;))&lt;br /&gt;
    #declare LegCount = 4;&lt;br /&gt;
  #break &lt;br /&gt;
  #case (strcmp(strupr(Animal),&amp;quot;OSTRICH&amp;quot;))&lt;br /&gt;
  #case (strcmp(strupr(Animal),&amp;quot;DUCK&amp;quot;))&lt;br /&gt;
    #declare LegCount = 2;&lt;br /&gt;
  #break &lt;br /&gt;
  #case (strcmp(strupr(Animal),&amp;quot;WORM&amp;quot;))&lt;br /&gt;
  #case (strcmp(strupr(Animal),&amp;quot;DOLPHIN&amp;quot;))&lt;br /&gt;
    #declare LegCount = 0;&lt;br /&gt;
  #break &lt;br /&gt;
  #else&lt;br /&gt;
    #declare LegCount = -1; // Unknown&lt;br /&gt;
#end&lt;br /&gt;
&lt;br /&gt;
#debug concat(&amp;quot;Animal: &amp;quot;,Animal,&amp;quot;\n&amp;quot;) &lt;br /&gt;
#if (LegCount&amp;lt;0) #debug &amp;quot;Number of Legs Unknown\n&amp;quot;&lt;br /&gt;
#else #debug concat(&amp;quot;Number of Legs: &amp;quot;,str(LegCount,3,0),&amp;quot;\n&amp;quot;)&lt;br /&gt;
#end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can also test for abbreviations using the following construct:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
  #case (strcmp(strupr(Animal),substr(&amp;quot;RHINOCEROS&amp;quot;,1,strlen(Animal))))&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This would match 'Rhino' or 'Rhinoceros', but you clearly need to be a little careful with this as it would also match 'Rhinoc', 'R' and &amp;lt;nowiki&amp;gt;''&amp;lt;/nowiki&amp;gt;. To set a minimum abbreviation length use the max function:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
  #case (strcmp(strupr(Animal),substr(&amp;quot;RHINOCEROS&amp;quot;,1,max(strlen(Animal),5))))&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This would match 'Rhino', 'Rhinoceros' and everything in between, but not 'R', 'Rhin' or &amp;lt;nowiki&amp;gt;''&amp;lt;/nowiki&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== The #while, #end construct (Loops) ==&lt;br /&gt;
See also - [[HowTo:Use_macros_and_loops]].&lt;br /&gt;
&lt;br /&gt;
The #while, #end construct encapsulates a sequence of POV-Ray statements that are repeatedly executed for as long as the conditional expression specified is true. The conditional expression can be simple or complex and adheres to the same rules as apply to the #if statement described above. &lt;br /&gt;
&lt;br /&gt;
As with the #if statement, the conditional expression must evaluate to a floating point number (often an integer value). This floating point number is interpreted as a boolean value, that is to say that if the expression evaluates to '0', it is considered 'false' and if it evaluates to anything else it is considered 'true'. If the condition is true then directives between the #while statement and a corresponding #end statement are evaluated. The conditional expression is then re-evaluated and, if still true the directives between the #while statement and the corresponding #end statement are repeated. &lt;br /&gt;
&lt;br /&gt;
The statements repeat in a loop until the condition evaluates to false. It is up to you to control the loop by defining a suitable condition that will not loop indefinitely. If the condition never evaluates to false then the program will continue to evaluate the statements forever, until you hit the stop button, until the memory of your computer is exhausted or until you terminate the application (whichever happens first) see [[Wikipedia:Infinite_loop]]. &lt;br /&gt;
&lt;br /&gt;
Note: extremely small values of about 1e-10 are considered zero (false) as a result of floating point number accuracy limits.&lt;br /&gt;
&lt;br /&gt;
Here is an example of a simple loop: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=pov&amp;gt;&lt;br /&gt;
#declare Count=0;&lt;br /&gt;
#while (Count &amp;lt; 5)&lt;br /&gt;
  object { MyObject translate x*3*Count }&lt;br /&gt;
  #declare Count=Count+1;&lt;br /&gt;
#end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
This example places five copies of MyObject in a row spaced three units apart in the x-direction. &lt;br /&gt;
&lt;br /&gt;
As described above (for the #if statement), you can combine conditional terms to build more complex conditional expressions using '&amp;amp;' (And), '|' (Or) and '!' (Not). &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Nested Loops===&lt;br /&gt;
Loops can be nested. This capability is often used to lay out very large numbers of objects using an economical amount of code.&lt;br /&gt;
&lt;br /&gt;
Here's a very simple but complete scene file containing a nested loop that you can play with:&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;source lang=pov&amp;gt;&lt;br /&gt;
#include &amp;quot;colors.inc&amp;quot;&lt;br /&gt;
#include &amp;quot;woods.inc&amp;quot;&lt;br /&gt;
&lt;br /&gt;
camera {location &amp;lt;-1.5,0.9,-0.08&amp;gt; look_at &amp;lt;0,0.7,0.5&amp;gt;}  &lt;br /&gt;
light_source {   &amp;lt;-20,75,-100&amp;gt; rgb White}&lt;br /&gt;
background {LightBlue}&lt;br /&gt;
plane {y,0 pigment {color GreenYellow}}&lt;br /&gt;
&lt;br /&gt;
#declare RandomSeed = seed(1);&lt;br /&gt;
#declare XCount=0;&lt;br /&gt;
#while (XCount &amp;lt; 200)&lt;br /&gt;
  #declare ZCount=0;&lt;br /&gt;
  #while (ZCount &amp;lt; 200)&lt;br /&gt;
    box {&amp;lt;-0.05,0,-0.05&amp;gt;&amp;lt;0.05,1,0.05&amp;gt;&lt;br /&gt;
      rotate &amp;lt;3*rand(RandomSeed),5*rand(RandomSeed),3*rand(RandomSeed)&amp;gt;&lt;br /&gt;
      texture {T_Wood1 translate &amp;lt;rand(RandomSeed),ZCount,rand(RandomSeed)&amp;gt; rotate x*90 scale 0.07}&lt;br /&gt;
      translate &amp;lt;XCount,0,ZCount&amp;gt; &lt;br /&gt;
    }&lt;br /&gt;
    #declare ZCount=ZCount+1;&lt;br /&gt;
  #end &lt;br /&gt;
  #declare XCount=XCount+1;&lt;br /&gt;
#end &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This example uses 2 nested loops. Each nested loop has its own control variable. It starts with both XCount and YCount equal to zero. With XCount at zero, YCount loops from 0 to 199, then XCount is incremented to 1, YCount is reset to zero and the second loop repeats. &lt;br /&gt;
&lt;br /&gt;
This example also introduces a degree of randomness in each iteration using the POV-Ray seed and rand functions. When generating a large number of objects using #while loops you'll find that a little randomness goes a long way. This example generates 40,000 wooden posts, each with a little bit of a wobble and each with a slightly different wood texture pattern. It should take about 10 or 20 seconds to render.&lt;/div&gt;</summary>
		<author><name>Chrisb</name></author>
	</entry>
	<entry>
		<id>https://wiki.povray.org/content?title=HowTo:Use_conditional_structures&amp;diff=516</id>
		<title>HowTo:Use conditional structures</title>
		<link rel="alternate" type="text/html" href="https://wiki.povray.org/content?title=HowTo:Use_conditional_structures&amp;diff=516"/>
		<updated>2008-06-10T17:44:17Z</updated>

		<summary type="html">&lt;p&gt;Chrisb: /* The #if, #else, #end construct */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Conditional constructs in POV-Ray are scripting features which perform different computations or actions depending on whether a condition evaluates to true or false. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==The #if, #else, #end construct==&lt;br /&gt;
The simplest conditional directive is the #if directive. This evaluates an expression, which must evaluate to a floating point number (often an integer value). This floating point number is interpreted as a boolean value, that is to say that if the expression evaluates to '0', it is considered 'false' and if it evaluates to anything else it is considered 'true'. If the condition is true then directives between the #if statement and a corresponding #else or #end statement are evaluated.&lt;br /&gt;
Note: extremely small values of about 1e-10 are considered zero (false) as a result of floating point number accuracy limits. &lt;br /&gt;
&lt;br /&gt;
The #else directive is optional but, if specified and the conditional expression was false, then directives between the #else and the corresponding #end statement are evaluated.&lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=pov&amp;gt;&lt;br /&gt;
#declare CameraDistance=25.8;&lt;br /&gt;
 &lt;br /&gt;
 ... Definition of some complex object that looks like a sphere at great distances. ...&lt;br /&gt;
 &lt;br /&gt;
#if (CameraDistance&amp;gt;100)&lt;br /&gt;
   sphere { &amp;lt;0,0,0&amp;gt;, 1.2 pigment {rgb 1}}&lt;br /&gt;
#else&lt;br /&gt;
   object {MyComplexObject}&lt;br /&gt;
#end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here the 'greater than' comparitive operator '&amp;gt;' is used to see whether the value of the CameraDistance variable is greater than 100. In this example, the expression 'CameraDistance&amp;gt;100' evaluates to 0 ('false') because the CameraDistance variable is less than 100.&lt;br /&gt;
&lt;br /&gt;
===Conditional Conjunctions ===&lt;br /&gt;
You can combine conditional terms to build more complex conditional expressions using '&amp;amp;' (And), '|' (Or) and '!' (Not). Use brackets to control the sequence of evaluation. You can also use POV-Ray functions within terms so long as they can be resolved to numeric values. The built-in float identifiers on, off, yes, no, true, and false are designed for use as boolean constants and simply evaluate to 0 (off, no and false) or 1 (on, yes and true).&lt;br /&gt;
&lt;br /&gt;
Here's an example that might take a little thinking about:&lt;br /&gt;
&amp;lt;source lang=pov&amp;gt;&lt;br /&gt;
#declare Clothing=&amp;quot;Jeans&amp;quot;;&lt;br /&gt;
#declare JeansPermitted=false;&lt;br /&gt;
// Check to see if Jeans are permitted&lt;br /&gt;
#if (strcmp(Clothing,&amp;quot;Jeans&amp;quot;)=0 &amp;amp; !JeansPermitted)&lt;br /&gt;
   #debug &amp;quot;Sorry. Jeans are not permitted\n&amp;quot;&lt;br /&gt;
#end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this example, the strcmp function returns a zero because there is no difference between the two strings it has compared.&lt;br /&gt;
The term 'strcmp(Clothing,&amp;quot;Jeans&amp;quot;)=0' therefore returns a 1 (this term is true). The '!' (Not) symbol is used to check for the condition where jeans are not permitted. The '&amp;amp;' symbol is used to combine the two and to therefore test for the condition where Clothing is &amp;quot;Jeans&amp;quot; and jeans are not permitted.&lt;br /&gt;
&lt;br /&gt;
As you've probably realised, there are many ways of expressing the same thing with conditional expressions and the art is in writing it in a way that is clear enough that you will understand it when you read it through again later. It can help to write the condition out as a comment before you build it into an expression. Leaving the comment in place helps anyone reading it later.&lt;br /&gt;
&lt;br /&gt;
==The #switch, #case, #range and #break Directives==&lt;br /&gt;
The #switch directive provides another way of specifying conditional expressions but allows you to handle a succession of conditions as defined by a #case clause or a #range clause. This directive can seem a little daunting compared to using one or more #if directives, but there are some powerful ways of using it. Like the #if directive it uses float values rather than boolean, so two values whose difference is less than 1e-10 are considered equal.&lt;br /&gt;
&lt;br /&gt;
This trivial example illustrates a number of basic points about the #switch directive. &lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;If a #case or #range clause is not a match it skips to the next one, ignoring everything else in between. &lt;br /&gt;
&amp;lt;li&amp;gt;If a #break is encountered within a matching #case or #range clause the #switch directive stops processing further lines, causing an immediate jump to the #end without processing subsequent sections, even if a subsequent condition would also have been satisfied. &lt;br /&gt;
&amp;lt;li&amp;gt;When processing a matching #case or #range clause, if a #break is not encountered it continues through successive #case statements whether they match or not.&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
#declare MyVariable = 5.2;&lt;br /&gt;
#debug concat(&amp;quot;MyVariable: &amp;quot;,str(MyVariable,3,3),&amp;quot;\n&amp;quot;)&lt;br /&gt;
#switch (MyVariable)&lt;br /&gt;
  #case (0)&lt;br /&gt;
    #debug &amp;quot;As close to nothing as makes a tiny difference.\n&amp;quot;&lt;br /&gt;
  #break &lt;br /&gt;
  #case (1)&lt;br /&gt;
  #case (2)&lt;br /&gt;
  #case (3)&lt;br /&gt;
  #case (5)&lt;br /&gt;
  #case (7)&lt;br /&gt;
    #debug &amp;quot;A Prime number between 1 and 10 (actually within 1e-10 of a prime).\n&amp;quot;&lt;br /&gt;
  #break &lt;br /&gt;
  #range (0,10)&lt;br /&gt;
    #debug &amp;quot;A number between 1 and 10 that is not within 1e-10 of a Prime number\n&amp;quot;&lt;br /&gt;
  #break&lt;br /&gt;
  #range (10,100)&lt;br /&gt;
    #debug &amp;quot;A number between 10 and 100 (actually 10+(1e-10) to 100+(1e-10)).\n&amp;quot;&lt;br /&gt;
  #break&lt;br /&gt;
  #else&lt;br /&gt;
    #debug &amp;quot;Everything else.\n&amp;quot;&lt;br /&gt;
    #debug &amp;quot;ie. Less than zero or greater than 100.\n&amp;quot;&lt;br /&gt;
#end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the parameter to a #case clause matches the parameter to the #switch clause then everything up to the next #break, #else or #end clause is evaluated. Similarly, if the parameter to the #switch clause is between the minimum and maximum values of a #range clause then everything up to the next #break, #else or #end clause is evaluated. To explore the sensitivity to the accuracy of the floating point number comparison you can set a value using 'e' as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
#declare MyVariable = 5+(0.5e-10);&lt;br /&gt;
  or&lt;br /&gt;
#declare MyVariable = 5+(1.5e-10);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Using #switch with text values===&lt;br /&gt;
The #switch, #case and #range clauses accept parameters that evaluate to float numbers. This includes the strcmp function which compares two strings and returns a zero if two strings match. By turning the #switch clause on its head a little, you can therefore use it with strings. Using the #switch directive with text can be particularly handy when writing macros that can generate an object in a large number of differently styles, because you can give each style a name and set parameters based on the name of the style specified. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Example of using #switch with text:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
#declare MyVariable = &amp;quot;Ostrich&amp;quot;;&lt;br /&gt;
#switch (0)&lt;br /&gt;
  #case (strcmp(strupr(MyVariable),&amp;quot;DOG&amp;quot;))&lt;br /&gt;
    #debug &amp;quot;Dog, DOG, or dog.\n&amp;quot;&lt;br /&gt;
    // Settings to be used for a dog&lt;br /&gt;
  #break &lt;br /&gt;
  #case (strcmp(strupr(MyVariable),&amp;quot;CAT&amp;quot;))&lt;br /&gt;
    #debug &amp;quot;Cat, CAT, or cat.\n&amp;quot;&lt;br /&gt;
    // Settings to be used for a cat&lt;br /&gt;
  #break &lt;br /&gt;
  #case (strcmp(strupr(MyVariable),&amp;quot;OSTRICH&amp;quot;))&lt;br /&gt;
    #debug &amp;quot;Ostrich, OSTRICH, or ostrich.\n&amp;quot;&lt;br /&gt;
    // Settings to be used for an ostrich&lt;br /&gt;
  #break &lt;br /&gt;
  #else&lt;br /&gt;
    #debug &amp;quot;Not a dog, cat or ostrich.\n&amp;quot;&lt;br /&gt;
    // Stuff to do if an unexpected creature was encountered.&lt;br /&gt;
#end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that the strupr function is used to remove case sensitivity. &lt;br /&gt;
&lt;br /&gt;
The following example illustrates the use of multiple #case clauses for a set of associated conditions to work out how many legs an animal has:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
#declare Animal   = &amp;quot;Ostrich&amp;quot;;&lt;br /&gt;
#switch (0)&lt;br /&gt;
  #case (strcmp(strupr(Animal),&amp;quot;DOG&amp;quot;))&lt;br /&gt;
  #case (strcmp(strupr(Animal),&amp;quot;CAT&amp;quot;))&lt;br /&gt;
  #case (strcmp(strupr(Animal),&amp;quot;RHINOCEROS&amp;quot;))&lt;br /&gt;
  #case (strcmp(strupr(Animal),&amp;quot;TABLE&amp;quot;))&lt;br /&gt;
    #declare LegCount = 4;&lt;br /&gt;
  #break &lt;br /&gt;
  #case (strcmp(strupr(Animal),&amp;quot;OSTRICH&amp;quot;))&lt;br /&gt;
  #case (strcmp(strupr(Animal),&amp;quot;DUCK&amp;quot;))&lt;br /&gt;
    #declare LegCount = 2;&lt;br /&gt;
  #break &lt;br /&gt;
  #case (strcmp(strupr(Animal),&amp;quot;WORM&amp;quot;))&lt;br /&gt;
  #case (strcmp(strupr(Animal),&amp;quot;DOLPHIN&amp;quot;))&lt;br /&gt;
    #declare LegCount = 0;&lt;br /&gt;
  #break &lt;br /&gt;
  #else&lt;br /&gt;
    #declare LegCount = -1; // Unknown&lt;br /&gt;
#end&lt;br /&gt;
&lt;br /&gt;
#debug concat(&amp;quot;Animal: &amp;quot;,Animal,&amp;quot;\n&amp;quot;) &lt;br /&gt;
#if (LegCount&amp;lt;0) #debug &amp;quot;Number of Legs Unknown\n&amp;quot;&lt;br /&gt;
#else #debug concat(&amp;quot;Number of Legs: &amp;quot;,str(LegCount,3,0),&amp;quot;\n&amp;quot;)&lt;br /&gt;
#end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can also test for abbreviations using the following construct:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
  #case (strcmp(strupr(Animal),substr(&amp;quot;RHINOCEROS&amp;quot;,1,strlen(Animal))))&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This would match 'Rhino' or 'Rhinoceros', but you clearly need to be a little careful with this as it would also match 'Rhinoc', 'R' and &amp;lt;nowiki&amp;gt;''&amp;lt;/nowiki&amp;gt;. To set a minimum abbreviation length use the max function:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
  #case (strcmp(strupr(Animal),substr(&amp;quot;RHINOCEROS&amp;quot;,1,max(strlen(Animal),5))))&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This would match 'Rhino', 'Rhinoceros' and everything in between, but not 'R', 'Rhin' or &amp;lt;nowiki&amp;gt;''&amp;lt;/nowiki&amp;gt;.&lt;/div&gt;</summary>
		<author><name>Chrisb</name></author>
	</entry>
	<entry>
		<id>https://wiki.povray.org/content?title=HowTo:Use_conditional_structures&amp;diff=515</id>
		<title>HowTo:Use conditional structures</title>
		<link rel="alternate" type="text/html" href="https://wiki.povray.org/content?title=HowTo:Use_conditional_structures&amp;diff=515"/>
		<updated>2008-06-10T17:41:05Z</updated>

		<summary type="html">&lt;p&gt;Chrisb: Replaced incorrect #if assertions&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Conditional constructs in POV-Ray are scripting features which perform different computations or actions depending on whether a condition evaluates to true or false. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==The #if, #else, #end construct==&lt;br /&gt;
The simplest conditional directive is the #if directive. This evaluates an expression, which must evaluate to a floating point number (often an integer value). This floating point number is interpreted as a boolean value, that is to say that if the expression evaluates to '0', it is considered 'false' and if it evaluates to anything else it is considered 'true'. If the condition is true then directives between the #if statement and a corresponding #else or #end statement are evaluated.&lt;br /&gt;
Note: extremely small values of about 1e-10 are considered zero (false) as a result of floating point number accuracy limits. &lt;br /&gt;
&lt;br /&gt;
The #else directive is optional but, if specified and the conditional expression was false, then directives between the #else and the corresponding #end statement are evaluated.&lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=pov&amp;gt;&lt;br /&gt;
 #declare CameraDistance=25.8;&lt;br /&gt;
 &lt;br /&gt;
 ... Definition of some complex object that looks like a sphere at great distances. ...&lt;br /&gt;
 &lt;br /&gt;
 #if (CameraDistance&amp;gt;100)&lt;br /&gt;
   sphere { &amp;lt;0,0,0&amp;gt;, 1.2 pigment {rgb 1}}&lt;br /&gt;
 #else&lt;br /&gt;
   object {MyComplexObject}&lt;br /&gt;
 #end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here the 'greater than' comparitive operator '&amp;gt;' is used to see whether the value of the CameraDistance variable is greater than 100. In this example, the expression 'CameraDistance&amp;gt;100' evaluates to 0 ('false') because the CameraDistance variable is less than 100.&lt;br /&gt;
&lt;br /&gt;
===Conditional Conjunctions ===&lt;br /&gt;
You can combine conditional terms to build more complex conditional expressions using '&amp;amp;' (And), '|' (Or) and '!' (Not). Use brackets to control the sequence of evaluation. You can also use POV-Ray functions within terms so long as they can be resolved to numeric values. The built-in float identifiers on, off, yes, no, true, and false are designed for use as boolean constants and simply evaluate to 0 (off, no and false) or 1 (on, yes and true).&lt;br /&gt;
&lt;br /&gt;
Here's an example that might take a little thinking about:&lt;br /&gt;
&amp;lt;source lang=pov&amp;gt;&lt;br /&gt;
 #declare Clothing=&amp;quot;Jeans&amp;quot;;&lt;br /&gt;
 #declare JeansPermitted=false;&lt;br /&gt;
 // Check to see if Jeans are permitted&lt;br /&gt;
 #if (strcmp(Clothing,&amp;quot;Jeans&amp;quot;)=0 &amp;amp; !JeansPermitted)&lt;br /&gt;
   #debug &amp;quot;Sorry. Jeans are not permitted\n&amp;quot;&lt;br /&gt;
 #end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this example, the strcmp function returns a zero because there is no difference between the two strings it has compared.&lt;br /&gt;
The term 'strcmp(Clothing,&amp;quot;Jeans&amp;quot;)=0' therefore returns a 1 (this term is true). The '!' (Not) symbol is used to check for the condition where jeans are not permitted. The '&amp;amp;' symbol is used to combine the two and to therefore test for the condition where Clothing is &amp;quot;Jeans&amp;quot; and jeans are not permitted.&lt;br /&gt;
&lt;br /&gt;
As you've probably realised, there are many ways of expressing the same thing with conditional expressions and the art is in writing it in a way that is clear enough that you will understand it when you read it through again later. It can help to write the condition out as a comment before you build it into an expression. Leaving the comment in place helps anyone reading it later.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==The #switch, #case, #range and #break Directives==&lt;br /&gt;
The #switch directive provides another way of specifying conditional expressions but allows you to handle a succession of conditions as defined by a #case clause or a #range clause. This directive can seem a little daunting compared to using one or more #if directives, but there are some powerful ways of using it. Like the #if directive it uses float values rather than boolean, so two values whose difference is less than 1e-10 are considered equal.&lt;br /&gt;
&lt;br /&gt;
This trivial example illustrates a number of basic points about the #switch directive. &lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;If a #case or #range clause is not a match it skips to the next one, ignoring everything else in between. &lt;br /&gt;
&amp;lt;li&amp;gt;If a #break is encountered within a matching #case or #range clause the #switch directive stops processing further lines, causing an immediate jump to the #end without processing subsequent sections, even if a subsequent condition would also have been satisfied. &lt;br /&gt;
&amp;lt;li&amp;gt;When processing a matching #case or #range clause, if a #break is not encountered it continues through successive #case statements whether they match or not.&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
#declare MyVariable = 5.2;&lt;br /&gt;
#debug concat(&amp;quot;MyVariable: &amp;quot;,str(MyVariable,3,3),&amp;quot;\n&amp;quot;)&lt;br /&gt;
#switch (MyVariable)&lt;br /&gt;
  #case (0)&lt;br /&gt;
    #debug &amp;quot;As close to nothing as makes a tiny difference.\n&amp;quot;&lt;br /&gt;
  #break &lt;br /&gt;
  #case (1)&lt;br /&gt;
  #case (2)&lt;br /&gt;
  #case (3)&lt;br /&gt;
  #case (5)&lt;br /&gt;
  #case (7)&lt;br /&gt;
    #debug &amp;quot;A Prime number between 1 and 10 (actually within 1e-10 of a prime).\n&amp;quot;&lt;br /&gt;
  #break &lt;br /&gt;
  #range (0,10)&lt;br /&gt;
    #debug &amp;quot;A number between 1 and 10 that is not within 1e-10 of a Prime number\n&amp;quot;&lt;br /&gt;
  #break&lt;br /&gt;
  #range (10,100)&lt;br /&gt;
    #debug &amp;quot;A number between 10 and 100 (actually 10+(1e-10) to 100+(1e-10)).\n&amp;quot;&lt;br /&gt;
  #break&lt;br /&gt;
  #else&lt;br /&gt;
    #debug &amp;quot;Everything else.\n&amp;quot;&lt;br /&gt;
    #debug &amp;quot;ie. Less than zero or greater than 100.\n&amp;quot;&lt;br /&gt;
#end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the parameter to a #case clause matches the parameter to the #switch clause then everything up to the next #break, #else or #end clause is evaluated. Similarly, if the parameter to the #switch clause is between the minimum and maximum values of a #range clause then everything up to the next #break, #else or #end clause is evaluated. To explore the sensitivity to the accuracy of the floating point number comparison you can set a value using 'e' as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
#declare MyVariable = 5+(0.5e-10);&lt;br /&gt;
  or&lt;br /&gt;
#declare MyVariable = 5+(1.5e-10);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Using #switch with text values===&lt;br /&gt;
The #switch, #case and #range clauses accept parameters that evaluate to float numbers. This includes the strcmp function which compares two strings and returns a zero if two strings match. By turning the #switch clause on its head a little, you can therefore use it with strings. Using the #switch directive with text can be particularly handy when writing macros that can generate an object in a large number of differently styles, because you can give each style a name and set parameters based on the name of the style specified. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Example of using #switch with text:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
#declare MyVariable = &amp;quot;Ostrich&amp;quot;;&lt;br /&gt;
#switch (0)&lt;br /&gt;
  #case (strcmp(strupr(MyVariable),&amp;quot;DOG&amp;quot;))&lt;br /&gt;
    #debug &amp;quot;Dog, DOG, or dog.\n&amp;quot;&lt;br /&gt;
    // Settings to be used for a dog&lt;br /&gt;
  #break &lt;br /&gt;
  #case (strcmp(strupr(MyVariable),&amp;quot;CAT&amp;quot;))&lt;br /&gt;
    #debug &amp;quot;Cat, CAT, or cat.\n&amp;quot;&lt;br /&gt;
    // Settings to be used for a cat&lt;br /&gt;
  #break &lt;br /&gt;
  #case (strcmp(strupr(MyVariable),&amp;quot;OSTRICH&amp;quot;))&lt;br /&gt;
    #debug &amp;quot;Ostrich, OSTRICH, or ostrich.\n&amp;quot;&lt;br /&gt;
    // Settings to be used for an ostrich&lt;br /&gt;
  #break &lt;br /&gt;
  #else&lt;br /&gt;
    #debug &amp;quot;Not a dog, cat or ostrich.\n&amp;quot;&lt;br /&gt;
    // Stuff to do if an unexpected creature was encountered.&lt;br /&gt;
#end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that the strupr function is used to remove case sensitivity. &lt;br /&gt;
&lt;br /&gt;
The following example illustrates the use of multiple #case clauses for a set of associated conditions to work out how many legs an animal has:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
#declare Animal   = &amp;quot;Ostrich&amp;quot;;&lt;br /&gt;
#switch (0)&lt;br /&gt;
  #case (strcmp(strupr(Animal),&amp;quot;DOG&amp;quot;))&lt;br /&gt;
  #case (strcmp(strupr(Animal),&amp;quot;CAT&amp;quot;))&lt;br /&gt;
  #case (strcmp(strupr(Animal),&amp;quot;RHINOCEROS&amp;quot;))&lt;br /&gt;
  #case (strcmp(strupr(Animal),&amp;quot;TABLE&amp;quot;))&lt;br /&gt;
    #declare LegCount = 4;&lt;br /&gt;
  #break &lt;br /&gt;
  #case (strcmp(strupr(Animal),&amp;quot;OSTRICH&amp;quot;))&lt;br /&gt;
  #case (strcmp(strupr(Animal),&amp;quot;DUCK&amp;quot;))&lt;br /&gt;
    #declare LegCount = 2;&lt;br /&gt;
  #break &lt;br /&gt;
  #case (strcmp(strupr(Animal),&amp;quot;WORM&amp;quot;))&lt;br /&gt;
  #case (strcmp(strupr(Animal),&amp;quot;DOLPHIN&amp;quot;))&lt;br /&gt;
    #declare LegCount = 0;&lt;br /&gt;
  #break &lt;br /&gt;
  #else&lt;br /&gt;
    #declare LegCount = -1; // Unknown&lt;br /&gt;
#end&lt;br /&gt;
&lt;br /&gt;
#debug concat(&amp;quot;Animal: &amp;quot;,Animal,&amp;quot;\n&amp;quot;) &lt;br /&gt;
#if (LegCount&amp;lt;0) #debug &amp;quot;Number of Legs Unknown\n&amp;quot;&lt;br /&gt;
#else #debug concat(&amp;quot;Number of Legs: &amp;quot;,str(LegCount,3,0),&amp;quot;\n&amp;quot;)&lt;br /&gt;
#end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can also test for abbreviations using the following construct:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
  #case (strcmp(strupr(Animal),substr(&amp;quot;RHINOCEROS&amp;quot;,1,strlen(Animal))))&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This would match 'Rhino' or 'Rhinoceros', but you clearly need to be a little careful with this as it would also match 'Rhinoc', 'R' and &amp;lt;nowiki&amp;gt;''&amp;lt;/nowiki&amp;gt;. To set a minimum abbreviation length use the max function:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
  #case (strcmp(strupr(Animal),substr(&amp;quot;RHINOCEROS&amp;quot;,1,max(strlen(Animal),5))))&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This would match 'Rhino', 'Rhinoceros' and everything in between, but not 'R', 'Rhin' or &amp;lt;nowiki&amp;gt;''&amp;lt;/nowiki&amp;gt;.&lt;/div&gt;</summary>
		<author><name>Chrisb</name></author>
	</entry>
	<entry>
		<id>https://wiki.povray.org/content?title=HowTo:Use_conditional_structures&amp;diff=514</id>
		<title>HowTo:Use conditional structures</title>
		<link rel="alternate" type="text/html" href="https://wiki.povray.org/content?title=HowTo:Use_conditional_structures&amp;diff=514"/>
		<updated>2008-06-10T15:32:26Z</updated>

		<summary type="html">&lt;p&gt;Chrisb: /* Using #switch with text values */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Conditional constructs in POV-Ray are scripting features which perform different computations or actions depending on whether a condition evaluates to true or false. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==#if==&lt;br /&gt;
&lt;br /&gt;
The '''#if''' statement can only evaluate floating point expressions. There is no boolean logic using '''and''', '''or''' or '''not'''. The equivalent must be achieved using arithmetic.&lt;br /&gt;
&lt;br /&gt;
Here's an example of '''and''' where a rotation (for a texture, say) depends on both the row and column. Enclosing both the conditions in brackets isolates them and each produces either 0 or 1. Summing them will give 0, 1 or 2. The rotation will occur when both are true, producing 2.&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
#local fRotateY = 0;&lt;br /&gt;
// If Row = 1 and Col = 4&lt;br /&gt;
#if ((uiRow = 1) + (uiCol = 4) = 2)&lt;br /&gt;
    // Rotates only row 1, column 4.&lt;br /&gt;
    #local fRotateY = 45;&lt;br /&gt;
#end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And here's an example of '''or''' where the rotation depends on the column having either of two values. Again, enclosing both the conditions in brackets isolates them and each produces either a 0 or a 1. Summing them will give 0, 1 or 2. The rotation will occur when either or both are true and they produce 1 or 2. Note that the '''&amp;gt; 0''' is optional and just a matter of style.&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
#local fRotateY = 0;&lt;br /&gt;
// If Row = 1 or Col = 6&lt;br /&gt;
#if ((uiRow = 1) + (uiCol = 6) &amp;gt; 0)&lt;br /&gt;
    // Rotates all of row 1 and all of column 6&lt;br /&gt;
    #local fRotateY = 45;&lt;br /&gt;
#end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And here's a truly ugly looking case which uses both. This is when you start wishing that they'd introduce a boolean type. ;-)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
#local fRotateY = 0;&lt;br /&gt;
// If (Row = 1 and Col = 4) or Col = 6&lt;br /&gt;
#if (((uiRow = 1) + (uiCol = 4) = 2) + (uiCol = 6) &amp;gt; 0)&lt;br /&gt;
    // Rotates row 1, column 4 and all of column 6&lt;br /&gt;
    #local fRotateY = 45;&lt;br /&gt;
#end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==The #switch, #case, #range and #break Directives==&lt;br /&gt;
The #switch directive provides another way of specifying conditional expressions but allows you to handle a succession of conditions as defined by a #case clause or a #range clause. This directive can seem a little daunting compared to using one or more #if directives, but there are some powerful ways of using it. Like the #if directive it uses float values rather than boolean, so two values whose difference is less than 1e-10 are considered equal.&lt;br /&gt;
&lt;br /&gt;
This trivial example illustrates a number of basic points about the #switch directive. &lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;If a #case or #range clause is not a match it skips to the next one, ignoring everything else in between. &lt;br /&gt;
&amp;lt;li&amp;gt;If a #break is encountered within a matching #case or #range clause the #switch directive stops processing further lines, causing an immediate jump to the #end without processing subsequent sections, even if a subsequent condition would also have been satisfied. &lt;br /&gt;
&amp;lt;li&amp;gt;When processing a matching #case or #range clause, if a #break is not encountered it continues through successive #case statements whether they match or not.&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
#declare MyVariable = 5.2;&lt;br /&gt;
#debug concat(&amp;quot;MyVariable: &amp;quot;,str(MyVariable,3,3),&amp;quot;\n&amp;quot;)&lt;br /&gt;
#switch (MyVariable)&lt;br /&gt;
  #case (0)&lt;br /&gt;
    #debug &amp;quot;As close to nothing as makes a tiny difference.\n&amp;quot;&lt;br /&gt;
  #break &lt;br /&gt;
  #case (1)&lt;br /&gt;
  #case (2)&lt;br /&gt;
  #case (3)&lt;br /&gt;
  #case (5)&lt;br /&gt;
  #case (7)&lt;br /&gt;
    #debug &amp;quot;A Prime number between 1 and 10 (actually within 1e-10 of a prime).\n&amp;quot;&lt;br /&gt;
  #break &lt;br /&gt;
  #range (0,10)&lt;br /&gt;
    #debug &amp;quot;A number between 1 and 10 that is not within 1e-10 of a Prime number\n&amp;quot;&lt;br /&gt;
  #break&lt;br /&gt;
  #range (10,100)&lt;br /&gt;
    #debug &amp;quot;A number between 10 and 100 (actually 10+(1e-10) to 100+(1e-10)).\n&amp;quot;&lt;br /&gt;
  #break&lt;br /&gt;
  #else&lt;br /&gt;
    #debug &amp;quot;Everything else.\n&amp;quot;&lt;br /&gt;
    #debug &amp;quot;ie. Less than zero or greater than 100.\n&amp;quot;&lt;br /&gt;
#end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the parameter to a #case clause matches the parameter to the #switch clause then everything up to the next #break, #else or #end clause is evaluated. Similarly, if the parameter to the #switch clause is between the minimum and maximum values of a #range clause then everything up to the next #break, #else or #end clause is evaluated. To explore the sensitivity to the accuracy of the floating point number comparison you can set a value using 'e' as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
#declare MyVariable = 5+(0.5e-10);&lt;br /&gt;
  or&lt;br /&gt;
#declare MyVariable = 5+(1.5e-10);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Using #switch with text values===&lt;br /&gt;
The #switch, #case and #range clauses accept parameters that evaluate to float numbers. This includes the strcmp function which compares two strings and returns a zero if two strings match. By turning the #switch clause on its head a little, you can therefore use it with strings. Using the #switch directive with text can be particularly handy when writing macros that can generate an object in a large number of differently styles, because you can give each style a name and set parameters based on the name of the style specified. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Example of using #switch with text:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
#declare MyVariable = &amp;quot;Ostrich&amp;quot;;&lt;br /&gt;
#switch (0)&lt;br /&gt;
  #case (strcmp(strupr(MyVariable),&amp;quot;DOG&amp;quot;))&lt;br /&gt;
    #debug &amp;quot;Dog, DOG, or dog.\n&amp;quot;&lt;br /&gt;
    // Settings to be used for a dog&lt;br /&gt;
  #break &lt;br /&gt;
  #case (strcmp(strupr(MyVariable),&amp;quot;CAT&amp;quot;))&lt;br /&gt;
    #debug &amp;quot;Cat, CAT, or cat.\n&amp;quot;&lt;br /&gt;
    // Settings to be used for a cat&lt;br /&gt;
  #break &lt;br /&gt;
  #case (strcmp(strupr(MyVariable),&amp;quot;OSTRICH&amp;quot;))&lt;br /&gt;
    #debug &amp;quot;Ostrich, OSTRICH, or ostrich.\n&amp;quot;&lt;br /&gt;
    // Settings to be used for an ostrich&lt;br /&gt;
  #break &lt;br /&gt;
  #else&lt;br /&gt;
    #debug &amp;quot;Not a dog, cat or ostrich.\n&amp;quot;&lt;br /&gt;
    // Stuff to do if an unexpected creature was encountered.&lt;br /&gt;
#end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that the strupr function is used to remove case sensitivity. &lt;br /&gt;
&lt;br /&gt;
The following example illustrates the use of multiple #case clauses for a set of associated conditions to work out how many legs an animal has:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
#declare Animal   = &amp;quot;Ostrich&amp;quot;;&lt;br /&gt;
#switch (0)&lt;br /&gt;
  #case (strcmp(strupr(Animal),&amp;quot;DOG&amp;quot;))&lt;br /&gt;
  #case (strcmp(strupr(Animal),&amp;quot;CAT&amp;quot;))&lt;br /&gt;
  #case (strcmp(strupr(Animal),&amp;quot;RHINOCEROS&amp;quot;))&lt;br /&gt;
  #case (strcmp(strupr(Animal),&amp;quot;TABLE&amp;quot;))&lt;br /&gt;
    #declare LegCount = 4;&lt;br /&gt;
  #break &lt;br /&gt;
  #case (strcmp(strupr(Animal),&amp;quot;OSTRICH&amp;quot;))&lt;br /&gt;
  #case (strcmp(strupr(Animal),&amp;quot;DUCK&amp;quot;))&lt;br /&gt;
    #declare LegCount = 2;&lt;br /&gt;
  #break &lt;br /&gt;
  #case (strcmp(strupr(Animal),&amp;quot;WORM&amp;quot;))&lt;br /&gt;
  #case (strcmp(strupr(Animal),&amp;quot;DOLPHIN&amp;quot;))&lt;br /&gt;
    #declare LegCount = 0;&lt;br /&gt;
  #break &lt;br /&gt;
  #else&lt;br /&gt;
    #declare LegCount = -1; // Unknown&lt;br /&gt;
#end&lt;br /&gt;
&lt;br /&gt;
#debug concat(&amp;quot;Animal: &amp;quot;,Animal,&amp;quot;\n&amp;quot;) &lt;br /&gt;
#if (LegCount&amp;lt;0) #debug &amp;quot;Number of Legs Unknown\n&amp;quot;&lt;br /&gt;
#else #debug concat(&amp;quot;Number of Legs: &amp;quot;,str(LegCount,3,0),&amp;quot;\n&amp;quot;)&lt;br /&gt;
#end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can also test for abbreviations using the following construct:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
  #case (strcmp(strupr(Animal),substr(&amp;quot;RHINOCEROS&amp;quot;,1,strlen(Animal))))&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This would match 'Rhino' or 'Rhinoceros', but you clearly need to be a little careful with this as it would also match 'Rhinoc', 'R' and &amp;lt;nowiki&amp;gt;''&amp;lt;/nowiki&amp;gt;. To set a minimum abbreviation length use the max function:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
  #case (strcmp(strupr(Animal),substr(&amp;quot;RHINOCEROS&amp;quot;,1,max(strlen(Animal),5))))&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This would match 'Rhino', 'Rhinoceros' and everything in between, but not 'R', 'Rhin' or &amp;lt;nowiki&amp;gt;''&amp;lt;/nowiki&amp;gt;.&lt;/div&gt;</summary>
		<author><name>Chrisb</name></author>
	</entry>
	<entry>
		<id>https://wiki.povray.org/content?title=HowTo:Use_conditional_structures&amp;diff=513</id>
		<title>HowTo:Use conditional structures</title>
		<link rel="alternate" type="text/html" href="https://wiki.povray.org/content?title=HowTo:Use_conditional_structures&amp;diff=513"/>
		<updated>2008-06-10T15:31:40Z</updated>

		<summary type="html">&lt;p&gt;Chrisb: /* Using #switch with text values */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Conditional constructs in POV-Ray are scripting features which perform different computations or actions depending on whether a condition evaluates to true or false. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==#if==&lt;br /&gt;
&lt;br /&gt;
The '''#if''' statement can only evaluate floating point expressions. There is no boolean logic using '''and''', '''or''' or '''not'''. The equivalent must be achieved using arithmetic.&lt;br /&gt;
&lt;br /&gt;
Here's an example of '''and''' where a rotation (for a texture, say) depends on both the row and column. Enclosing both the conditions in brackets isolates them and each produces either 0 or 1. Summing them will give 0, 1 or 2. The rotation will occur when both are true, producing 2.&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
#local fRotateY = 0;&lt;br /&gt;
// If Row = 1 and Col = 4&lt;br /&gt;
#if ((uiRow = 1) + (uiCol = 4) = 2)&lt;br /&gt;
    // Rotates only row 1, column 4.&lt;br /&gt;
    #local fRotateY = 45;&lt;br /&gt;
#end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And here's an example of '''or''' where the rotation depends on the column having either of two values. Again, enclosing both the conditions in brackets isolates them and each produces either a 0 or a 1. Summing them will give 0, 1 or 2. The rotation will occur when either or both are true and they produce 1 or 2. Note that the '''&amp;gt; 0''' is optional and just a matter of style.&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
#local fRotateY = 0;&lt;br /&gt;
// If Row = 1 or Col = 6&lt;br /&gt;
#if ((uiRow = 1) + (uiCol = 6) &amp;gt; 0)&lt;br /&gt;
    // Rotates all of row 1 and all of column 6&lt;br /&gt;
    #local fRotateY = 45;&lt;br /&gt;
#end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And here's a truly ugly looking case which uses both. This is when you start wishing that they'd introduce a boolean type. ;-)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
#local fRotateY = 0;&lt;br /&gt;
// If (Row = 1 and Col = 4) or Col = 6&lt;br /&gt;
#if (((uiRow = 1) + (uiCol = 4) = 2) + (uiCol = 6) &amp;gt; 0)&lt;br /&gt;
    // Rotates row 1, column 4 and all of column 6&lt;br /&gt;
    #local fRotateY = 45;&lt;br /&gt;
#end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==The #switch, #case, #range and #break Directives==&lt;br /&gt;
The #switch directive provides another way of specifying conditional expressions but allows you to handle a succession of conditions as defined by a #case clause or a #range clause. This directive can seem a little daunting compared to using one or more #if directives, but there are some powerful ways of using it. Like the #if directive it uses float values rather than boolean, so two values whose difference is less than 1e-10 are considered equal.&lt;br /&gt;
&lt;br /&gt;
This trivial example illustrates a number of basic points about the #switch directive. &lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;If a #case or #range clause is not a match it skips to the next one, ignoring everything else in between. &lt;br /&gt;
&amp;lt;li&amp;gt;If a #break is encountered within a matching #case or #range clause the #switch directive stops processing further lines, causing an immediate jump to the #end without processing subsequent sections, even if a subsequent condition would also have been satisfied. &lt;br /&gt;
&amp;lt;li&amp;gt;When processing a matching #case or #range clause, if a #break is not encountered it continues through successive #case statements whether they match or not.&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
#declare MyVariable = 5.2;&lt;br /&gt;
#debug concat(&amp;quot;MyVariable: &amp;quot;,str(MyVariable,3,3),&amp;quot;\n&amp;quot;)&lt;br /&gt;
#switch (MyVariable)&lt;br /&gt;
  #case (0)&lt;br /&gt;
    #debug &amp;quot;As close to nothing as makes a tiny difference.\n&amp;quot;&lt;br /&gt;
  #break &lt;br /&gt;
  #case (1)&lt;br /&gt;
  #case (2)&lt;br /&gt;
  #case (3)&lt;br /&gt;
  #case (5)&lt;br /&gt;
  #case (7)&lt;br /&gt;
    #debug &amp;quot;A Prime number between 1 and 10 (actually within 1e-10 of a prime).\n&amp;quot;&lt;br /&gt;
  #break &lt;br /&gt;
  #range (0,10)&lt;br /&gt;
    #debug &amp;quot;A number between 1 and 10 that is not within 1e-10 of a Prime number\n&amp;quot;&lt;br /&gt;
  #break&lt;br /&gt;
  #range (10,100)&lt;br /&gt;
    #debug &amp;quot;A number between 10 and 100 (actually 10+(1e-10) to 100+(1e-10)).\n&amp;quot;&lt;br /&gt;
  #break&lt;br /&gt;
  #else&lt;br /&gt;
    #debug &amp;quot;Everything else.\n&amp;quot;&lt;br /&gt;
    #debug &amp;quot;ie. Less than zero or greater than 100.\n&amp;quot;&lt;br /&gt;
#end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the parameter to a #case clause matches the parameter to the #switch clause then everything up to the next #break, #else or #end clause is evaluated. Similarly, if the parameter to the #switch clause is between the minimum and maximum values of a #range clause then everything up to the next #break, #else or #end clause is evaluated. To explore the sensitivity to the accuracy of the floating point number comparison you can set a value using 'e' as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
#declare MyVariable = 5+(0.5e-10);&lt;br /&gt;
  or&lt;br /&gt;
#declare MyVariable = 5+(1.5e-10);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Using #switch with text values===&lt;br /&gt;
The #switch, #case and #range clauses accept parameters that evaluate to float numbers. This includes the strcmp function which compares two strings and returns a zero if two strings match. By turning the #switch clause on its head a little, you can therefore use it with strings. Using the #switch directive with text can be particularly handy when writing macros that can generate an object in a large number of differently styles, because you can give each style a name and set parameters based on the name of the style specified. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Example of using #switch with text:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
#declare MyVariable = &amp;quot;Ostrich&amp;quot;;&lt;br /&gt;
#switch (0)&lt;br /&gt;
  #case (strcmp(strupr(MyVariable),&amp;quot;DOG&amp;quot;))&lt;br /&gt;
    #debug &amp;quot;Dog, DOG, or dog.\n&amp;quot;&lt;br /&gt;
    // Settings to be used for a dog&lt;br /&gt;
  #break &lt;br /&gt;
  #case (strcmp(strupr(MyVariable),&amp;quot;CAT&amp;quot;))&lt;br /&gt;
    #debug &amp;quot;Cat, CAT, or cat.\n&amp;quot;&lt;br /&gt;
    // Settings to be used for a cat&lt;br /&gt;
  #break &lt;br /&gt;
  #case (strcmp(strupr(MyVariable),&amp;quot;OSTRICH&amp;quot;))&lt;br /&gt;
    #debug &amp;quot;Ostrich, OSTRICH, or ostrich.\n&amp;quot;&lt;br /&gt;
    // Settings to be used for an ostrich&lt;br /&gt;
  #break &lt;br /&gt;
  #else&lt;br /&gt;
    #debug &amp;quot;Not a dog, cat or ostrich.\n&amp;quot;&lt;br /&gt;
    // Stuff to do if an unexpected creature was encountered.&lt;br /&gt;
#end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that the strupr function is used to remove case sensitivity. &lt;br /&gt;
&lt;br /&gt;
The following example illustrates the use of multiple #case clauses for a set of associated conditions to work out how many legs an animal has:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
#declare Animal   = &amp;quot;Ostrich&amp;quot;;&lt;br /&gt;
#switch (0)&lt;br /&gt;
  #case (strcmp(strupr(Animal),&amp;quot;DOG&amp;quot;))&lt;br /&gt;
  #case (strcmp(strupr(Animal),&amp;quot;CAT&amp;quot;))&lt;br /&gt;
  #case (strcmp(strupr(Animal),&amp;quot;RHINOCEROS&amp;quot;))&lt;br /&gt;
  #case (strcmp(strupr(Animal),&amp;quot;TABLE&amp;quot;))&lt;br /&gt;
    #declare LegCount = 4;&lt;br /&gt;
  #break &lt;br /&gt;
  #case (strcmp(strupr(Animal),&amp;quot;OSTRICH&amp;quot;))&lt;br /&gt;
  #case (strcmp(strupr(Animal),&amp;quot;DUCK&amp;quot;))&lt;br /&gt;
    #declare LegCount = 2;&lt;br /&gt;
  #break &lt;br /&gt;
  #case (strcmp(strupr(Animal),&amp;quot;WORM&amp;quot;))&lt;br /&gt;
  #case (strcmp(strupr(Animal),&amp;quot;DOLPHIN&amp;quot;))&lt;br /&gt;
    #declare LegCount = 0;&lt;br /&gt;
  #break &lt;br /&gt;
  #else&lt;br /&gt;
    #declare LegCount = -1; // Unknown&lt;br /&gt;
#end&lt;br /&gt;
&lt;br /&gt;
#debug concat(&amp;quot;Animal: &amp;quot;,Animal,&amp;quot;\n&amp;quot;) &lt;br /&gt;
#if (LegCount&amp;lt;0) #debug &amp;quot;Number of Legs Unknown\n&amp;quot;&lt;br /&gt;
#else #debug concat(&amp;quot;Number of Legs: &amp;quot;,str(LegCount,3,0),&amp;quot;\n&amp;quot;)&lt;br /&gt;
#end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can also test for abbreviations using the following construct:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
  #case (strcmp(strupr(Animal),substr(&amp;quot;RHINOCEROS&amp;quot;,1,strlen(Animal))))&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This would match 'Rhino' or 'Rhinoceros', but you clearly need to be a little careful with this as it would also match 'Rhinoc', 'R' and ''. To set a minimum abbreviation length use the max function:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
  #case (strcmp(strupr(Animal),substr(&amp;quot;RHINOCEROS&amp;quot;,1,max(strlen(Animal),5))))&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This would match 'Rhino', 'Rhinoceros' and everything in between, but not 'R', 'Rhin' or &amp;lt;nowiki&amp;gt;''&amp;lt;/nowiki&amp;gt;.&lt;/div&gt;</summary>
		<author><name>Chrisb</name></author>
	</entry>
	<entry>
		<id>https://wiki.povray.org/content?title=HowTo:Use_conditional_structures&amp;diff=512</id>
		<title>HowTo:Use conditional structures</title>
		<link rel="alternate" type="text/html" href="https://wiki.povray.org/content?title=HowTo:Use_conditional_structures&amp;diff=512"/>
		<updated>2008-06-10T15:26:47Z</updated>

		<summary type="html">&lt;p&gt;Chrisb: /* Using #switch with text values */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Conditional constructs in POV-Ray are scripting features which perform different computations or actions depending on whether a condition evaluates to true or false. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==#if==&lt;br /&gt;
&lt;br /&gt;
The '''#if''' statement can only evaluate floating point expressions. There is no boolean logic using '''and''', '''or''' or '''not'''. The equivalent must be achieved using arithmetic.&lt;br /&gt;
&lt;br /&gt;
Here's an example of '''and''' where a rotation (for a texture, say) depends on both the row and column. Enclosing both the conditions in brackets isolates them and each produces either 0 or 1. Summing them will give 0, 1 or 2. The rotation will occur when both are true, producing 2.&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
#local fRotateY = 0;&lt;br /&gt;
// If Row = 1 and Col = 4&lt;br /&gt;
#if ((uiRow = 1) + (uiCol = 4) = 2)&lt;br /&gt;
    // Rotates only row 1, column 4.&lt;br /&gt;
    #local fRotateY = 45;&lt;br /&gt;
#end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And here's an example of '''or''' where the rotation depends on the column having either of two values. Again, enclosing both the conditions in brackets isolates them and each produces either a 0 or a 1. Summing them will give 0, 1 or 2. The rotation will occur when either or both are true and they produce 1 or 2. Note that the '''&amp;gt; 0''' is optional and just a matter of style.&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
#local fRotateY = 0;&lt;br /&gt;
// If Row = 1 or Col = 6&lt;br /&gt;
#if ((uiRow = 1) + (uiCol = 6) &amp;gt; 0)&lt;br /&gt;
    // Rotates all of row 1 and all of column 6&lt;br /&gt;
    #local fRotateY = 45;&lt;br /&gt;
#end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And here's a truly ugly looking case which uses both. This is when you start wishing that they'd introduce a boolean type. ;-)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
#local fRotateY = 0;&lt;br /&gt;
// If (Row = 1 and Col = 4) or Col = 6&lt;br /&gt;
#if (((uiRow = 1) + (uiCol = 4) = 2) + (uiCol = 6) &amp;gt; 0)&lt;br /&gt;
    // Rotates row 1, column 4 and all of column 6&lt;br /&gt;
    #local fRotateY = 45;&lt;br /&gt;
#end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==The #switch, #case, #range and #break Directives==&lt;br /&gt;
The #switch directive provides another way of specifying conditional expressions but allows you to handle a succession of conditions as defined by a #case clause or a #range clause. This directive can seem a little daunting compared to using one or more #if directives, but there are some powerful ways of using it. Like the #if directive it uses float values rather than boolean, so two values whose difference is less than 1e-10 are considered equal.&lt;br /&gt;
&lt;br /&gt;
This trivial example illustrates a number of basic points about the #switch directive. &lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;If a #case or #range clause is not a match it skips to the next one, ignoring everything else in between. &lt;br /&gt;
&amp;lt;li&amp;gt;If a #break is encountered within a matching #case or #range clause the #switch directive stops processing further lines, causing an immediate jump to the #end without processing subsequent sections, even if a subsequent condition would also have been satisfied. &lt;br /&gt;
&amp;lt;li&amp;gt;When processing a matching #case or #range clause, if a #break is not encountered it continues through successive #case statements whether they match or not.&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
#declare MyVariable = 5.2;&lt;br /&gt;
#debug concat(&amp;quot;MyVariable: &amp;quot;,str(MyVariable,3,3),&amp;quot;\n&amp;quot;)&lt;br /&gt;
#switch (MyVariable)&lt;br /&gt;
  #case (0)&lt;br /&gt;
    #debug &amp;quot;As close to nothing as makes a tiny difference.\n&amp;quot;&lt;br /&gt;
  #break &lt;br /&gt;
  #case (1)&lt;br /&gt;
  #case (2)&lt;br /&gt;
  #case (3)&lt;br /&gt;
  #case (5)&lt;br /&gt;
  #case (7)&lt;br /&gt;
    #debug &amp;quot;A Prime number between 1 and 10 (actually within 1e-10 of a prime).\n&amp;quot;&lt;br /&gt;
  #break &lt;br /&gt;
  #range (0,10)&lt;br /&gt;
    #debug &amp;quot;A number between 1 and 10 that is not within 1e-10 of a Prime number\n&amp;quot;&lt;br /&gt;
  #break&lt;br /&gt;
  #range (10,100)&lt;br /&gt;
    #debug &amp;quot;A number between 10 and 100 (actually 10+(1e-10) to 100+(1e-10)).\n&amp;quot;&lt;br /&gt;
  #break&lt;br /&gt;
  #else&lt;br /&gt;
    #debug &amp;quot;Everything else.\n&amp;quot;&lt;br /&gt;
    #debug &amp;quot;ie. Less than zero or greater than 100.\n&amp;quot;&lt;br /&gt;
#end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the parameter to a #case clause matches the parameter to the #switch clause then everything up to the next #break, #else or #end clause is evaluated. Similarly, if the parameter to the #switch clause is between the minimum and maximum values of a #range clause then everything up to the next #break, #else or #end clause is evaluated. To explore the sensitivity to the accuracy of the floating point number comparison you can set a value using 'e' as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
#declare MyVariable = 5+(0.5e-10);&lt;br /&gt;
  or&lt;br /&gt;
#declare MyVariable = 5+(1.5e-10);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Using #switch with text values===&lt;br /&gt;
The #switch, #case and #range clauses accept parameters that evaluate to float numbers. This includes the strcmp function which compares two strings and returns a zero if two strings match. By turning the #switch clause on its head a little, you can therefore use it with strings. Using the #switch directive with text can be particularly handy when writing macros that can generate an object in a large number of differently styles, because you can give each style a name and set parameters based on the name of the style specified. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Example of using #switch with text:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
#declare MyVariable = &amp;quot;Ostrich&amp;quot;;&lt;br /&gt;
#switch (0)&lt;br /&gt;
  #case (strcmp(strupr(MyVariable),&amp;quot;DOG&amp;quot;))&lt;br /&gt;
    #debug &amp;quot;Dog, DOG, or dog.\n&amp;quot;&lt;br /&gt;
    // Settings to be used for a dog&lt;br /&gt;
  #break &lt;br /&gt;
  #case (strcmp(strupr(MyVariable),&amp;quot;CAT&amp;quot;))&lt;br /&gt;
    #debug &amp;quot;Cat, CAT, or cat.\n&amp;quot;&lt;br /&gt;
    // Settings to be used for a cat&lt;br /&gt;
  #break &lt;br /&gt;
  #case (strcmp(strupr(MyVariable),&amp;quot;OSTRICH&amp;quot;))&lt;br /&gt;
    #debug &amp;quot;Ostrich, OSTRICH, or ostrich.\n&amp;quot;&lt;br /&gt;
    // Settings to be used for an ostrich&lt;br /&gt;
  #break &lt;br /&gt;
  #else&lt;br /&gt;
    #debug &amp;quot;Not a dog, cat or ostrich.\n&amp;quot;&lt;br /&gt;
    // Stuff to do if an unexpected creature was encountered.&lt;br /&gt;
#end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that the strupr function is used to remove case sensitivity. &lt;br /&gt;
&lt;br /&gt;
The following example illustrates the use of multiple #case clauses for a set of associated conditions to work out how many legs an animal has:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
#declare Animal   = &amp;quot;Ostrich&amp;quot;;&lt;br /&gt;
#switch (0)&lt;br /&gt;
  #case (strcmp(strupr(Animal),&amp;quot;DOG&amp;quot;))&lt;br /&gt;
  #case (strcmp(strupr(Animal),&amp;quot;CAT&amp;quot;))&lt;br /&gt;
  #case (strcmp(strupr(Animal),&amp;quot;RHINOCEROS&amp;quot;))&lt;br /&gt;
  #case (strcmp(strupr(Animal),&amp;quot;TABLE&amp;quot;))&lt;br /&gt;
    #declare LegCount = 4;&lt;br /&gt;
  #break &lt;br /&gt;
  #case (strcmp(strupr(Animal),&amp;quot;OSTRICH&amp;quot;))&lt;br /&gt;
  #case (strcmp(strupr(Animal),&amp;quot;DUCK&amp;quot;))&lt;br /&gt;
    #declare LegCount = 2;&lt;br /&gt;
  #break &lt;br /&gt;
  #case (strcmp(strupr(Animal),&amp;quot;WORM&amp;quot;))&lt;br /&gt;
  #case (strcmp(strupr(Animal),&amp;quot;DOLPHIN&amp;quot;))&lt;br /&gt;
    #declare LegCount = 0;&lt;br /&gt;
  #break &lt;br /&gt;
  #else&lt;br /&gt;
    #declare LegCount = -1; // Unknown&lt;br /&gt;
#end&lt;br /&gt;
&lt;br /&gt;
#debug concat(&amp;quot;Animal: &amp;quot;,Animal,&amp;quot;\n&amp;quot;) &lt;br /&gt;
#if (LegCount&amp;lt;0) #debug &amp;quot;Number of Legs Unknown\n&amp;quot;&lt;br /&gt;
#else #debug concat(&amp;quot;Number of Legs: &amp;quot;,str(LegCount,3,0),&amp;quot;\n&amp;quot;)&lt;br /&gt;
#end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can also test for abbreviations using the following construct:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
  #case (strcmp(strupr(Animal),substr(&amp;quot;RHINOCEROS&amp;quot;,1,strlen(Animal))))&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This would match 'Rhino' or 'Rhinoceros', but you clearly need to be a little careful with this as it would also match 'Rhinoc', 'R' and ''. To set a minimum abbreviation length use the max function:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
  #case (strcmp(strupr(Animal),substr(&amp;quot;RHINOCEROS&amp;quot;,1,max(strlen(Animal),5))))&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This would match 'Rhino', 'Rhinoceros' and everything in between, but not 'R', 'Rhin' or ''.&lt;/div&gt;</summary>
		<author><name>Chrisb</name></author>
	</entry>
	<entry>
		<id>https://wiki.povray.org/content?title=HowTo:Use_conditional_structures&amp;diff=511</id>
		<title>HowTo:Use conditional structures</title>
		<link rel="alternate" type="text/html" href="https://wiki.povray.org/content?title=HowTo:Use_conditional_structures&amp;diff=511"/>
		<updated>2008-06-10T15:25:17Z</updated>

		<summary type="html">&lt;p&gt;Chrisb: /* Using #switch with text values */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Conditional constructs in POV-Ray are scripting features which perform different computations or actions depending on whether a condition evaluates to true or false. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==#if==&lt;br /&gt;
&lt;br /&gt;
The '''#if''' statement can only evaluate floating point expressions. There is no boolean logic using '''and''', '''or''' or '''not'''. The equivalent must be achieved using arithmetic.&lt;br /&gt;
&lt;br /&gt;
Here's an example of '''and''' where a rotation (for a texture, say) depends on both the row and column. Enclosing both the conditions in brackets isolates them and each produces either 0 or 1. Summing them will give 0, 1 or 2. The rotation will occur when both are true, producing 2.&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
#local fRotateY = 0;&lt;br /&gt;
// If Row = 1 and Col = 4&lt;br /&gt;
#if ((uiRow = 1) + (uiCol = 4) = 2)&lt;br /&gt;
    // Rotates only row 1, column 4.&lt;br /&gt;
    #local fRotateY = 45;&lt;br /&gt;
#end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And here's an example of '''or''' where the rotation depends on the column having either of two values. Again, enclosing both the conditions in brackets isolates them and each produces either a 0 or a 1. Summing them will give 0, 1 or 2. The rotation will occur when either or both are true and they produce 1 or 2. Note that the '''&amp;gt; 0''' is optional and just a matter of style.&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
#local fRotateY = 0;&lt;br /&gt;
// If Row = 1 or Col = 6&lt;br /&gt;
#if ((uiRow = 1) + (uiCol = 6) &amp;gt; 0)&lt;br /&gt;
    // Rotates all of row 1 and all of column 6&lt;br /&gt;
    #local fRotateY = 45;&lt;br /&gt;
#end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And here's a truly ugly looking case which uses both. This is when you start wishing that they'd introduce a boolean type. ;-)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
#local fRotateY = 0;&lt;br /&gt;
// If (Row = 1 and Col = 4) or Col = 6&lt;br /&gt;
#if (((uiRow = 1) + (uiCol = 4) = 2) + (uiCol = 6) &amp;gt; 0)&lt;br /&gt;
    // Rotates row 1, column 4 and all of column 6&lt;br /&gt;
    #local fRotateY = 45;&lt;br /&gt;
#end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==The #switch, #case, #range and #break Directives==&lt;br /&gt;
The #switch directive provides another way of specifying conditional expressions but allows you to handle a succession of conditions as defined by a #case clause or a #range clause. This directive can seem a little daunting compared to using one or more #if directives, but there are some powerful ways of using it. Like the #if directive it uses float values rather than boolean, so two values whose difference is less than 1e-10 are considered equal.&lt;br /&gt;
&lt;br /&gt;
This trivial example illustrates a number of basic points about the #switch directive. &lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;If a #case or #range clause is not a match it skips to the next one, ignoring everything else in between. &lt;br /&gt;
&amp;lt;li&amp;gt;If a #break is encountered within a matching #case or #range clause the #switch directive stops processing further lines, causing an immediate jump to the #end without processing subsequent sections, even if a subsequent condition would also have been satisfied. &lt;br /&gt;
&amp;lt;li&amp;gt;When processing a matching #case or #range clause, if a #break is not encountered it continues through successive #case statements whether they match or not.&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
#declare MyVariable = 5.2;&lt;br /&gt;
#debug concat(&amp;quot;MyVariable: &amp;quot;,str(MyVariable,3,3),&amp;quot;\n&amp;quot;)&lt;br /&gt;
#switch (MyVariable)&lt;br /&gt;
  #case (0)&lt;br /&gt;
    #debug &amp;quot;As close to nothing as makes a tiny difference.\n&amp;quot;&lt;br /&gt;
  #break &lt;br /&gt;
  #case (1)&lt;br /&gt;
  #case (2)&lt;br /&gt;
  #case (3)&lt;br /&gt;
  #case (5)&lt;br /&gt;
  #case (7)&lt;br /&gt;
    #debug &amp;quot;A Prime number between 1 and 10 (actually within 1e-10 of a prime).\n&amp;quot;&lt;br /&gt;
  #break &lt;br /&gt;
  #range (0,10)&lt;br /&gt;
    #debug &amp;quot;A number between 1 and 10 that is not within 1e-10 of a Prime number\n&amp;quot;&lt;br /&gt;
  #break&lt;br /&gt;
  #range (10,100)&lt;br /&gt;
    #debug &amp;quot;A number between 10 and 100 (actually 10+(1e-10) to 100+(1e-10)).\n&amp;quot;&lt;br /&gt;
  #break&lt;br /&gt;
  #else&lt;br /&gt;
    #debug &amp;quot;Everything else.\n&amp;quot;&lt;br /&gt;
    #debug &amp;quot;ie. Less than zero or greater than 100.\n&amp;quot;&lt;br /&gt;
#end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the parameter to a #case clause matches the parameter to the #switch clause then everything up to the next #break, #else or #end clause is evaluated. Similarly, if the parameter to the #switch clause is between the minimum and maximum values of a #range clause then everything up to the next #break, #else or #end clause is evaluated. To explore the sensitivity to the accuracy of the floating point number comparison you can set a value using 'e' as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
#declare MyVariable = 5+(0.5e-10);&lt;br /&gt;
  or&lt;br /&gt;
#declare MyVariable = 5+(1.5e-10);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Using #switch with text values===&lt;br /&gt;
The #switch, #case and #range clauses accept parameters that evaluate to float numbers. This includes the strcmp function which compares two strings and returns a zero if two strings match. By turning the #switch clause on its head a little, you can therefore use it with strings. Using the #switch directive with text can be particularly handy when writing macros that can generate an object in a large number of differently styles, because you can give each style a name and set parameters based on the name of the style specified. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Example of using #switch with text:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
#declare MyVariable = &amp;quot;Ostrich&amp;quot;;&lt;br /&gt;
#switch (0)&lt;br /&gt;
  #case (strcmp(strupr(MyVariable),&amp;quot;DOG&amp;quot;))&lt;br /&gt;
    #debug &amp;quot;Dog, DOG, or dog.\n&amp;quot;&lt;br /&gt;
    // Settings to be used for a dog&lt;br /&gt;
  #break &lt;br /&gt;
  #case (strcmp(strupr(MyVariable),&amp;quot;CAT&amp;quot;))&lt;br /&gt;
    #debug &amp;quot;Cat, CAT, or cat.\n&amp;quot;&lt;br /&gt;
    // Settings to be used for a cat&lt;br /&gt;
  #break &lt;br /&gt;
  #case (strcmp(strupr(MyVariable),&amp;quot;OSTRICH&amp;quot;))&lt;br /&gt;
    #debug &amp;quot;Ostrich, OSTRICH, or ostrich.\n&amp;quot;&lt;br /&gt;
    // Settings to be used for an ostrich&lt;br /&gt;
  #break &lt;br /&gt;
  #else&lt;br /&gt;
    #debug &amp;quot;Not a dog, cat or ostrich.\n&amp;quot;&lt;br /&gt;
    // Stuff to do if an unexpected creature was encountered.&lt;br /&gt;
#end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that the strupr function is used to remove case sensitivity. &lt;br /&gt;
&lt;br /&gt;
The following example illustrates the use of multiple #case clauses for a set of associated conditions to work out how many legs an animal has:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
#declare Animal   = &amp;quot;Ostrich&amp;quot;;&lt;br /&gt;
#switch (0)&lt;br /&gt;
  #case (strcmp(strupr(Animal),&amp;quot;DOG&amp;quot;))&lt;br /&gt;
  #case (strcmp(strupr(Animal),&amp;quot;CAT&amp;quot;))&lt;br /&gt;
  #case (strcmp(strupr(Animal),&amp;quot;RHINOCEROS&amp;quot;))&lt;br /&gt;
  #case (strcmp(strupr(Animal),&amp;quot;TABLE&amp;quot;))&lt;br /&gt;
    #declare LegCount = 4;&lt;br /&gt;
  #break &lt;br /&gt;
  #case (strcmp(strupr(Animal),&amp;quot;OSTRICH&amp;quot;))&lt;br /&gt;
  #case (strcmp(strupr(Animal),&amp;quot;DUCK&amp;quot;))&lt;br /&gt;
    #declare LegCount = 2;&lt;br /&gt;
  #break &lt;br /&gt;
  #case (strcmp(strupr(Animal),&amp;quot;WORM&amp;quot;))&lt;br /&gt;
  #case (strcmp(strupr(Animal),&amp;quot;DOLPHIN&amp;quot;))&lt;br /&gt;
    #declare LegCount = 0;&lt;br /&gt;
  #break &lt;br /&gt;
  #else&lt;br /&gt;
    #declare LegCount = -1; // Unknown&lt;br /&gt;
#end&lt;br /&gt;
&lt;br /&gt;
#debug concat(&amp;quot;Animal: &amp;quot;,Animal,&amp;quot;\n&amp;quot;) &lt;br /&gt;
#if (LegCount&amp;lt;0) #debug &amp;quot;Number of Legs Unknown\n&amp;quot;&lt;br /&gt;
#else #debug concat(&amp;quot;Number of Legs: &amp;quot;,str(LegCount,3,0),&amp;quot;\n&amp;quot;)&lt;br /&gt;
#end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can also test for abbreviations using the following construct:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
  #case (strcmp(strupr(Animal),substr(&amp;quot;RHINOCEROS&amp;quot;,1,strlen(Animal))))&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This would match 'Rhino', 'Rhinoceros', but you clearly need to be a little careful with this as it would also match 'Rhinoc', 'R' and ''. To set a minimum abbreviation length use the max function:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
  #case (strcmp(strupr(Animal),substr(&amp;quot;RHINOCEROS&amp;quot;,1,max(strlen(Animal),5))))&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This would match 'Rhino', 'Rhinoceros' and everything in between, but not 'R', 'Rhin' or ''.&lt;/div&gt;</summary>
		<author><name>Chrisb</name></author>
	</entry>
	<entry>
		<id>https://wiki.povray.org/content?title=HowTo:Use_conditional_structures&amp;diff=510</id>
		<title>HowTo:Use conditional structures</title>
		<link rel="alternate" type="text/html" href="https://wiki.povray.org/content?title=HowTo:Use_conditional_structures&amp;diff=510"/>
		<updated>2008-06-10T15:16:35Z</updated>

		<summary type="html">&lt;p&gt;Chrisb: Added #switch section&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Conditional constructs in POV-Ray are scripting features which perform different computations or actions depending on whether a condition evaluates to true or false. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==#if==&lt;br /&gt;
&lt;br /&gt;
The '''#if''' statement can only evaluate floating point expressions. There is no boolean logic using '''and''', '''or''' or '''not'''. The equivalent must be achieved using arithmetic.&lt;br /&gt;
&lt;br /&gt;
Here's an example of '''and''' where a rotation (for a texture, say) depends on both the row and column. Enclosing both the conditions in brackets isolates them and each produces either 0 or 1. Summing them will give 0, 1 or 2. The rotation will occur when both are true, producing 2.&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
#local fRotateY = 0;&lt;br /&gt;
// If Row = 1 and Col = 4&lt;br /&gt;
#if ((uiRow = 1) + (uiCol = 4) = 2)&lt;br /&gt;
    // Rotates only row 1, column 4.&lt;br /&gt;
    #local fRotateY = 45;&lt;br /&gt;
#end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And here's an example of '''or''' where the rotation depends on the column having either of two values. Again, enclosing both the conditions in brackets isolates them and each produces either a 0 or a 1. Summing them will give 0, 1 or 2. The rotation will occur when either or both are true and they produce 1 or 2. Note that the '''&amp;gt; 0''' is optional and just a matter of style.&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
#local fRotateY = 0;&lt;br /&gt;
// If Row = 1 or Col = 6&lt;br /&gt;
#if ((uiRow = 1) + (uiCol = 6) &amp;gt; 0)&lt;br /&gt;
    // Rotates all of row 1 and all of column 6&lt;br /&gt;
    #local fRotateY = 45;&lt;br /&gt;
#end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And here's a truly ugly looking case which uses both. This is when you start wishing that they'd introduce a boolean type. ;-)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
#local fRotateY = 0;&lt;br /&gt;
// If (Row = 1 and Col = 4) or Col = 6&lt;br /&gt;
#if (((uiRow = 1) + (uiCol = 4) = 2) + (uiCol = 6) &amp;gt; 0)&lt;br /&gt;
    // Rotates row 1, column 4 and all of column 6&lt;br /&gt;
    #local fRotateY = 45;&lt;br /&gt;
#end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==The #switch, #case, #range and #break Directives==&lt;br /&gt;
The #switch directive provides another way of specifying conditional expressions but allows you to handle a succession of conditions as defined by a #case clause or a #range clause. This directive can seem a little daunting compared to using one or more #if directives, but there are some powerful ways of using it. Like the #if directive it uses float values rather than boolean, so two values whose difference is less than 1e-10 are considered equal.&lt;br /&gt;
&lt;br /&gt;
This trivial example illustrates a number of basic points about the #switch directive. &lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;If a #case or #range clause is not a match it skips to the next one, ignoring everything else in between. &lt;br /&gt;
&amp;lt;li&amp;gt;If a #break is encountered within a matching #case or #range clause the #switch directive stops processing further lines, causing an immediate jump to the #end without processing subsequent sections, even if a subsequent condition would also have been satisfied. &lt;br /&gt;
&amp;lt;li&amp;gt;When processing a matching #case or #range clause, if a #break is not encountered it continues through successive #case statements whether they match or not.&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
#declare MyVariable = 5.2;&lt;br /&gt;
#debug concat(&amp;quot;MyVariable: &amp;quot;,str(MyVariable,3,3),&amp;quot;\n&amp;quot;)&lt;br /&gt;
#switch (MyVariable)&lt;br /&gt;
  #case (0)&lt;br /&gt;
    #debug &amp;quot;As close to nothing as makes a tiny difference.\n&amp;quot;&lt;br /&gt;
  #break &lt;br /&gt;
  #case (1)&lt;br /&gt;
  #case (2)&lt;br /&gt;
  #case (3)&lt;br /&gt;
  #case (5)&lt;br /&gt;
  #case (7)&lt;br /&gt;
    #debug &amp;quot;A Prime number between 1 and 10 (actually within 1e-10 of a prime).\n&amp;quot;&lt;br /&gt;
  #break &lt;br /&gt;
  #range (0,10)&lt;br /&gt;
    #debug &amp;quot;A number between 1 and 10 that is not within 1e-10 of a Prime number\n&amp;quot;&lt;br /&gt;
  #break&lt;br /&gt;
  #range (10,100)&lt;br /&gt;
    #debug &amp;quot;A number between 10 and 100 (actually 10+(1e-10) to 100+(1e-10)).\n&amp;quot;&lt;br /&gt;
  #break&lt;br /&gt;
  #else&lt;br /&gt;
    #debug &amp;quot;Everything else.\n&amp;quot;&lt;br /&gt;
    #debug &amp;quot;ie. Less than zero or greater than 100.\n&amp;quot;&lt;br /&gt;
#end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the parameter to a #case clause matches the parameter to the #switch clause then everything up to the next #break, #else or #end clause is evaluated. Similarly, if the parameter to the #switch clause is between the minimum and maximum values of a #range clause then everything up to the next #break, #else or #end clause is evaluated. To explore the sensitivity to the accuracy of the floating point number comparison you can set a value using 'e' as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
#declare MyVariable = 5+(0.5e-10);&lt;br /&gt;
  or&lt;br /&gt;
#declare MyVariable = 5+(1.5e-10);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Using #switch with text values===&lt;br /&gt;
The #switch, #case and #range clauses accept parameters that evaluate to float numbers. This includes the strcmp function which compares two strings and returns a zero if two strings match. By turning the #switch clause on its head a little, you can therefore use it with strings. Using the #switch directive with text can be particularly handy when writing macros that can generate an object in a large number of differently styles, because you can give each style a name and set parameters based on the name of the style specified. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Example of using #switch with text:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
#declare MyVariable = &amp;quot;Ostrich&amp;quot;;&lt;br /&gt;
#switch (0)&lt;br /&gt;
  #case (strcmp(strupr(MyVariable),&amp;quot;DOG&amp;quot;))&lt;br /&gt;
    #debug &amp;quot;Dog, DOG, or dog.\n&amp;quot;&lt;br /&gt;
    // Settings to be used for a dog&lt;br /&gt;
  #break &lt;br /&gt;
  #case (strcmp(strupr(MyVariable),&amp;quot;CAT&amp;quot;))&lt;br /&gt;
    #debug &amp;quot;Cat, CAT, or cat.\n&amp;quot;&lt;br /&gt;
    // Settings to be used for a cat&lt;br /&gt;
  #break &lt;br /&gt;
  #case (strcmp(strupr(MyVariable),&amp;quot;OSTRICH&amp;quot;))&lt;br /&gt;
    #debug &amp;quot;Ostrich, OSTRICH, or ostrich.\n&amp;quot;&lt;br /&gt;
    // Settings to be used for an ostrich&lt;br /&gt;
  #break &lt;br /&gt;
  #else&lt;br /&gt;
    #debug &amp;quot;Not a dog, cat or ostrich.\n&amp;quot;&lt;br /&gt;
    // Stuff to do if an unexpected creature was encountered.&lt;br /&gt;
#end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that the strupr function is used to remove case sensitivity. &lt;br /&gt;
&lt;br /&gt;
The following example illustrates the use of multiple #case clauses for a set of associated conditions to work out how many legs an animal has:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
#declare Animal   = &amp;quot;Ostrich&amp;quot;;&lt;br /&gt;
#switch (0)&lt;br /&gt;
  #case (strcmp(strupr(Animal),&amp;quot;DOG&amp;quot;))&lt;br /&gt;
  #case (strcmp(strupr(Animal),&amp;quot;CAT&amp;quot;))&lt;br /&gt;
  #case (strcmp(strupr(Animal),&amp;quot;RHINOCEROS&amp;quot;))&lt;br /&gt;
  #case (strcmp(strupr(Animal),&amp;quot;TABLE&amp;quot;))&lt;br /&gt;
    #declare LegCount = 4;&lt;br /&gt;
  #break &lt;br /&gt;
  #case (strcmp(strupr(Animal),&amp;quot;OSTRICH&amp;quot;))&lt;br /&gt;
  #case (strcmp(strupr(Animal),&amp;quot;DUCK&amp;quot;))&lt;br /&gt;
    #declare LegCount = 2;&lt;br /&gt;
  #break &lt;br /&gt;
  #case (strcmp(strupr(Animal),&amp;quot;WORM&amp;quot;))&lt;br /&gt;
  #case (strcmp(strupr(Animal),&amp;quot;DOLPHIN&amp;quot;))&lt;br /&gt;
    #declare LegCount = 0;&lt;br /&gt;
  #break &lt;br /&gt;
  #else&lt;br /&gt;
    #declare LegCount = -1; // Unknown&lt;br /&gt;
#end&lt;br /&gt;
&lt;br /&gt;
#debug concat(&amp;quot;Animal: &amp;quot;,Animal,&amp;quot;\n&amp;quot;) &lt;br /&gt;
#if (LegCount&amp;lt;1) #debug &amp;quot;Number of Legs Unknown\n&amp;quot;&lt;br /&gt;
#else #debug concat(&amp;quot;Number of Legs: &amp;quot;,str(LegCount,3,0),&amp;quot;\n&amp;quot;)&lt;br /&gt;
#end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can also test for abbreviations using the following construct:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
  #case (strcmp(strupr(Animal),substr(&amp;quot;RHINOCEROS&amp;quot;,1,strlen(Animal))))&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This would match 'Rhino', 'Rhinoceros'. &lt;br /&gt;
&lt;br /&gt;
You clearly need to be a little careful with this as it would also match 'Rhinoc', 'R' and '', but you can set a minimum abbreviation length by using the max function:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
  #case (strcmp(strupr(Animal),substr(&amp;quot;RHINOCEROS&amp;quot;,1,max(strlen(Animal),5))))&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This would match 'Rhino', 'Rhinoceros' and everything in between, but not 'R', 'Rhin' or ''.&lt;/div&gt;</summary>
		<author><name>Chrisb</name></author>
	</entry>
	<entry>
		<id>https://wiki.povray.org/content?title=HowTo:Create_animations&amp;diff=509</id>
		<title>HowTo:Create animations</title>
		<link rel="alternate" type="text/html" href="https://wiki.povray.org/content?title=HowTo:Create_animations&amp;diff=509"/>
		<updated>2008-06-08T23:14:39Z</updated>

		<summary type="html">&lt;p&gt;Chrisb: /* Animating objects */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Animation is the rapid display of a sequence of images in order to create an illusion of movement (see [[Wikipedia:Animation]]). POV-Ray can be used to create such a sequence of images. Creating these images in POV-Ray may be very different from using other graphical tools that you are used to. As with other forms of animation, small sequences can be done quite easily, but when animations grow, a little planning and preparation goes a long way.&lt;br /&gt;
&lt;br /&gt;
==Basics==&lt;br /&gt;
POV-Ray provides a number of features to help produce a sequence of individual still images but does not put them together into an animation. You'll therefore need a separate piece of software to assemble the animation. There are lots of application programs available that will do this, including several free and open source products. You'll need to pick one that can generate the animation file format you wish to produce, e.g. AVI, MPEG, FLI/FLC, QuickTime, or animated GIF files (popularly used on Web pages). Try Googling [http://www.google.com/search?q=animation+utilities animation utilities].&lt;br /&gt;
&lt;br /&gt;
When animating, we use the ini-file (or equivalent command line options) to tell the renderer what frames to render, and what clock values the renderer should use. Our scene file can then use settings such as the clock variable to control the generation of a particular image or 'frame' in the sequence. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
+W150&lt;br /&gt;
+H150         &lt;br /&gt;
Input_File_Name=robot.pov&lt;br /&gt;
Initial_Frame=1&lt;br /&gt;
Final_Frame=30&lt;br /&gt;
Initial_Clock=0&lt;br /&gt;
Final_Clock=1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When using the above INI-file, POV-Ray will render 30 frames and the clock variable will run from 0 to 1. The clock setting as defined in the ini-file or on the command line will be available when your scene is parsed at render time as the variable 'clock'. If not specified, the value of the clock variable will pass from 0 to 1 through the animation sequence.  The frame number will be available to your scene file as the variable 'frame_number'. To be of interest something should change during the animation, often with each frame. This change is usually controlled by using the clock variable or the frame_number variable in your scene file.&lt;br /&gt;
&lt;br /&gt;
==Animating objects==&lt;br /&gt;
To animate a ball we could use the clock variable to control its attributes, position, orientation etc. For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
sphere { &amp;lt;0,clock,0&amp;gt;,1 pigment {rgb 1}}&lt;br /&gt;
 or&lt;br /&gt;
sphere { &amp;lt;0,0,0&amp;gt;,1 translate &amp;lt;0,clock,0&amp;gt; pigment {rgb 1}}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Both examples move a sphere up the Y-axis by a fixed amount per frame.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
 sphere { &amp;lt;0,0,0&amp;gt;,0.5*(1+clock) pigment {rgb 1}}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Increases the radius of the sphere from 0.5 units to 1 unit as the animation sequence progresses.&lt;br /&gt;
&lt;br /&gt;
==Animating object properties==&lt;br /&gt;
More interesting behaviour is possible is you imagine everything can be animated. Allthough impossible in the real world you can show how a piece of glass would look if it's index of refraction would slowly change.&lt;br /&gt;
&lt;br /&gt;
==Animating the camera==&lt;br /&gt;
Animating a camera requires some planning when complex movements are required. Smooth movement is possible if you can specify a 'neat' set of position functions, and a flyby look-and-feel is possible if you also take into account gravity, speed and acceleration, so you can adjust the 'roll' of the camera according to the current down direction.&lt;br /&gt;
This dynamical downdirection is a lineair combination of the gravity vector, and the centrifugal forces caused by direction changes.  &lt;br /&gt;
&lt;br /&gt;
==Creating complex behaviour==&lt;br /&gt;
[[Image:Birds_2_02.gif|right]]&lt;br /&gt;
&lt;br /&gt;
When you want to show complex behaviour in your animation, you will have a lot of programming to do. Sometimes however it is not necessary to define everything in detail. Sometimes simple sets of rules (working on a simple set of variables) wil exhibit complex behavior which will nonetheless be recognizable. &lt;br /&gt;
&lt;br /&gt;
It is possible to define an array of object, say birds or fish, setting up variables for position, orientation and speed, and creating a macro to draw them (with this orientation and speed). Now every time a frame is rendered you call the macro which draws all birds or fish,  and call a macro which calculates the new state for every object (position, speed) and stores it for use in the next frame. This calculation macro is in fact a simple set of -more or less- high-level rules. Changing these rules, you setup behavior, not exact positions for the objects.  You can 'guide' each bird, not exactly, but with simple rules like &amp;quot;stay above the ground&amp;quot; and &amp;quot;if you are going to collide, turn left a bit&amp;quot; you have some control.  These sets of rules will generate almost random behavior, which has recognizable dynamics like flocking for birds, traffic-jamming for cars, or bending in the 'wind' for trees.&lt;br /&gt;
&lt;br /&gt;
===State variables===&lt;br /&gt;
The state variables are the core of this method, and you will need to carefully analyse the behavior of the object you are trying to mimic. You the capture these in a simple data structure. You might create something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
#declare Blocation = array[max_birds];&lt;br /&gt;
#declare Bvelocity = array[max_birds];&lt;br /&gt;
#declare Bphase = array[max_birds];&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The amount of detail in the dissemination of the object tends to grow in time, see below for further explanation of the phase-parameter. &lt;br /&gt;
&lt;br /&gt;
To make this work you will need to 'transfer' the state of the objects (birds) from each frame to the next. This can easily be done using macro's to write out, and readback the variables to a file on disk. The following macro's can be easily extended to save and load more complex data-sets.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
#macro SaveState()    &lt;br /&gt;
       #fopen wfile &amp;quot;state.txt&amp;quot; write&lt;br /&gt;
       #local i = 0;&lt;br /&gt;
       # while (i&amp;lt;max_birds)&lt;br /&gt;
               #write ( wfile, Blocation[i], &amp;quot;,&amp;quot;, Bvelocity[i], &amp;quot;,&amp;quot; , Bphase[i], &amp;quot;,&amp;quot;)&lt;br /&gt;
               #local i=i+1;                &lt;br /&gt;
       #end     &lt;br /&gt;
       #fclose file     &lt;br /&gt;
#end    &lt;br /&gt;
&lt;br /&gt;
#macro LoadState()    &lt;br /&gt;
       #fopen rfile &amp;quot;state.txt&amp;quot; read&lt;br /&gt;
       #local i = 0;&lt;br /&gt;
       #while (i&amp;lt;max_birds)&lt;br /&gt;
               #read ( rfile, Blocation[i] ,Bvelocity[i], Bphase[i] )&lt;br /&gt;
               #local i=i+1;                &lt;br /&gt;
       #end         &lt;br /&gt;
       #fclose file&lt;br /&gt;
#end    &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Drawing the objects===&lt;br /&gt;
You will need a macro or set of macros to draw the objects into the scene. The macro to draw the object will have to take into account all relevant parameters. For instance a bird rolls when taking a turn, according with it's changing down-vector. Also the wings will have a current state (a phase) which determines where the wings are in the up-down direction. &lt;br /&gt;
&lt;br /&gt;
===Rules===&lt;br /&gt;
In the main file you will want to execute some 'business rules' for every bird to define it's solitary behaviour, and maybe you will want to run some other rules for each bird-pair, so social behaviour can be controlled. These rules act on the state variables, but can also gather information elsewhere provided the variables needed are in [[scope]].&lt;br /&gt;
&lt;br /&gt;
You can embed these rules in a macro which you run each frame. In this macro you could create some intermediate variables, deduced from the state variables to make the rule definition somewhat more comfortable. In the example above, we could define a speed, which is easier to compare than a velocity vector.&lt;br /&gt;
&lt;br /&gt;
 #local Speed = vlength(Bvelocity[i]);&lt;br /&gt;
&lt;br /&gt;
Now further on you can create a rule to stop birds from stalling:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
// Do not stall&lt;br /&gt;
#if (Speed&amp;lt;1) &lt;br /&gt;
    #declare Bvelocity[i]=Bvelocity[i]*1.2; &lt;br /&gt;
#end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Detailed control===&lt;br /&gt;
As said you cannot control these objects at the position-level using these rules. At rendertime you have access to all the variables so you could do extra checks and 'force then around'. However this will not work at parse-time. Suppose you create a scene with mountains and buildings, and want to add some birds. Now when the birds calculate their 'next move' the information about buildings and mountains is NOT available. Detailed interaction with the scene requires capturing behaviour in rules, and creating an environment where data about say buildings and mountains can be stored. Now the extra rules can act on this data.&lt;br /&gt;
&lt;br /&gt;
===More to try===&lt;br /&gt;
*You could consider animating things like fish, cars, trees, houses and much more.&lt;br /&gt;
*Try animating different species with specific interactions.&lt;br /&gt;
&lt;br /&gt;
==Cyclic animations==&lt;br /&gt;
Suppose you want to make an animation that loops, so that after the last frame has been rendered it should hop back to the first frame and play everything again. To make the jump from the last to the first frame seamless, the animation must end with exactly the same scene as it started with, i.e. parsing the file with clock = 0 and clock = 1 must generate the same image. When animating this however, you will find a slight glitch in the animation: since the first and last frame are identical it will look like like the animation stops for a while. You could prevent this simply by deleting the last frame after you have rendered them, or only render a subset of the frames to leave out the last one, but POV-ray offers a much better solution. Simply add&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
Cyclic_Animation=On&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
to the INI-file, or +KC to the command line. POV-ray will now automatically do the following:&lt;br /&gt;
&lt;br /&gt;
* Increase the number of frames by one (so if you chose to have 50 frames in the animation, POV-ray will make it 51)&lt;br /&gt;
* but not render the last frame (so you'll still only get 50 images rendered, since the 51st one would be identical to the first)&lt;br /&gt;
&lt;br /&gt;
When these images are compiled into a looping animation, you'll get a nice, smooth, and glitch-free animation.  For example, here's [[HowTo:Encode_animations_as_Ogg_Theora_Video|how to create an Ogg Theora video file]].&lt;/div&gt;</summary>
		<author><name>Chrisb</name></author>
	</entry>
	<entry>
		<id>https://wiki.povray.org/content?title=HowTo:Create_animations&amp;diff=508</id>
		<title>HowTo:Create animations</title>
		<link rel="alternate" type="text/html" href="https://wiki.povray.org/content?title=HowTo:Create_animations&amp;diff=508"/>
		<updated>2008-06-08T22:43:02Z</updated>

		<summary type="html">&lt;p&gt;Chrisb: /* Animating objects */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Animation is the rapid display of a sequence of images in order to create an illusion of movement (see [[Wikipedia:Animation]]). POV-Ray can be used to create such a sequence of images. Creating these images in POV-Ray may be very different from using other graphical tools that you are used to. As with other forms of animation, small sequences can be done quite easily, but when animations grow, a little planning and preparation goes a long way.&lt;br /&gt;
&lt;br /&gt;
==Basics==&lt;br /&gt;
POV-Ray provides a number of features to help produce a sequence of individual still images but does not put them together into an animation. You'll therefore need a separate piece of software to assemble the animation. There are lots of application programs available that will do this, including several free and open source products. You'll need to pick one that can generate the animation file format you wish to produce, e.g. AVI, MPEG, FLI/FLC, QuickTime, or animated GIF files (popularly used on Web pages). Try Googling [http://www.google.com/search?q=animation+utilities animation utilities].&lt;br /&gt;
&lt;br /&gt;
When animating, we use the ini-file (or equivalent command line options) to tell the renderer what frames to render, and what clock values the renderer should use. Our scene file can then use settings such as the clock variable to control the generation of a particular image or 'frame' in the sequence. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
+W150&lt;br /&gt;
+H150         &lt;br /&gt;
Input_File_Name=robot.pov&lt;br /&gt;
Initial_Frame=1&lt;br /&gt;
Final_Frame=30&lt;br /&gt;
Initial_Clock=0&lt;br /&gt;
Final_Clock=1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When using the above INI-file, POV-Ray will render 30 frames and the clock variable will run from 0 to 1. The clock setting as defined in the ini-file or on the command line will be available when your scene is parsed at render time as the variable 'clock'. If not specified, the value of the clock variable will pass from 0 to 1 through the animation sequence.  The frame number will be available to your scene file as the variable 'frame_number'. To be of interest something should change during the animation, often with each frame. This change is usually controlled by using the clock variable or the frame_number variable in your scene file.&lt;br /&gt;
&lt;br /&gt;
==Animating objects==&lt;br /&gt;
To animate a ball we could use the clock variable to control an objects attributes, position, orientation etc. For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
sphere { &amp;lt;0,clock,0&amp;gt;,1 pigment {rgb 1}}&lt;br /&gt;
 or&lt;br /&gt;
sphere { &amp;lt;0,0,0&amp;gt;,1 translate &amp;lt;0,clock,0&amp;gt; pigment {rgb 1}}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Both examples move a sphere up the Y-axis by a fixed amount per frame.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
 sphere { &amp;lt;0,0,0&amp;gt;,0.5*(1+clock) pigment {rgb 1}}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Increases the radius of the sphere from 0.5 units to 1 unit as the animation sequence progresses.&lt;br /&gt;
&lt;br /&gt;
==Animating object properties==&lt;br /&gt;
More interesting behaviour is possible is you imagine everything can be animated. Allthough impossible in the real world you can show how a piece of glass would look if it's index of refraction would slowly change.&lt;br /&gt;
&lt;br /&gt;
==Animating the camera==&lt;br /&gt;
Animating a camera requires some planning when complex movements are required. Smooth movement is possible if you can specify a 'neat' set of position functions, and a flyby look-and-feel is possible if you also take into account gravity, speed and acceleration, so you can adjust the 'roll' of the camera according to the current down direction.&lt;br /&gt;
This dynamical downdirection is a lineair combination of the gravity vector, and the centrifugal forces caused by direction changes.  &lt;br /&gt;
&lt;br /&gt;
==Creating complex behaviour==&lt;br /&gt;
[[Image:Birds_2_02.gif|right]]&lt;br /&gt;
&lt;br /&gt;
When you want to show complex behaviour in your animation, you will have a lot of programming to do. Sometimes however it is not necessary to define everything in detail. Sometimes simple sets of rules (working on a simple set of variables) wil exhibit complex behavior which will nonetheless be recognizable. &lt;br /&gt;
&lt;br /&gt;
It is possible to define an array of object, say birds or fish, setting up variables for position, orientation and speed, and creating a macro to draw them (with this orientation and speed). Now every time a frame is rendered you call the macro which draws all birds or fish,  and call a macro which calculates the new state for every object (position, speed) and stores it for use in the next frame. This calculation macro is in fact a simple set of -more or less- high-level rules. Changing these rules, you setup behavior, not exact positions for the objects.  You can 'guide' each bird, not exactly, but with simple rules like &amp;quot;stay above the ground&amp;quot; and &amp;quot;if you are going to collide, turn left a bit&amp;quot; you have some control.  These sets of rules will generate almost random behavior, which has recognizable dynamics like flocking for birds, traffic-jamming for cars, or bending in the 'wind' for trees.&lt;br /&gt;
&lt;br /&gt;
===State variables===&lt;br /&gt;
The state variables are the core of this method, and you will need to carefully analyse the behavior of the object you are trying to mimic. You the capture these in a simple data structure. You might create something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
#declare Blocation = array[max_birds];&lt;br /&gt;
#declare Bvelocity = array[max_birds];&lt;br /&gt;
#declare Bphase = array[max_birds];&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The amount of detail in the dissemination of the object tends to grow in time, see below for further explanation of the phase-parameter. &lt;br /&gt;
&lt;br /&gt;
To make this work you will need to 'transfer' the state of the objects (birds) from each frame to the next. This can easily be done using macro's to write out, and readback the variables to a file on disk. The following macro's can be easily extended to save and load more complex data-sets.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
#macro SaveState()    &lt;br /&gt;
       #fopen wfile &amp;quot;state.txt&amp;quot; write&lt;br /&gt;
       #local i = 0;&lt;br /&gt;
       # while (i&amp;lt;max_birds)&lt;br /&gt;
               #write ( wfile, Blocation[i], &amp;quot;,&amp;quot;, Bvelocity[i], &amp;quot;,&amp;quot; , Bphase[i], &amp;quot;,&amp;quot;)&lt;br /&gt;
               #local i=i+1;                &lt;br /&gt;
       #end     &lt;br /&gt;
       #fclose file     &lt;br /&gt;
#end    &lt;br /&gt;
&lt;br /&gt;
#macro LoadState()    &lt;br /&gt;
       #fopen rfile &amp;quot;state.txt&amp;quot; read&lt;br /&gt;
       #local i = 0;&lt;br /&gt;
       #while (i&amp;lt;max_birds)&lt;br /&gt;
               #read ( rfile, Blocation[i] ,Bvelocity[i], Bphase[i] )&lt;br /&gt;
               #local i=i+1;                &lt;br /&gt;
       #end         &lt;br /&gt;
       #fclose file&lt;br /&gt;
#end    &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Drawing the objects===&lt;br /&gt;
You will need a macro or set of macros to draw the objects into the scene. The macro to draw the object will have to take into account all relevant parameters. For instance a bird rolls when taking a turn, according with it's changing down-vector. Also the wings will have a current state (a phase) which determines where the wings are in the up-down direction. &lt;br /&gt;
&lt;br /&gt;
===Rules===&lt;br /&gt;
In the main file you will want to execute some 'business rules' for every bird to define it's solitary behaviour, and maybe you will want to run some other rules for each bird-pair, so social behaviour can be controlled. These rules act on the state variables, but can also gather information elsewhere provided the variables needed are in [[scope]].&lt;br /&gt;
&lt;br /&gt;
You can embed these rules in a macro which you run each frame. In this macro you could create some intermediate variables, deduced from the state variables to make the rule definition somewhat more comfortable. In the example above, we could define a speed, which is easier to compare than a velocity vector.&lt;br /&gt;
&lt;br /&gt;
 #local Speed = vlength(Bvelocity[i]);&lt;br /&gt;
&lt;br /&gt;
Now further on you can create a rule to stop birds from stalling:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
// Do not stall&lt;br /&gt;
#if (Speed&amp;lt;1) &lt;br /&gt;
    #declare Bvelocity[i]=Bvelocity[i]*1.2; &lt;br /&gt;
#end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Detailed control===&lt;br /&gt;
As said you cannot control these objects at the position-level using these rules. At rendertime you have access to all the variables so you could do extra checks and 'force then around'. However this will not work at parse-time. Suppose you create a scene with mountains and buildings, and want to add some birds. Now when the birds calculate their 'next move' the information about buildings and mountains is NOT available. Detailed interaction with the scene requires capturing behaviour in rules, and creating an environment where data about say buildings and mountains can be stored. Now the extra rules can act on this data.&lt;br /&gt;
&lt;br /&gt;
===More to try===&lt;br /&gt;
*You could consider animating things like fish, cars, trees, houses and much more.&lt;br /&gt;
*Try animating different species with specific interactions.&lt;br /&gt;
&lt;br /&gt;
==Cyclic animations==&lt;br /&gt;
Suppose you want to make an animation that loops, so that after the last frame has been rendered it should hop back to the first frame and play everything again. To make the jump from the last to the first frame seamless, the animation must end with exactly the same scene as it started with, i.e. parsing the file with clock = 0 and clock = 1 must generate the same image. When animating this however, you will find a slight glitch in the animation: since the first and last frame are identical it will look like like the animation stops for a while. You could prevent this simply by deleting the last frame after you have rendered them, or only render a subset of the frames to leave out the last one, but POV-ray offers a much better solution. Simply add&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
Cyclic_Animation=On&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
to the INI-file, or +KC to the command line. POV-ray will now automatically do the following:&lt;br /&gt;
&lt;br /&gt;
* Increase the number of frames by one (so if you chose to have 50 frames in the animation, POV-ray will make it 51)&lt;br /&gt;
* but not render the last frame (so you'll still only get 50 images rendered, since the 51st one would be identical to the first)&lt;br /&gt;
&lt;br /&gt;
When these images are compiled into a looping animation, you'll get a nice, smooth, and glitch-free animation.  For example, here's [[HowTo:Encode_animations_as_Ogg_Theora_Video|how to create an Ogg Theora video file]].&lt;/div&gt;</summary>
		<author><name>Chrisb</name></author>
	</entry>
	<entry>
		<id>https://wiki.povray.org/content?title=HowTo:Create_animations&amp;diff=507</id>
		<title>HowTo:Create animations</title>
		<link rel="alternate" type="text/html" href="https://wiki.povray.org/content?title=HowTo:Create_animations&amp;diff=507"/>
		<updated>2008-06-08T22:41:17Z</updated>

		<summary type="html">&lt;p&gt;Chrisb: /* Animating objects */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Animation is the rapid display of a sequence of images in order to create an illusion of movement (see [[Wikipedia:Animation]]). POV-Ray can be used to create such a sequence of images. Creating these images in POV-Ray may be very different from using other graphical tools that you are used to. As with other forms of animation, small sequences can be done quite easily, but when animations grow, a little planning and preparation goes a long way.&lt;br /&gt;
&lt;br /&gt;
==Basics==&lt;br /&gt;
POV-Ray provides a number of features to help produce a sequence of individual still images but does not put them together into an animation. You'll therefore need a separate piece of software to assemble the animation. There are lots of application programs available that will do this, including several free and open source products. You'll need to pick one that can generate the animation file format you wish to produce, e.g. AVI, MPEG, FLI/FLC, QuickTime, or animated GIF files (popularly used on Web pages). Try Googling [http://www.google.com/search?q=animation+utilities animation utilities].&lt;br /&gt;
&lt;br /&gt;
When animating, we use the ini-file (or equivalent command line options) to tell the renderer what frames to render, and what clock values the renderer should use. Our scene file can then use settings such as the clock variable to control the generation of a particular image or 'frame' in the sequence. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
+W150&lt;br /&gt;
+H150         &lt;br /&gt;
Input_File_Name=robot.pov&lt;br /&gt;
Initial_Frame=1&lt;br /&gt;
Final_Frame=30&lt;br /&gt;
Initial_Clock=0&lt;br /&gt;
Final_Clock=1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When using the above INI-file, POV-Ray will render 30 frames and the clock variable will run from 0 to 1. The clock setting as defined in the ini-file or on the command line will be available when your scene is parsed at render time as the variable 'clock'. If not specified, the value of the clock variable will pass from 0 to 1 through the animation sequence.  The frame number will be available to your scene file as the variable 'frame_number'. To be of interest something should change during the animation, often with each frame. This change is usually controlled by using the clock variable or the frame_number variable in your scene file.&lt;br /&gt;
&lt;br /&gt;
==Animating objects==&lt;br /&gt;
To animate a ball we could use the clock variable to control an objects attributes, position, orientation etc. For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
sphere { &amp;lt;0,clock,0&amp;gt;,1 }&lt;br /&gt;
 or&lt;br /&gt;
sphere { &amp;lt;0,0,0&amp;gt;,1 translate &amp;lt;0,clock,0&amp;gt; }&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Both examples move a sphere up the Y-axis by a fixed amount per frame.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
 sphere { &amp;lt;0,0,0&amp;gt;,0.5*(1+clock) }&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Increases the radius of the sphere from 0.5 units to 1 unit as the animation sequence progresses.&lt;br /&gt;
&lt;br /&gt;
==Animating object properties==&lt;br /&gt;
More interesting behaviour is possible is you imagine everything can be animated. Allthough impossible in the real world you can show how a piece of glass would look if it's index of refraction would slowly change.&lt;br /&gt;
&lt;br /&gt;
==Animating the camera==&lt;br /&gt;
Animating a camera requires some planning when complex movements are required. Smooth movement is possible if you can specify a 'neat' set of position functions, and a flyby look-and-feel is possible if you also take into account gravity, speed and acceleration, so you can adjust the 'roll' of the camera according to the current down direction.&lt;br /&gt;
This dynamical downdirection is a lineair combination of the gravity vector, and the centrifugal forces caused by direction changes.  &lt;br /&gt;
&lt;br /&gt;
==Creating complex behaviour==&lt;br /&gt;
[[Image:Birds_2_02.gif|right]]&lt;br /&gt;
&lt;br /&gt;
When you want to show complex behaviour in your animation, you will have a lot of programming to do. Sometimes however it is not necessary to define everything in detail. Sometimes simple sets of rules (working on a simple set of variables) wil exhibit complex behavior which will nonetheless be recognizable. &lt;br /&gt;
&lt;br /&gt;
It is possible to define an array of object, say birds or fish, setting up variables for position, orientation and speed, and creating a macro to draw them (with this orientation and speed). Now every time a frame is rendered you call the macro which draws all birds or fish,  and call a macro which calculates the new state for every object (position, speed) and stores it for use in the next frame. This calculation macro is in fact a simple set of -more or less- high-level rules. Changing these rules, you setup behavior, not exact positions for the objects.  You can 'guide' each bird, not exactly, but with simple rules like &amp;quot;stay above the ground&amp;quot; and &amp;quot;if you are going to collide, turn left a bit&amp;quot; you have some control.  These sets of rules will generate almost random behavior, which has recognizable dynamics like flocking for birds, traffic-jamming for cars, or bending in the 'wind' for trees.&lt;br /&gt;
&lt;br /&gt;
===State variables===&lt;br /&gt;
The state variables are the core of this method, and you will need to carefully analyse the behavior of the object you are trying to mimic. You the capture these in a simple data structure. You might create something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
#declare Blocation = array[max_birds];&lt;br /&gt;
#declare Bvelocity = array[max_birds];&lt;br /&gt;
#declare Bphase = array[max_birds];&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The amount of detail in the dissemination of the object tends to grow in time, see below for further explanation of the phase-parameter. &lt;br /&gt;
&lt;br /&gt;
To make this work you will need to 'transfer' the state of the objects (birds) from each frame to the next. This can easily be done using macro's to write out, and readback the variables to a file on disk. The following macro's can be easily extended to save and load more complex data-sets.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
#macro SaveState()    &lt;br /&gt;
       #fopen wfile &amp;quot;state.txt&amp;quot; write&lt;br /&gt;
       #local i = 0;&lt;br /&gt;
       # while (i&amp;lt;max_birds)&lt;br /&gt;
               #write ( wfile, Blocation[i], &amp;quot;,&amp;quot;, Bvelocity[i], &amp;quot;,&amp;quot; , Bphase[i], &amp;quot;,&amp;quot;)&lt;br /&gt;
               #local i=i+1;                &lt;br /&gt;
       #end     &lt;br /&gt;
       #fclose file     &lt;br /&gt;
#end    &lt;br /&gt;
&lt;br /&gt;
#macro LoadState()    &lt;br /&gt;
       #fopen rfile &amp;quot;state.txt&amp;quot; read&lt;br /&gt;
       #local i = 0;&lt;br /&gt;
       #while (i&amp;lt;max_birds)&lt;br /&gt;
               #read ( rfile, Blocation[i] ,Bvelocity[i], Bphase[i] )&lt;br /&gt;
               #local i=i+1;                &lt;br /&gt;
       #end         &lt;br /&gt;
       #fclose file&lt;br /&gt;
#end    &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Drawing the objects===&lt;br /&gt;
You will need a macro or set of macros to draw the objects into the scene. The macro to draw the object will have to take into account all relevant parameters. For instance a bird rolls when taking a turn, according with it's changing down-vector. Also the wings will have a current state (a phase) which determines where the wings are in the up-down direction. &lt;br /&gt;
&lt;br /&gt;
===Rules===&lt;br /&gt;
In the main file you will want to execute some 'business rules' for every bird to define it's solitary behaviour, and maybe you will want to run some other rules for each bird-pair, so social behaviour can be controlled. These rules act on the state variables, but can also gather information elsewhere provided the variables needed are in [[scope]].&lt;br /&gt;
&lt;br /&gt;
You can embed these rules in a macro which you run each frame. In this macro you could create some intermediate variables, deduced from the state variables to make the rule definition somewhat more comfortable. In the example above, we could define a speed, which is easier to compare than a velocity vector.&lt;br /&gt;
&lt;br /&gt;
 #local Speed = vlength(Bvelocity[i]);&lt;br /&gt;
&lt;br /&gt;
Now further on you can create a rule to stop birds from stalling:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
// Do not stall&lt;br /&gt;
#if (Speed&amp;lt;1) &lt;br /&gt;
    #declare Bvelocity[i]=Bvelocity[i]*1.2; &lt;br /&gt;
#end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Detailed control===&lt;br /&gt;
As said you cannot control these objects at the position-level using these rules. At rendertime you have access to all the variables so you could do extra checks and 'force then around'. However this will not work at parse-time. Suppose you create a scene with mountains and buildings, and want to add some birds. Now when the birds calculate their 'next move' the information about buildings and mountains is NOT available. Detailed interaction with the scene requires capturing behaviour in rules, and creating an environment where data about say buildings and mountains can be stored. Now the extra rules can act on this data.&lt;br /&gt;
&lt;br /&gt;
===More to try===&lt;br /&gt;
*You could consider animating things like fish, cars, trees, houses and much more.&lt;br /&gt;
*Try animating different species with specific interactions.&lt;br /&gt;
&lt;br /&gt;
==Cyclic animations==&lt;br /&gt;
Suppose you want to make an animation that loops, so that after the last frame has been rendered it should hop back to the first frame and play everything again. To make the jump from the last to the first frame seamless, the animation must end with exactly the same scene as it started with, i.e. parsing the file with clock = 0 and clock = 1 must generate the same image. When animating this however, you will find a slight glitch in the animation: since the first and last frame are identical it will look like like the animation stops for a while. You could prevent this simply by deleting the last frame after you have rendered them, or only render a subset of the frames to leave out the last one, but POV-ray offers a much better solution. Simply add&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
Cyclic_Animation=On&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
to the INI-file, or +KC to the command line. POV-ray will now automatically do the following:&lt;br /&gt;
&lt;br /&gt;
* Increase the number of frames by one (so if you chose to have 50 frames in the animation, POV-ray will make it 51)&lt;br /&gt;
* but not render the last frame (so you'll still only get 50 images rendered, since the 51st one would be identical to the first)&lt;br /&gt;
&lt;br /&gt;
When these images are compiled into a looping animation, you'll get a nice, smooth, and glitch-free animation.  For example, here's [[HowTo:Encode_animations_as_Ogg_Theora_Video|how to create an Ogg Theora video file]].&lt;/div&gt;</summary>
		<author><name>Chrisb</name></author>
	</entry>
	<entry>
		<id>https://wiki.povray.org/content?title=HowTo:Create_animations&amp;diff=506</id>
		<title>HowTo:Create animations</title>
		<link rel="alternate" type="text/html" href="https://wiki.povray.org/content?title=HowTo:Create_animations&amp;diff=506"/>
		<updated>2008-06-08T22:40:24Z</updated>

		<summary type="html">&lt;p&gt;Chrisb: /* Animating objects small addition*/&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Animation is the rapid display of a sequence of images in order to create an illusion of movement (see [[Wikipedia:Animation]]). POV-Ray can be used to create such a sequence of images. Creating these images in POV-Ray may be very different from using other graphical tools that you are used to. As with other forms of animation, small sequences can be done quite easily, but when animations grow, a little planning and preparation goes a long way.&lt;br /&gt;
&lt;br /&gt;
==Basics==&lt;br /&gt;
POV-Ray provides a number of features to help produce a sequence of individual still images but does not put them together into an animation. You'll therefore need a separate piece of software to assemble the animation. There are lots of application programs available that will do this, including several free and open source products. You'll need to pick one that can generate the animation file format you wish to produce, e.g. AVI, MPEG, FLI/FLC, QuickTime, or animated GIF files (popularly used on Web pages). Try Googling [http://www.google.com/search?q=animation+utilities animation utilities].&lt;br /&gt;
&lt;br /&gt;
When animating, we use the ini-file (or equivalent command line options) to tell the renderer what frames to render, and what clock values the renderer should use. Our scene file can then use settings such as the clock variable to control the generation of a particular image or 'frame' in the sequence. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
+W150&lt;br /&gt;
+H150         &lt;br /&gt;
Input_File_Name=robot.pov&lt;br /&gt;
Initial_Frame=1&lt;br /&gt;
Final_Frame=30&lt;br /&gt;
Initial_Clock=0&lt;br /&gt;
Final_Clock=1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When using the above INI-file, POV-Ray will render 30 frames and the clock variable will run from 0 to 1. The clock setting as defined in the ini-file or on the command line will be available when your scene is parsed at render time as the variable 'clock'. If not specified, the value of the clock variable will pass from 0 to 1 through the animation sequence.  The frame number will be available to your scene file as the variable 'frame_number'. To be of interest something should change during the animation, often with each frame. This change is usually controlled by using the clock variable or the frame_number variable in your scene file.&lt;br /&gt;
&lt;br /&gt;
==Animating objects==&lt;br /&gt;
To animate a ball we could use the clock variable to control an objects attributes, position, orientation etc. For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
 sphere { &amp;lt;0,clock,0&amp;gt;,1 }&lt;br /&gt;
 or&lt;br /&gt;
 sphere { &amp;lt;0,0,0&amp;gt;,1 translate &amp;lt;0,clock,0&amp;gt; }&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Both examples move a sphere up the Y-axis by a fixed amount per frame.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
 sphere { &amp;lt;0,0,0&amp;gt;,0.5*(1+clock) }&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Increases the radius of the sphere from 0.5 units to 1 unit as the animation sequence progresses.&lt;br /&gt;
&lt;br /&gt;
==Animating object properties==&lt;br /&gt;
More interesting behaviour is possible is you imagine everything can be animated. Allthough impossible in the real world you can show how a piece of glass would look if it's index of refraction would slowly change.&lt;br /&gt;
&lt;br /&gt;
==Animating the camera==&lt;br /&gt;
Animating a camera requires some planning when complex movements are required. Smooth movement is possible if you can specify a 'neat' set of position functions, and a flyby look-and-feel is possible if you also take into account gravity, speed and acceleration, so you can adjust the 'roll' of the camera according to the current down direction.&lt;br /&gt;
This dynamical downdirection is a lineair combination of the gravity vector, and the centrifugal forces caused by direction changes.  &lt;br /&gt;
&lt;br /&gt;
==Creating complex behaviour==&lt;br /&gt;
[[Image:Birds_2_02.gif|right]]&lt;br /&gt;
&lt;br /&gt;
When you want to show complex behaviour in your animation, you will have a lot of programming to do. Sometimes however it is not necessary to define everything in detail. Sometimes simple sets of rules (working on a simple set of variables) wil exhibit complex behavior which will nonetheless be recognizable. &lt;br /&gt;
&lt;br /&gt;
It is possible to define an array of object, say birds or fish, setting up variables for position, orientation and speed, and creating a macro to draw them (with this orientation and speed). Now every time a frame is rendered you call the macro which draws all birds or fish,  and call a macro which calculates the new state for every object (position, speed) and stores it for use in the next frame. This calculation macro is in fact a simple set of -more or less- high-level rules. Changing these rules, you setup behavior, not exact positions for the objects.  You can 'guide' each bird, not exactly, but with simple rules like &amp;quot;stay above the ground&amp;quot; and &amp;quot;if you are going to collide, turn left a bit&amp;quot; you have some control.  These sets of rules will generate almost random behavior, which has recognizable dynamics like flocking for birds, traffic-jamming for cars, or bending in the 'wind' for trees.&lt;br /&gt;
&lt;br /&gt;
===State variables===&lt;br /&gt;
The state variables are the core of this method, and you will need to carefully analyse the behavior of the object you are trying to mimic. You the capture these in a simple data structure. You might create something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
#declare Blocation = array[max_birds];&lt;br /&gt;
#declare Bvelocity = array[max_birds];&lt;br /&gt;
#declare Bphase = array[max_birds];&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The amount of detail in the dissemination of the object tends to grow in time, see below for further explanation of the phase-parameter. &lt;br /&gt;
&lt;br /&gt;
To make this work you will need to 'transfer' the state of the objects (birds) from each frame to the next. This can easily be done using macro's to write out, and readback the variables to a file on disk. The following macro's can be easily extended to save and load more complex data-sets.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
#macro SaveState()    &lt;br /&gt;
       #fopen wfile &amp;quot;state.txt&amp;quot; write&lt;br /&gt;
       #local i = 0;&lt;br /&gt;
       # while (i&amp;lt;max_birds)&lt;br /&gt;
               #write ( wfile, Blocation[i], &amp;quot;,&amp;quot;, Bvelocity[i], &amp;quot;,&amp;quot; , Bphase[i], &amp;quot;,&amp;quot;)&lt;br /&gt;
               #local i=i+1;                &lt;br /&gt;
       #end     &lt;br /&gt;
       #fclose file     &lt;br /&gt;
#end    &lt;br /&gt;
&lt;br /&gt;
#macro LoadState()    &lt;br /&gt;
       #fopen rfile &amp;quot;state.txt&amp;quot; read&lt;br /&gt;
       #local i = 0;&lt;br /&gt;
       #while (i&amp;lt;max_birds)&lt;br /&gt;
               #read ( rfile, Blocation[i] ,Bvelocity[i], Bphase[i] )&lt;br /&gt;
               #local i=i+1;                &lt;br /&gt;
       #end         &lt;br /&gt;
       #fclose file&lt;br /&gt;
#end    &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Drawing the objects===&lt;br /&gt;
You will need a macro or set of macros to draw the objects into the scene. The macro to draw the object will have to take into account all relevant parameters. For instance a bird rolls when taking a turn, according with it's changing down-vector. Also the wings will have a current state (a phase) which determines where the wings are in the up-down direction. &lt;br /&gt;
&lt;br /&gt;
===Rules===&lt;br /&gt;
In the main file you will want to execute some 'business rules' for every bird to define it's solitary behaviour, and maybe you will want to run some other rules for each bird-pair, so social behaviour can be controlled. These rules act on the state variables, but can also gather information elsewhere provided the variables needed are in [[scope]].&lt;br /&gt;
&lt;br /&gt;
You can embed these rules in a macro which you run each frame. In this macro you could create some intermediate variables, deduced from the state variables to make the rule definition somewhat more comfortable. In the example above, we could define a speed, which is easier to compare than a velocity vector.&lt;br /&gt;
&lt;br /&gt;
 #local Speed = vlength(Bvelocity[i]);&lt;br /&gt;
&lt;br /&gt;
Now further on you can create a rule to stop birds from stalling:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
// Do not stall&lt;br /&gt;
#if (Speed&amp;lt;1) &lt;br /&gt;
    #declare Bvelocity[i]=Bvelocity[i]*1.2; &lt;br /&gt;
#end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Detailed control===&lt;br /&gt;
As said you cannot control these objects at the position-level using these rules. At rendertime you have access to all the variables so you could do extra checks and 'force then around'. However this will not work at parse-time. Suppose you create a scene with mountains and buildings, and want to add some birds. Now when the birds calculate their 'next move' the information about buildings and mountains is NOT available. Detailed interaction with the scene requires capturing behaviour in rules, and creating an environment where data about say buildings and mountains can be stored. Now the extra rules can act on this data.&lt;br /&gt;
&lt;br /&gt;
===More to try===&lt;br /&gt;
*You could consider animating things like fish, cars, trees, houses and much more.&lt;br /&gt;
*Try animating different species with specific interactions.&lt;br /&gt;
&lt;br /&gt;
==Cyclic animations==&lt;br /&gt;
Suppose you want to make an animation that loops, so that after the last frame has been rendered it should hop back to the first frame and play everything again. To make the jump from the last to the first frame seamless, the animation must end with exactly the same scene as it started with, i.e. parsing the file with clock = 0 and clock = 1 must generate the same image. When animating this however, you will find a slight glitch in the animation: since the first and last frame are identical it will look like like the animation stops for a while. You could prevent this simply by deleting the last frame after you have rendered them, or only render a subset of the frames to leave out the last one, but POV-ray offers a much better solution. Simply add&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
Cyclic_Animation=On&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
to the INI-file, or +KC to the command line. POV-ray will now automatically do the following:&lt;br /&gt;
&lt;br /&gt;
* Increase the number of frames by one (so if you chose to have 50 frames in the animation, POV-ray will make it 51)&lt;br /&gt;
* but not render the last frame (so you'll still only get 50 images rendered, since the 51st one would be identical to the first)&lt;br /&gt;
&lt;br /&gt;
When these images are compiled into a looping animation, you'll get a nice, smooth, and glitch-free animation.  For example, here's [[HowTo:Encode_animations_as_Ogg_Theora_Video|how to create an Ogg Theora video file]].&lt;/div&gt;</summary>
		<author><name>Chrisb</name></author>
	</entry>
	<entry>
		<id>https://wiki.povray.org/content?title=HowTo:Create_animations&amp;diff=505</id>
		<title>HowTo:Create animations</title>
		<link rel="alternate" type="text/html" href="https://wiki.povray.org/content?title=HowTo:Create_animations&amp;diff=505"/>
		<updated>2008-06-08T22:29:04Z</updated>

		<summary type="html">&lt;p&gt;Chrisb: /* Basics */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Animation is the rapid display of a sequence of images in order to create an illusion of movement (see [[Wikipedia:Animation]]). POV-Ray can be used to create such a sequence of images. Creating these images in POV-Ray may be very different from using other graphical tools that you are used to. As with other forms of animation, small sequences can be done quite easily, but when animations grow, a little planning and preparation goes a long way.&lt;br /&gt;
&lt;br /&gt;
==Basics==&lt;br /&gt;
POV-Ray provides a number of features to help produce a sequence of individual still images but does not put them together into an animation. You'll therefore need a separate piece of software to assemble the animation. There are lots of application programs available that will do this, including several free and open source products. You'll need to pick one that can generate the animation file format you wish to produce, e.g. AVI, MPEG, FLI/FLC, QuickTime, or animated GIF files (popularly used on Web pages). Try Googling [http://www.google.com/search?q=animation+utilities animation utilities].&lt;br /&gt;
&lt;br /&gt;
When animating, we use the ini-file (or equivalent command line options) to tell the renderer what frames to render, and what clock values the renderer should use. Our scene file can then use settings such as the clock variable to control the generation of a particular image or 'frame' in the sequence. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
+W150&lt;br /&gt;
+H150         &lt;br /&gt;
Input_File_Name=robot.pov&lt;br /&gt;
Initial_Frame=1&lt;br /&gt;
Final_Frame=30&lt;br /&gt;
Initial_Clock=0&lt;br /&gt;
Final_Clock=1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When using the above INI-file, POV-Ray will render 30 frames and the clock variable will run from 0 to 1. The clock setting as defined in the ini-file or on the command line will be available when your scene is parsed at render time as the variable 'clock'. If not specified, the value of the clock variable will pass from 0 to 1 through the animation sequence.  The frame number will be available to your scene file as the variable 'frame_number'. To be of interest something should change during the animation, often with each frame. This change is usually controlled by using the clock variable or the frame_number variable in your scene file.&lt;br /&gt;
&lt;br /&gt;
==Animating objects==&lt;br /&gt;
To animate a ball going up and down we could use the clockvariable in an object creation of translation.&lt;br /&gt;
&lt;br /&gt;
 sphere { &amp;lt;0,clock,0&amp;gt;,1 }&lt;br /&gt;
 or&lt;br /&gt;
 sphere { &amp;lt;0,0,0&amp;gt;,1 translate &amp;lt;0,clock,0&amp;gt; }&lt;br /&gt;
&lt;br /&gt;
==Animating object properties==&lt;br /&gt;
More interesting behaviour is possible is you imagine everything can be animated. Allthough impossible in the real world you can show how a piece of glass would look if it's index of refraction would slowly change.&lt;br /&gt;
&lt;br /&gt;
==Animating the camera==&lt;br /&gt;
Animating a camera requires some planning when complex movements are required. Smooth movement is possible if you can specify a 'neat' set of position functions, and a flyby look-and-feel is possible if you also take into account gravity, speed and acceleration, so you can adjust the 'roll' of the camera according to the current down direction.&lt;br /&gt;
This dynamical downdirection is a lineair combination of the gravity vector, and the centrifugal forces caused by direction changes.  &lt;br /&gt;
&lt;br /&gt;
==Creating complex behaviour==&lt;br /&gt;
[[Image:Birds_2_02.gif|right]]&lt;br /&gt;
&lt;br /&gt;
When you want to show complex behaviour in your animation, you will have a lot of programming to do. Sometimes however it is not necessary to define everything in detail. Sometimes simple sets of rules (working on a simple set of variables) wil exhibit complex behavior which will nonetheless be recognizable. &lt;br /&gt;
&lt;br /&gt;
It is possible to define an array of object, say birds or fish, setting up variables for position, orientation and speed, and creating a macro to draw them (with this orientation and speed). Now every time a frame is rendered you call the macro which draws all birds or fish,  and call a macro which calculates the new state for every object (position, speed) and stores it for use in the next frame. This calculation macro is in fact a simple set of -more or less- high-level rules. Changing these rules, you setup behavior, not exact positions for the objects.  You can 'guide' each bird, not exactly, but with simple rules like &amp;quot;stay above the ground&amp;quot; and &amp;quot;if you are going to collide, turn left a bit&amp;quot; you have some control.  These sets of rules will generate almost random behavior, which has recognizable dynamics like flocking for birds, traffic-jamming for cars, or bending in the 'wind' for trees.&lt;br /&gt;
&lt;br /&gt;
===State variables===&lt;br /&gt;
The state variables are the core of this method, and you will need to carefully analyse the behavior of the object you are trying to mimic. You the capture these in a simple data structure. You might create something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
#declare Blocation = array[max_birds];&lt;br /&gt;
#declare Bvelocity = array[max_birds];&lt;br /&gt;
#declare Bphase = array[max_birds];&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The amount of detail in the dissemination of the object tends to grow in time, see below for further explanation of the phase-parameter. &lt;br /&gt;
&lt;br /&gt;
To make this work you will need to 'transfer' the state of the objects (birds) from each frame to the next. This can easily be done using macro's to write out, and readback the variables to a file on disk. The following macro's can be easily extended to save and load more complex data-sets.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
#macro SaveState()    &lt;br /&gt;
       #fopen wfile &amp;quot;state.txt&amp;quot; write&lt;br /&gt;
       #local i = 0;&lt;br /&gt;
       # while (i&amp;lt;max_birds)&lt;br /&gt;
               #write ( wfile, Blocation[i], &amp;quot;,&amp;quot;, Bvelocity[i], &amp;quot;,&amp;quot; , Bphase[i], &amp;quot;,&amp;quot;)&lt;br /&gt;
               #local i=i+1;                &lt;br /&gt;
       #end     &lt;br /&gt;
       #fclose file     &lt;br /&gt;
#end    &lt;br /&gt;
&lt;br /&gt;
#macro LoadState()    &lt;br /&gt;
       #fopen rfile &amp;quot;state.txt&amp;quot; read&lt;br /&gt;
       #local i = 0;&lt;br /&gt;
       #while (i&amp;lt;max_birds)&lt;br /&gt;
               #read ( rfile, Blocation[i] ,Bvelocity[i], Bphase[i] )&lt;br /&gt;
               #local i=i+1;                &lt;br /&gt;
       #end         &lt;br /&gt;
       #fclose file&lt;br /&gt;
#end    &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Drawing the objects===&lt;br /&gt;
You will need a macro or set of macros to draw the objects into the scene. The macro to draw the object will have to take into account all relevant parameters. For instance a bird rolls when taking a turn, according with it's changing down-vector. Also the wings will have a current state (a phase) which determines where the wings are in the up-down direction. &lt;br /&gt;
&lt;br /&gt;
===Rules===&lt;br /&gt;
In the main file you will want to execute some 'business rules' for every bird to define it's solitary behaviour, and maybe you will want to run some other rules for each bird-pair, so social behaviour can be controlled. These rules act on the state variables, but can also gather information elsewhere provided the variables needed are in [[scope]].&lt;br /&gt;
&lt;br /&gt;
You can embed these rules in a macro which you run each frame. In this macro you could create some intermediate variables, deduced from the state variables to make the rule definition somewhat more comfortable. In the example above, we could define a speed, which is easier to compare than a velocity vector.&lt;br /&gt;
&lt;br /&gt;
 #local Speed = vlength(Bvelocity[i]);&lt;br /&gt;
&lt;br /&gt;
Now further on you can create a rule to stop birds from stalling:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
// Do not stall&lt;br /&gt;
#if (Speed&amp;lt;1) &lt;br /&gt;
    #declare Bvelocity[i]=Bvelocity[i]*1.2; &lt;br /&gt;
#end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Detailed control===&lt;br /&gt;
As said you cannot control these objects at the position-level using these rules. At rendertime you have access to all the variables so you could do extra checks and 'force then around'. However this will not work at parse-time. Suppose you create a scene with mountains and buildings, and want to add some birds. Now when the birds calculate their 'next move' the information about buildings and mountains is NOT available. Detailed interaction with the scene requires capturing behaviour in rules, and creating an environment where data about say buildings and mountains can be stored. Now the extra rules can act on this data.&lt;br /&gt;
&lt;br /&gt;
===More to try===&lt;br /&gt;
*You could consider animating things like fish, cars, trees, houses and much more.&lt;br /&gt;
*Try animating different species with specific interactions.&lt;br /&gt;
&lt;br /&gt;
==Cyclic animations==&lt;br /&gt;
Suppose you want to make an animation that loops, so that after the last frame has been rendered it should hop back to the first frame and play everything again. To make the jump from the last to the first frame seamless, the animation must end with exactly the same scene as it started with, i.e. parsing the file with clock = 0 and clock = 1 must generate the same image. When animating this however, you will find a slight glitch in the animation: since the first and last frame are identical it will look like like the animation stops for a while. You could prevent this simply by deleting the last frame after you have rendered them, or only render a subset of the frames to leave out the last one, but POV-ray offers a much better solution. Simply add&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
Cyclic_Animation=On&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
to the INI-file, or +KC to the command line. POV-ray will now automatically do the following:&lt;br /&gt;
&lt;br /&gt;
* Increase the number of frames by one (so if you chose to have 50 frames in the animation, POV-ray will make it 51)&lt;br /&gt;
* but not render the last frame (so you'll still only get 50 images rendered, since the 51st one would be identical to the first)&lt;br /&gt;
&lt;br /&gt;
When these images are compiled into a looping animation, you'll get a nice, smooth, and glitch-free animation.  For example, here's [[HowTo:Encode_animations_as_Ogg_Theora_Video|how to create an Ogg Theora video file]].&lt;/div&gt;</summary>
		<author><name>Chrisb</name></author>
	</entry>
	<entry>
		<id>https://wiki.povray.org/content?title=HowTo:Create_animations&amp;diff=504</id>
		<title>HowTo:Create animations</title>
		<link rel="alternate" type="text/html" href="https://wiki.povray.org/content?title=HowTo:Create_animations&amp;diff=504"/>
		<updated>2008-06-08T22:05:20Z</updated>

		<summary type="html">&lt;p&gt;Chrisb: Added a little to the intro&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Animation is the rapid display of a sequence of images in order to create an illusion of movement (see [[Wikipedia:Animation]]). POV-Ray can be used to create such a sequence of images. Creating these images in POV-Ray may be very different from using other graphical tools that you are used to. As with other forms of animation, small sequences can be done quite easily, but when animations grow, a little planning and preparation goes a long way.&lt;br /&gt;
&lt;br /&gt;
==Basics==&lt;br /&gt;
POV-Ray provides a number of features to help produce a sequence of individual still images but does not put them together into an animation. You'll therefore need a separate piece of software to assemble the animation. There are lots of application programs available that will do this, including several free and open source products. You'll need to pick one that can generate the animation file format you wish to produce, e.g. AVI, MPEG, FLI/FLC, QuickTime, or animated GIF files (popularly used on Web pages).&lt;br /&gt;
&lt;br /&gt;
When animating, we use the ini-file (or equivalent command line options) to tell the renderer what frames to render, and what clock values the renderer should use. Our scene file can then use settings such as the clock variable to control the image generation. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
+W150&lt;br /&gt;
+H150         &lt;br /&gt;
Input_File_Name=robot.pov&lt;br /&gt;
Initial_Frame=1&lt;br /&gt;
Final_Frame=30&lt;br /&gt;
Initial_Clock=0&lt;br /&gt;
Final_Clock=1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Using the above INI-file will render 30 frames, and the clockvariable will run from 0 to 1. This clock we set in the ini-file wille be avaiable at rendertime as the variable 'clock'. To be of interest every frame should be different according to the clockvalue. &lt;br /&gt;
&lt;br /&gt;
==Animating objects==&lt;br /&gt;
To animate a ball going up and down we could use the clockvariable in an object creation of translation.&lt;br /&gt;
&lt;br /&gt;
 sphere { &amp;lt;0,clock,0&amp;gt;,1 }&lt;br /&gt;
 or&lt;br /&gt;
 sphere { &amp;lt;0,0,0&amp;gt;,1 translate &amp;lt;0,clock,0&amp;gt; }&lt;br /&gt;
&lt;br /&gt;
==Animating object properties==&lt;br /&gt;
More interesting behaviour is possible is you imagine everything can be animated. Allthough impossible in the real world you can show how a piece of glass would look if it's index of refraction would slowly change.&lt;br /&gt;
&lt;br /&gt;
==Animating the camera==&lt;br /&gt;
Animating a camera requires some planning when complex movements are required. Smooth movement is possible if you can specify a 'neat' set of position functions, and a flyby look-and-feel is possible if you also take into account gravity, speed and acceleration, so you can adjust the 'roll' of the camera according to the current down direction.&lt;br /&gt;
This dynamical downdirection is a lineair combination of the gravity vector, and the centrifugal forces caused by direction changes.  &lt;br /&gt;
&lt;br /&gt;
==Creating complex behaviour==&lt;br /&gt;
[[Image:Birds_2_02.gif|right]]&lt;br /&gt;
&lt;br /&gt;
When you want to show complex behaviour in your animation, you will have a lot of programming to do. Sometimes however it is not necessary to define everything in detail. Sometimes simple sets of rules (working on a simple set of variables) wil exhibit complex behavior which will nonetheless be recognizable. &lt;br /&gt;
&lt;br /&gt;
It is possible to define an array of object, say birds or fish, setting up variables for position, orientation and speed, and creating a macro to draw them (with this orientation and speed). Now every time a frame is rendered you call the macro which draws all birds or fish,  and call a macro which calculates the new state for every object (position, speed) and stores it for use in the next frame. This calculation macro is in fact a simple set of -more or less- high-level rules. Changing these rules, you setup behavior, not exact positions for the objects.  You can 'guide' each bird, not exactly, but with simple rules like &amp;quot;stay above the ground&amp;quot; and &amp;quot;if you are going to collide, turn left a bit&amp;quot; you have some control.  These sets of rules will generate almost random behavior, which has recognizable dynamics like flocking for birds, traffic-jamming for cars, or bending in the 'wind' for trees.&lt;br /&gt;
&lt;br /&gt;
===State variables===&lt;br /&gt;
The state variables are the core of this method, and you will need to carefully analyse the behavior of the object you are trying to mimic. You the capture these in a simple data structure. You might create something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
#declare Blocation = array[max_birds];&lt;br /&gt;
#declare Bvelocity = array[max_birds];&lt;br /&gt;
#declare Bphase = array[max_birds];&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The amount of detail in the dissemination of the object tends to grow in time, see below for further explanation of the phase-parameter. &lt;br /&gt;
&lt;br /&gt;
To make this work you will need to 'transfer' the state of the objects (birds) from each frame to the next. This can easily be done using macro's to write out, and readback the variables to a file on disk. The following macro's can be easily extended to save and load more complex data-sets.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
#macro SaveState()    &lt;br /&gt;
       #fopen wfile &amp;quot;state.txt&amp;quot; write&lt;br /&gt;
       #local i = 0;&lt;br /&gt;
       # while (i&amp;lt;max_birds)&lt;br /&gt;
               #write ( wfile, Blocation[i], &amp;quot;,&amp;quot;, Bvelocity[i], &amp;quot;,&amp;quot; , Bphase[i], &amp;quot;,&amp;quot;)&lt;br /&gt;
               #local i=i+1;                &lt;br /&gt;
       #end     &lt;br /&gt;
       #fclose file     &lt;br /&gt;
#end    &lt;br /&gt;
&lt;br /&gt;
#macro LoadState()    &lt;br /&gt;
       #fopen rfile &amp;quot;state.txt&amp;quot; read&lt;br /&gt;
       #local i = 0;&lt;br /&gt;
       #while (i&amp;lt;max_birds)&lt;br /&gt;
               #read ( rfile, Blocation[i] ,Bvelocity[i], Bphase[i] )&lt;br /&gt;
               #local i=i+1;                &lt;br /&gt;
       #end         &lt;br /&gt;
       #fclose file&lt;br /&gt;
#end    &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Drawing the objects===&lt;br /&gt;
You will need a macro or set of macros to draw the objects into the scene. The macro to draw the object will have to take into account all relevant parameters. For instance a bird rolls when taking a turn, according with it's changing down-vector. Also the wings will have a current state (a phase) which determines where the wings are in the up-down direction. &lt;br /&gt;
&lt;br /&gt;
===Rules===&lt;br /&gt;
In the main file you will want to execute some 'business rules' for every bird to define it's solitary behaviour, and maybe you will want to run some other rules for each bird-pair, so social behaviour can be controlled. These rules act on the state variables, but can also gather information elsewhere provided the variables needed are in [[scope]].&lt;br /&gt;
&lt;br /&gt;
You can embed these rules in a macro which you run each frame. In this macro you could create some intermediate variables, deduced from the state variables to make the rule definition somewhat more comfortable. In the example above, we could define a speed, which is easier to compare than a velocity vector.&lt;br /&gt;
&lt;br /&gt;
 #local Speed = vlength(Bvelocity[i]);&lt;br /&gt;
&lt;br /&gt;
Now further on you can create a rule to stop birds from stalling:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
// Do not stall&lt;br /&gt;
#if (Speed&amp;lt;1) &lt;br /&gt;
    #declare Bvelocity[i]=Bvelocity[i]*1.2; &lt;br /&gt;
#end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Detailed control===&lt;br /&gt;
As said you cannot control these objects at the position-level using these rules. At rendertime you have access to all the variables so you could do extra checks and 'force then around'. However this will not work at parse-time. Suppose you create a scene with mountains and buildings, and want to add some birds. Now when the birds calculate their 'next move' the information about buildings and mountains is NOT available. Detailed interaction with the scene requires capturing behaviour in rules, and creating an environment where data about say buildings and mountains can be stored. Now the extra rules can act on this data.&lt;br /&gt;
&lt;br /&gt;
===More to try===&lt;br /&gt;
*You could consider animating things like fish, cars, trees, houses and much more.&lt;br /&gt;
*Try animating different species with specific interactions.&lt;br /&gt;
&lt;br /&gt;
==Cyclic animations==&lt;br /&gt;
Suppose you want to make an animation that loops, so that after the last frame has been rendered it should hop back to the first frame and play everything again. To make the jump from the last to the first frame seamless, the animation must end with exactly the same scene as it started with, i.e. parsing the file with clock = 0 and clock = 1 must generate the same image. When animating this however, you will find a slight glitch in the animation: since the first and last frame are identical it will look like like the animation stops for a while. You could prevent this simply by deleting the last frame after you have rendered them, or only render a subset of the frames to leave out the last one, but POV-ray offers a much better solution. Simply add&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;pov&amp;quot;&amp;gt;&lt;br /&gt;
Cyclic_Animation=On&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
to the INI-file, or +KC to the command line. POV-ray will now automatically do the following:&lt;br /&gt;
&lt;br /&gt;
* Increase the number of frames by one (so if you chose to have 50 frames in the animation, POV-ray will make it 51)&lt;br /&gt;
* but not render the last frame (so you'll still only get 50 images rendered, since the 51st one would be identical to the first)&lt;br /&gt;
&lt;br /&gt;
When these images are compiled into a looping animation, you'll get a nice, smooth, and glitch-free animation.  For example, here's [[HowTo:Encode_animations_as_Ogg_Theora_Video|how to create an Ogg Theora video file]].&lt;/div&gt;</summary>
		<author><name>Chrisb</name></author>
	</entry>
</feed>