MegaPOV Documentation

MegaPOV 1.1

8 September 2004

Abstract

This documentation contains a complete set of information about MegaPOV. Here you can find descriptions from either script and patch writer point of view. This work is supposed to be an addition to complete the POV-Ray™ Documentation.


Table of Contents

1. Introduction
1.1. What is MegaPOV?
1.2. What's new
1.2.1. MegaPOV 1.1 - 8 September 2004
1.2.2. Previous versions of MegaPOV
1.3. Why should i use MegaPOV?
1.4. Enabling MegaPOV features
1.5. Where do I find MegaPOV?
1.5.1. Sources and binaries
1.5.2. Documentation and samples
1.5.3. Discussions
2. MegaPOV References
2.1. Options
2.1.1. Frame_Step
2.1.2. HDR (High Dynamic Range) image output
2.2. Expressions
2.2.1. Language directives
2.2.2. Built-in tokens
2.2.3. Functions
2.2.4. Internal functions
2.2.5. Polynomial solver in parser
2.2.6. Splines
2.2.7. Transforms
2.3. Camera
2.3.1. user_defined camera type
2.4. Objects
2.4.1. Common features
2.4.2. Text
2.4.3. Cloth simulation
2.4.4. Isosurface
2.5. Effects
2.5.1. Glow
2.5.2. Motion blur
2.5.3. Fur
2.6. Textures and patterns
2.6.1. Angle of incidence
2.6.2. Listed pattern
2.6.3. Projection pattern
2.6.4. Displace warp for patterns
2.6.5. Noise pigment
2.6.6. HDR (High Dynamic Range) image type
2.6.7. New camera_view pigment
2.7. Global Settings
2.7.1. Film exposure simulation
2.7.2. Radiosity
2.7.3. Mechanics simulation patch
2.7.4. Post processing
3. MegaPOV Include files
3.1. The 'mp_functions.inc' include file
3.2. The 'mp_consts.inc' include file
3.2.1. Output types for camera_view pigment
3.3. The 'mp_types.inc' include file
3.3.1. The Type_Of(Id) macro
3.3.2. The Type_Of_Spline(Id) macro
3.3.3. The Type_Of_Object(Id) macro
3.3.4. The Type_Of_Camera(Id) macro
3.4. The 'mechsim.inc' include file
3.4.1. general aspects
3.4.2. constants
3.4.3. The Vector_Function() macro
3.4.4. The Object generation macros
3.4.5. The topology generation macros
3.5. The 'pprocess.inc' include file
3.5.1. Macros with effects
3.5.2. Shared predefined effects
4. Tutorials
4.1. Objects
4.1.1. Cloth simulation
4.2. Simulation
4.2.1. Mechanics simulation tutorial
4.3. HDRI (High dynamic range illumination)
4.3.1. HDRI tutorial
5. Internals
5.1. Sources
5.1.1. Understanding the POV-Ray source structure
5.1.2. Creating your own patches
5.2. Binaries
5.2.1. compiling on Windows systems
5.2.2. compiling on Macintosh systems
5.2.3. compiling on Unix systems
5.3. Parser
5.3.1. Adding tokens
5.4. Patterns
5.4.1. Reducing memory usage
5.5. Expressions
5.5.1. Polynomial solver
5.6. Multi-format Documentation with DocBook
5.6.1. Environment for DocBook documentation
5.6.2. Editing DocBook documentation
5.6.3. Converting DocBook documents
6. Appendices
6.1. MegaPOV-Team
6.2. Contribution
6.3. MegaPOV before POV-Ray 3.6
6.3.1. MegaPOV history
6.3.2. Authors of patches in MegaPOV below version 1.0
Index

List of Figures

2.1. Force based environment collisions illustration
2.2. Impact based environment collisions illustration
2.3. Mass-mass collisions illustration
2.4. Mass-face collisions illustration
2.5. Connection-connection collisions illustration
3.1. patch connection numbers

List of Tables

2.1. The following time formatting strings are available:
2.2. HDR image ambient variations
2.3. Exposure influence comparison
2.4. internal sequence
2.5. halton sequence
3.1. MechSim_Show_Grid() variations
3.2. MechSim_Show_Patch() variations
3.3. MechSim_Show_Patch() variations
4.1. Example for high dynamic range of raytraced scene
4.2. Views and illumination maps from the scene
4.3. The illumination maps being used in a scene
6.1. Current MegaPOV-Team Members

List of Examples

2.1. Influence of Frame_Step on generated files
2.2. Using the #set directive
2.3. date function usage
2.4. Using the timer function
2.5. Averaging frames with output_filename function
2.6. Polynomial solver usage
2.7. Conversion from the sor object definition to the sor_spline type in spline
2.8. Alternative forms of user_defined camera type definition
2.9. HDR image example
2.10. Various values for film exposure simulations
2.11. An example for a complete collision{} section:
2.12. Constant downward force in Mechanics simulation
2.13. The simulation data file format
2.14. The internal post process function asking for red color at the middle of image
2.15. Post processing which does nothing (only duplicate the original image)
2.16. Post processing which turns the rendered image into a gray scale image
3.1. MechSim_Show_Objects() macro usage
3.2. MechSim_Show_All_Objects() macro usage
3.3. MechSim_Show_Grid() macro usage
3.4. MechSim_Show_Patch() macro usage
3.5. MechSim_Show_Sphere() macro usage
3.6. MechSim_Generate_Grid_Fn() macro usage
3.7. MechSim_Generate_Grid() macro usage
3.8. MechSim_Generate_Grid_Std() macro usage
3.9. MechSim_Generate_Box() macro usage
3.10. MechSim_Generate_Patch() macro usage
3.11. MechSim_Generate_Patch_Std() macro usage
3.12. MechSim_Generate_Line() macro usage
3.13. MechSim_Generate_Line() macro usage
3.14. MechSim_Generate_Sphere() macro usage
3.15. Find edge macro
5.1. Typical patch markup

Chapter 1. Introduction

1.1. What is MegaPOV?

MegaPOV is a custom and unofficial patched version of POV-Ray™. It is a compilation of separately released patches and techniques released within the POV-Ray™ Community and dedicated work of the MegaPOV-Team.

Many patches from MegaPOV 0.7 were included in official POV-Ray™ 3.5. It will probably not happen often with patches included in MegaPOV 1.0 and later because POV-Ray™ in the future will be rewritten using C++.

1.2. What's new

1.2.1. MegaPOV 1.1 - 8 September 2004

MegaPOV 1.1 is an update to POV-Ray™ 3.6. Development of POV-Ray™ 3.6 took longer than expected so MegaPOV 1.1 was delayed as well. We regret this but on the other hand MegaPOV 1.1 now also comes with some useful new features:

  1. Fur (see Section 2.5.3, “Fur”)
  2. Type checking (see Section 2.2.3.6, “Type checking”)
  3. Measurement of dimensions in vectors (see Section 2.2.3.5, “Dimensions of vectors”)
  4. New spline types:
  5. Sizes of images measurement (see Section 2.2.3.4, “Sizes of images”)
  6. Reduced memory requirements for each object, depending on the type of pattern being used (see Section 5.4.1, “Reducing memory usage”)
  7. HDR (High Dynamic Range) image type from MLPov (see Section 2.6.6, “HDR (High Dynamic Range) image type”)
  8. HDR (High Dynamic Range) image write support (see Section 2.1.2, “HDR (High Dynamic Range) image output”)
  9. Connection-connection collisions for mechsim patch (see Section 2.7.3.1.3, “The collision settings”)
  10. Normal modifier for transforms (see Section 2.2.7.1, “The normal modifier for transforms”)
  11. String function with numbered output filename (see Section 2.2.3.3, “Filename with frame number”)
  12. New user_defined camera projection type (see Section 2.3.1, “user_defined camera type”)
  13. New camera_view pigment type (see Section 2.6.7, “New camera_view pigment”)
  14. Angle of incidence pattern from MLPov (see Section 2.6.1, “Angle of incidence”)
  15. Projection pattern from MLPov (see Section 2.6.3, “Projection pattern”)
  16. Custom radiosity sampling directions (see Section 2.7.2.2, “Custom radiosity sampling directions”)
  17. Randomized radiosity sampling directions (see Section 2.7.2.3, “Randomized radiosity sampling directions”)
  18. Reintroduced motion_blur from MegaPOV 0.7 with new type feature (see Section 2.5.2, “Motion blur”)
  19. New post processing feature (see Section 2.7.4, “Post processing”)
  20. Fixed bug of MegaPOV 1.0 concerning spline identifiers

Some of the patches from MegaPOV 1.0 are now included in the POV-Ray™ 3.6 update, and some have become obsolete because of changes in POV-Ray™ 3.6. The parts concerning these changes have been removed from this manual, because they are no longer considered as "patches". Here is an overview:

  1. Option End_Row with value 1
  2. UV mapping in torus object;
  3. UV mapping in parametric object;
  4. Fix for using splines in function;
  5. Fix for smooth height_field.

1.2.2. Previous versions of MegaPOV

For an overview of the previous versions, (see Section 6.3, “MegaPOV before POV-Ray 3.6”)

1.3. Why should i use MegaPOV?

In case you are new to POV-Ray™ and maybe have not even used the official POV-Ray™ before it is not recommended to use MegaPOV. Instead get the official POV-Ray™ from the POV-Ray™ website.

MegaPOV will be interesting for more advanced POV-Ray™ users who are particularly interested in the additional functionality the patches offer. We try to ensure a relatively high quality of the patches added to MegaPOV but still some of these patches are still under development so you have to expect that not everything will run as smoothly as on official POV-Ray™ and that features will possibly change in future versions.

Some people may wonder why a MegaPOV version is still maintained when most MegaPOV features have been incorporated and improved in POV-Ray™ 3.5. Here are some reasons why:

  • There are already several patched versions of POV-Ray™ 3.5;
  • Many patched versions are only available for a specific platform;
  • You often need to switch between patched versions for different features;
  • The next update of POV-Ray™ will probably take some time;
  • MegaPOV is a public test version. Features which prove to be popular and more or less bug free might get the attention of the POV-Team™ and make it into the next POV-Ray™.

So the MegaPOV-Team collects available patches, tries to merge them into one patch collection and makes it available for the most common platforms.

1.4. Enabling MegaPOV features

MegaPOV features are enabled by using:

#version unofficial megapov 1.1;  // version number may be different

The new features are disabled by default, and only the official version's syntax will be accepted. The above line of POV code must be included in every include file with MegaPOV features as well, not just the main POV file. Once the unofficial features have been enabled, they can be again disabled by using:

#version 3.6;

This is useful to allow backwards compatibility for some features.

1.5. Where do I find MegaPOV?

1.5.1. Sources and binaries

Packages with compiled binaries are available for the most common platforms. They can be obtained at the MegaPOV site where you can also find the source code.


The Mac version with its special user interface is maintained separately on Smellenbergh's site.

1.5.2. Documentation and samples

An online version of the MegaPOV documentation as well as downloadable archives in various formats are located at the MegaPOV site - documentation section.

A preview of the samples coming with MegaPOV can be found in our demo section. The thumbnails there have a link to a larger image (640*480) and an mpeg file in case of animations and some description is available there as well.

[Note]Note

None of the MegaPOV packages includes the official POV-Ray™ documentation, samples and include files although these are essential for using MegaPOV. If you do not already have installed POV-Ray™ you should get the official version from the POV-Ray™ website.

1.5.3. Discussions

We don't maintain our own forum for discussions. MegaPOV is an unofficial patch to POV-Ray™ and the MegaPOV-Team is just part of the POV-Ray™ Community. That's why you can use the povray.unofficial.patches group for discussions related to MegaPOV. You can also use povray.binaries.* and povray.text.* groups to upload files related to MegaPOV. All mentioned groups are located on news.povray.org.

Chapter 2. MegaPOV References

2.1. Options

2.1.1. Frame_Step

Włodzimierz ABX Skiba

The Frame_Step=n (+STPn) option introduces breaks in the order of rendered steps. It splits the order of rendered frames into a 'virtual' and a 'real' order.

'Virtual' order is the same as the traditional (used in POV-Ray™ 3.5) order described with Initial_Frame, Final_Frame, Initial_Clock, Final_Clock, Subset_Start_Frame, Subset_End_Frame. This order is what the scripts reads from initial_frame, clock_delta and other animation related build-in tokens in SDL.

'Real' order is a subset of 'virtual' order. It is every n-th frame where n is the value of Frame_Step. Selected frames are reordered (with ascending or descending order) according to the sign of Frame_Step option.

Frame_Step is supposed to use parallel rendering over one source with one location shared between instances of renderer.

Example 2.1. Influence of Frame_Step on generated files

The following command line:

megapov +Iscene.pov Initial_Frame=1 Final_Frame=5 +FN

causes the creation of files in such order:

scene1.png
scene2.png
scene3.png
scene4.png
scene5.png

while when using Frame_Step:

megapov +Iscene.pov Initial_Frame=1 Final_Frame=5 +FN Frame_Step=-2

causes a subset of it in the following order:

scene5.png
scene3.png
scene1.png

[Important]Important

Frame_Step different than 1 works fine for those animations where variables are not passed between frames when using external files and where the next frame does not use values derived from a previous (in the meaning of virtual order) frame by other ways.

2.1.2. HDR (High Dynamic Range) image output

Christoph Hormann

Apart from reading HDR images as image maps (see Section 2.6.6, “HDR (High Dynamic Range) image type”) MegaPOV also supports this file format for image output. Further information on this file format can be found in Section 2.6.6, “HDR (High Dynamic Range) image type” as well.

The file format identification character is H. Writing this file format is activated by the command line option

+FH

or the ini option

Output_File_Type=H

2.2. Expressions

2.2.1. Language directives

2.2.1.1. Set directive

Chris Huff

The #set keyword modifies the most recently created version of a variable. So, if a variable has been created previously with either #declare or #local, its value can be changed with the #set directive.

Example 2.2. Using the #set directive

#declare MyCounter = 0:
#set MyCounter = MyCounter + 1;

One advantage is that it makes it more visually clear where variables are 'created', and where they are only 'changed'.

Another advantage is that if you try to change a variable that doesn't yet exist, it produces an error. This could happen if you make a typing mistake, like this:

#declare MyCounter = 0;
#while (MyCounter < 10)
  #declare MyCountr = MyCounter+1;
#end

This would normally cause an infinite loop, and may take a while to track down, especially in complex scenes and with typos that "look right" at a glance. If #set was used, it would cause an error ("#set cannot assign to uninitialized identifier MyCountr.") at that line, pointing you directly at the problem.

2.2.2. Built-in tokens

2.2.2.1. Additional tokens in function syntax

Włodzimierz ABX Skiba

POV-Ray™ 3.5 in its official release does not accept all built-in constants and variables to be used in functions. Following tokens are recognized additionally in VM since MegaPOV 1.0: clock_delta, clock_on, false, final_clock, final_frame, frame_number, initial_clock, initial_frame, image_height, image_width, no, off, on, true, version, yes . All mentioned tokens return the same values as in the whole SDL parser.

2.2.2.2. frame_step key-word

Włodzimierz ABX Skiba

As other animation options, also Frame_Step has its own equivalent in SDL. You can use the frame_step key-word to get the value which was passed to Frame_Step (see Section 2.1.1, “Frame_Step”). Default value is 1.

2.2.3. Functions

2.2.3.1. Time and date functions

Yvo Smellenbergh

With the keyword date, time and/or a date can be used in your images. This might be useful in a macro to place a time stamp in your images, along with your name. The keyword date works like other string functions, except that you have to supply a format string.

Example 2.3. date function usage

Suppose it's Saturday 1 January. The following script:

#declare TheString=date("%a %B")

will return the string: Sat January

The most flexible implementation was chosen (which is probably not the easiest ...) because not all countries write dates in the same way. Just think of the difference between the USA and most parts of Europe. These are the possible specifiers for the format string: Please note that these should be equal for all platforms but if you don't get the expected result, contact the person who compiled your version to find out if there are differences.

Table 2.1. The following time formatting strings are available:

a Abbreviated weekday name.
AFull weekday name.
bAbbreviated month name.
BFull month name.
cThe strftime() format equaling the format string of "%x %X".
dDay of the month as a decimal number.
HThe hour (24-hour clock) as a decimal number from 00 to 23.
IThe hour (12-hour clock) as a decimal number from 01 to 12
jThe day of the year as a decimal number from 001 to 366
mThe month as a decimal number from 01 to 12.
MThe minute as a decimal number from 00 to 59.
p"AM" or "PM".
SThe seconds as a decimal number from 00 to 59.
UThe week number of the year as a decimal number from 00 to 52. Sunday is considered the first day of the week.
wThe weekday as a decimal number from 0 to 6. Sunday is (0) zero.
WThe week of the year as a decimal number from 00 to 51. Monday is the first day of the week.
xThe date representation of the current locale.
XThe time representation of the current locale.
yThe last two digits of the year as a decimal number.
YThe century as a decimal number.
zThe time zone name or nothing if it is unknown.
%  The percent sign is displayed.

[Note]Note:

To use the '%' character in the result, use it twice: date("%%")

Refer to date.pov for an example scene. Please note that you might have to write the result in a file if you want to abort the rendering and continue later on. Otherwise you could get a different result because time goes on :-)

2.2.3.2. Timer function

Yvo Smellenbergh

The keyword start_chrono sets an internal variable and returns the current internal clock counter of your computer. The return value is not important. However, you must assign this return value from start_chrono otherwise you get an error. Use it like this:

#declare Stopwatch = start_chrono;

or use it like this:

#if (start_chrono)

but not:

start_chrono //parsing stops with a fatal error

The keyword current_chrono returns the time in full seconds (no fractions of seconds) between start_chrono and current_chrono. The start value is not changed. A second current_chrono will still return the seconds between start_chrono and the second current_chrono.


If you don't call start_chrono somewhere before you call current_chrono, you will get the seconds elapsed since the beginning of the current render (parsing).

Example 2.4. Using the timer function

//reset the chrono and return the internal clock counter
#declare ParseStart = start_chrono; 

... syntax to be parsed

//read the seconds elapsed since chrono_start
#declare ParseEnd = current_chrono;
#debug concat("\nParsing took ",str((ParseEnd, 1, 0)," seconds\n")

Refer to chrono.pov for a demo scene.

2.2.3.3. Filename with frame number

Włodzimierz ABX Skiba

Some animators want to use filenames of previous, already rendered frames to average them to mimic motion_blur in one turn. But the concatenation of filename with frame number is not a trivial thing and can be platform dependant. MegaPOV allows you to get n-th filename of current animation. For stills it always returns filename without numbers.

Syntax is:

#declare File_Name=output_filename(Frame_Number)

Example 2.5. Averaging frames with output_filename function

You can force every 10th frame to be averaged content of previous nine frames, this way:

#if(mod(frame_number,10)=9)
  #declare Averaged_Frames=pigment{
    average
    #local Counter=1;
    #while(Counter<10)
      [1 image_map{output_filename(frame_number-Counter)}]
      #set Counter=Counter+1;
    #end
  }
  // placing of pigment in output area
#else
  // conventional scene
#end

2.2.3.4. Sizes of images

Włodzimierz ABX Skiba

You probably already know that the image_width and image_height keywords return the sizes of a rendered image. But there are cases when you would like to change the content of a scene depending on the sizes of the images used for maps. For this purpose the image_width and image_height keywords are extended with an optional parameter which is the identifier of an item using an image.

Syntax is:

#declare Identifier=image_width [ (ITEM_WITH_IMAGE) ];
#declare Identifier=image_height [ (ITEM_WITH_IMAGE) ];

ITEM_WITH_IMAGE: PIGMENT_ID | NORMAL_ID | TEXTURE_ID

2.2.3.5. Dimensions of vectors

Włodzimierz ABX Skiba

The usage of the dimension_size is extended since MegaPOV 1.1 with a measurement of floats, vectors and colors. If you want to write a universal script which works differently depending on the number of components in an identifier, you can use the dimension_size to get 1,2,3,4 or 5 as number of the components in the given identifier.

Syntax is:

#declare Identifier=dimension_size ( FLOAT | VECTOR | COLOR );

2.2.3.6. Type checking

Włodzimierz ABX Skiba

MegaPOV 1.1 allows the verification of the type (and in some cases subtypes) of identifiers. It is possible thanks to the is function which tests the internal type of an identifier.

Syntax is:

#declare Identifier=is ( IDENTIFIER , TYPE | SUBTYPE );

TYPE: array | camera | color | 
      color_map | density | density_map | 
      finish | float | fog | 
      function | interior | light_source | 
      material | media | normal | 
      normal_map | object | pigment | 
      pigment_map | rainbow | sky_sphere | 
      slope_map | spline | string | 
      texture | texture_map | transform | 
      vector

SUBTYPE: SPLINE_TYPE | OBJECT_TYPE | CAMERA_TYPE

SPLINE_TYPE: akima_spline | basic_x_spline | 
             cubic_spline | extended_x_spline | 
             general_x_spline | linear_spline | 
             natural_spline | quadratic_spline | 
             sor_spline | tcb_spline 

OBJECT_TYPE: bicubic_patch | blob | box | 
             cone | cubic | cylinder | 
             disc | height_field | intersection | 
             isosurface | julia_fractal | lathe | 
             merge | mesh | parametric | 
             plane | poly | polygon | 
             prism | quadric | quartic | 
             smooth_triangle | sor | sphere | 
             sphere_sweep | superellipsoid | text | 
             torus | triangle | union

CAMERA_TYPE: cylinder | fisheye | omnimax | 
             orthographic | panoramic | perspective | 
             spherical | ultra_wide_angle | user_defined

[Important]Important

Internally mesh2 is stored as mesh. Similar difference is stored as intersection.

An example using the is keyword can be found in the mp_types.inc include file (see Section 3.3, “The 'mp_types.inc' include file”).

2.2.4. Internal functions

MegaPOV delivers new pre-defined functions. These new internal functions can be accessed through the mp_functions.inc include file, so it should be included in your scene to make use of them.

2.2.4.1. f_triangle

Włodzimierz ABX Skiba

f_triangle function has 10 parameters:

FLOAT f_triangle(FLOAT V1x, FLOAT V1y, FLOAT V1z, FLOAT V2x, FLOAT V2y, FLOAT V2z, FLOAT V3x, FLOAT V3y, FLOAT V3z, FLOAT Thickness);

The parameters V1x, V1y, V1z describe the coordinates of the first vertex in the triangle.


The parameters V2x, V2y, V2z describe the coordinates of the second vertex in the triangle.


The parameters V3x, V3y, V3z describe the coordinates of the third vertex in the triangle.


The parameter Thickness describes how thick the triangle is.

[Note]Note

In order to achieve the fastest calculation, try to pass the parameters so that the side V1-V2 represents the longest side and V1-V3 represents the shortest side.

2.2.5. Polynomial solver in parser

Włodzimierz ABX Skiba

The polynomial solver is accessible from scripts via the float functions n_roots and nth_root with the following syntax:

INT n_roots(FLOAT an, ..., FLOAT a0, BOOL sturm_flag, FLOAT epsilon);

FLOAT nth_root(FLOAT nth, FLOAT an, ..., FLOAT a0, BOOL sturm_flag, FLOAT epsilon);

n_roots returns the number of roots derived from the polynomial given by the parameters an, ..., a0 and calculated under the conditions specified by the parameters sturm_flag and epsilon.

nth_root returns the value of the nth root of a given polynomial.

The sturm flag turns on a different algorithm of calculation. Its usage influences the number of returned roots. Epsilon (positive) value means that the roots below Epsilon value are ignored. Epsilon=0 means that none of the roots are ignored.

[Important]Important

You don't have to call n_roots before nth_root, but if you do call nth_root with the wrong root number then it causes an error and breaks parsing. It is better to call n_roots first to verify the number of available roots.

Example 2.6. Polynomial solver usage

Imagine that we have x3+6*x2-x-6 and that we are interested in its roots for further calculations. So if we declare:

#declare N=n_roots(1, 6, -1, -6, off, 0);

then N has value 3 because the mentioned equation has 3 roots. If we are interested in what roots it has, we can use the following calls:

#declare R0=nth_root(0, 1, 6, -1, -6, off, 0);
#declare R1=nth_root(1, 1, 6, -1, -6, off, 0);
#declare R2=nth_root(2, 1, 6, -1, -6, off, 0);

And it returns R0=-6, R1=1 and R2=-1. So finally we know that x3+6*x2-x-6=(x+6)*(x-1)*(x+1) .

2.2.6. Splines

2.2.6.1. spline follows sor

Włodzimierz ABX Skiba

Splines in POV-Ray™ can be used to create objects through rotation, translation or by being a border of a surface. Usually it is hard to match those surfaces with calculations developed in SDL because they are mostly hard-coded within the source core code of POV-Ray™. The spline feature introduced in POV-Ray™ 3.5 makes such operations much easier but some spline types are still missing. sor_spline is introduced to access the surface of the sor object in SDL.

To use the data from the sor object in a sor_spline, the order of coordinates has to be changed. The old y coordinate is now the clock value in the spline. The advantage is that one sor_spline can hold data from five old sor-s. That's because every spline can operate up to five dimensions along the clock value.

Example 2.7. Conversion from the sor object definition to the sor_spline type in spline

spline{
   sor_spline
  -1.000000,0.000000*x
   0.000000,0.118143*x
   0.540084,0.620253*x
   0.827004,0.210970*x
   0.962025,0.194093*x
   1.000000,0.286920*x
   1.033755,0.468354*x
}

sor{
  7
  <0.000000, -1.000000>
  <0.118143,  0.000000>
  <0.620253,  0.540084>
  <0.210970,  0.827004>
  <0.194093,  0.962025>
  <0.286920,  1.000000>
  <0.468354,  1.033755>
}

2.2.6.2. akima spline

Włodzimierz ABX Skiba

An akima_spline is a spline that goes smoothly (pleasingly for some) through all points. ACM Press abstracts original work of Hiroshi Akima:

 

This method is devised in such a way that the resultant curve will pass through the given points and will appear smooth and natural. It is based on a piecewise function composed of a set of polynomials, each of degree three, at most, and applicable to successive intervals of the given points. In this method, the slope of the curve is determined at each given point locally, and each polynomial representing a portion of the curve between a pair of given points is determined by the coordinates of and the slopes at the points. Comparison indicates that the curve obtained by this new method is closer to a manually drawn curve than those drawn by other mathematical methods.

 
--The Guide to Computing Literature. 

Syntax is:

spline {
  akima_spline
  time_Val_1, <Vector_1> [,]
  time_Val_2, <Vector_2> [,]
    ...
  time_Val_n, <Vector_n>
}

2.2.6.3. tcb spline

Włodzimierz ABX Skiba

This spline is also known as Kochanek-Bartels spline.

Syntax is:

spline {
  tcb_spline [TCB_PARAMETERS]
  time_Val_1 [TCB_PARAMETERS], <Vector_1> [TCB_PARAMETERS][,]
  time_Val_2 [TCB_PARAMETERS], <Vector_2> [TCB_PARAMETERS][,]
    ...
  time_Val_n [TCB_PARAMETERS], <Vector_n> [TCB_PARAMETERS]
}

TCB_PARAMETERS:
  [tension FLOAT] [continuity FLOAT] [bias FLOAT]

The tension, continuity and bias are fully optional. Depending on the place where they appear, they control the spline in different ways:

  • Placed right after the tcb_spline keyword, they set the default values for all ends of the spline segments. This placement is ignored in case of copying spline without adding new controls because previous defaults were already propagated to each side of control points.
  • Placed between the time_value and the corresponding vector, the tcb parameters determine the properties of the spline segment ending in the vector that follows these parameters.
  • For tcb parameters following a vector, the properties of the spline segment beginning after this vector are set.

What is controlled by these parameters?

  • tension controls how sharply the curve bends.
  • continuity controls how rapid speed and direction change.
  • bias controls the direction of the curve as it passes through the control point.

[Note]Note
A tcb_spline needs additional control points before and after the spline. This is required to control the first and last segment of the spline.

2.2.6.4. x splines

A very nice property of x splines is that they can go through a control point as well as just approximate it.

2.2.6.4.1. basic x spline

Włodzimierz ABX Skiba

Syntax is:

spline {
  basic_x_spline [freedom_degree FLOAT]
  time_Val_1, <Vector_1> [,]
  time_Val_2, <Vector_2> [,]
  ...
  time_Val_n, <Vector_n>
}

[Note]Note
A basic_x_spline needs additional control points before and after the spline. This is required to control the first and last segment of the spline.

2.2.6.4.2. extended x spline

Włodzimierz ABX Skiba

The extended_x_spline offers the possibility to mix smooth curves and sharp edges in an unrestricted way in one spline.

Syntax is:

spline {
  extended_x_spline [freedom_degree FLOAT]
  time_Val_1, <Vector_1> [freedom_degree FLOAT ][,]
  time_Val_2, <Vector_2> [freedom_degree FLOAT ][,]
  ...
  time_Val_n, <Vector_n> [freedom_degree FLOAT ]
}
2.2.6.4.3. general x spline

Włodzimierz ABX Skiba

Syntax is:

spline {
  general_x_spline [freedom_degree FLOAT]
  time_Val_1, <Vector_1> [freedom_degree FLOAT ][,]
  time_Val_2, <Vector_2> [freedom_degree FLOAT ][,]
  ...
  time_Val_n, <Vector_n> [freedom_degree FLOAT ]
}

2.2.6.5. Spline accessed like array

Włodzimierz ABX Skiba

Since MegaPOV 1.0 it is possible to read values stored in a spline with a notation similar to an array. Previously once the spline was declared, it was only possible to evaluate it for a specified argument. Now two new usages are possible: you can get the number of entries and read the exact values placed in splines.

SPLINE_USAGE:
  SPLINE_EVALUATION | SPLINE_MEASUREMENT | SPLINE_ENTRY

SPLINE_EVALUATION:
  #declare Spline_Value = MySpline(Val);
  #declare Spline_Value = MySpline(Val, SPLINE_TYPE);

SPLINE_MEASUREMENT:
  #declare Number_Of_Entries = dimension_size( MySpline );

SPLINE_ENTRY:
  #declare Float_Time_Parameter = MySpline[ Counter ][ 0 ];
  #declare Vector_Value_Of_Entry = MySpline[ Counter ][ 1 ];

2.2.7. Transforms

2.2.7.1. The normal modifier for transforms

Christoph Hormann

This patch adds a new option to the transform syntax that modifies the transform to be suited for transforming normal vectors.

When a mesh is transformed by the transformation matrix M the normals need to be transformed with the transpose of the inverse of M. This is handled automatically by this patch.

Syntax is:

transform {
  ...
  normal on|off
}

The default value is off so you get a standard transform.

2.3. Camera

2.3.1. user_defined camera type

Włodzimierz ABX Skiba

Instead of patching POV-Ray™ with new camera types MegaPOV provides a tool to define any projection type directly inside the scene scripts. This tool is named user_defined camera type. It allows starting camera rays from any point in any direction. Both the location and direction of rays is specified as a set of three functions or as one pigment.

Syntax is:

camera {
  user_defined
  location { FUNCTION_VECTOR }
  direction { FUNCTION_VECTOR }
}

FUNCTION_VECTOR:
  PIGMENT | 3_USER_DEFINED_FUNCTIONS ...

3_USER_DEFINED_FUNCTIONS:
  USER_DEFINED_FUNCTION
  USER_DEFINED_FUNCTION
  USER_DEFINED_FUNCTION

In the case of 3 functions used to define location or direction, please remember that those functions operate on screen coordinates (u and v) in the area <0,0>-<1,1> so that they are independent of the image resolution. If you want to convert the value from the range 0-1 to the range 0-image_width or 0-image_height you can use the function adj_range from the math.inc include file.

In the case of a pigment used to define location or direction, please remember that the values of the pigment are taken from the area <0,0,0>-<1,1,0>.

Example 2.8. Alternative forms of user_defined camera type definition

Let's imagine we want to recreate the orthographic camera using a user_defined camera:

camera{
  orthographic
  location <.5,.5,0>
  direction z
  up y
  right x
}

Written as a set of functions it would be:

camera{
  user_defined
  location{
    function{u}
    function{v}
    function{0}
  }
  direction{
    function{0}
    function{0}
    function{1}
  }
}

Defined with pigments it would be:

camera{
  user_defined
  location{
    pigment{
      gradient x
      pigment_map{
        [0 gradient y color_map{[0 rgb 0][1 rgb x]}]
        [1 gradient y color_map{[0 rgb y][1 rgb x+y]}]
      }
    }
  }
  direction{
    pigment{rgb z}
  }
}

Of course if it can make the script shorter, you can mix notations. You can use both functions and pigments in one camera definition:

camera{
  user_defined
  location{
    function{u}
    function{v}
    function{0}
  }
  direction{
    pigment{rgb z}
  }
}

2.4. Objects

2.4.1. Common features

2.4.1.1. Bounding used in inside tests

Micha Riser

With MegaPOV, in every test using Inside of objects the bounding object has now priority. It first tests if the point is inside the bounding. If it is not then it knows that it can already decide that the point is outside (if the object is not inversed) or that the point is inside (if the object is inversed).

This should increase rendering speed of complicated CSG objects, since it could eliminate a lot of computing steps. The inside test is firstly done for the bounding object. Only when this test is inside the bounding, the tests against each of the objects composing the CSG object will be done.

2.4.2. Text

2.4.2.1. Text enhancements

Yvo & René Smellenbergh

Based on the text enhancement idea of Jamis Buck and Noel Bundy, but modified and extended.

Syntax is:

text {
  the usual text stuff
  ...
  [ h_align_left | h_align_center | h_align_right ]
  [ v_align_top | v_align_center | v_align_bottom ]
}

h_align_left By adding this keyword to the text block, the text string (including horizontal offset) is aligned horizontally so that its most left point touches the y-axis. This is identical to the default alignment.

h_align_center By adding this keyword to the text block, the text string (including horizontal offset) is aligned horizontally so that it extends equally on both sides of the y-axis.

h_align_right By adding this keyword to the text block, the text string (including horizontal offset) is aligned horizontally so that its most right point touches the y-axis.

v_align_top By adding this keyword to the text block, the text string (including vertical offset) is aligned vertically so that its highest point touches the x-axis.

v_align_center By adding this keyword to the text block, the text string (including vertical offset) is aligned vertically so that its middle height sits on the x-axis.

v_align_bottom By adding this keyword to the text block, the text string (including vertical offset) is aligned vertically so that its lowest point sits on the x-axis.

[Note]Note

When no alignment is specified, the POV-Ray™ defaults are used. Horizontally to the left and vertically on the base line.

The old keyword "position" of previous MegaPOV versions is no longer supported.

2.4.3. Cloth simulation

Christophe Bouffartigue

simcloth allows to simulate cloth in MegaPOV. The cloth patch is rectangular, and interacts with its environment (gravity, some obstructing objects, wind, ...).

Syntax is:

  simcloth {
    [ environment OBJECT-IDENTIFIER ]
    [ friction FLOAT ]
    [ gravity VECTOR ]
    [ wind { PIGMENT } ]
    [ viscosity FLOAT ]
    [ neighbors 0 | 1 ]
    [ internal_collision on | off ]
    [ damping FLOAT ]
    [ intervals FLOAT ]
    [ iterations INTEGER ]
    input STRING
    [ output STRING ]
    [ mesh_output STRING ]
    [ smooth_mesh on | off ]
    [ uv_mesh on | off ]
  }

environment is followed by an object identifier. The object should be declared before simcloth {}. This object defines the environment that will interact with the cloth. Although any object can be used, it is recommended to use objects which have well-defined interiors.

friction is a coefficient specifying energy loss when the cloth touches the environment. A low value (<= 0) means a lot of friction and strongly slows the movement of the cloth. A high value (>= 1) will allow the cloth to slide over the objects (but not to bounce off ...). Default value is 1.0

gravity Specifies the direction and the strength of gravity. The default value is <0, 0, 0>.

wind A pigment is used to define the direction and strength of the wind in every space location. At a given point, the wind is defined by the red, green and blue components of the pigment at this point. You can explicitly declare the pigment, or use an already declared identifier. Don't forget that the color components can take any value you want (negative ones, greater than one, ...)

viscosity Specifies the influence of the wind and air friction on the cloth. The default value is 0 (no influence).

neighbors Specifies the number of neighbors that are joined by springs at each point. neighbors 0 is for 8 neighbors (faster but rougher calculation), and neighbors 1 (default value) is for 24 neighbors (slower calculation, but better results).

internal_collision Activates or deactivates internal collision management (cloth against itself). This problem is handled by added springs between points that are too close together. System instability probability is increased, and you must, most often, decrease the intervals parameter (see below). Deactivated by default (warning: much longer parsing when activated).

damping General energy loss parameter, it limits the accumulation of the model approximations and errors. A value lower than 0.95 (default value) is strongly recommended.

intervals specifies the time interval between each iteration. Keep it low. Default value is 0.05.

iterations It's the number of iterations to calculate.

input Filename of the starting *.cth file. The only required parameter, since you need a cloth to start with. For a complete description of the *.cth file format, see below.

output Filename of the ending *.cth file. If this parameter is specified, the result of the simulation is saved. Useful for animations, or for a multi-stage calculation.

mesh_output Allow the program to output a file (with specified name), containing tons of triangles, corresponding to the cloth points after the simulation. It allows you to save the result of a simulation, in a format usable by other POV-Ray™ versions (official or unofficial).

smooth_mesh Activate or deactivate the creation of smooth_triangle's if the mesh_output option is activated. Deactivated by default.

uv_mesh Activates or deactivates uv coordinates within the triangle (or smooth_triangle) if the mesh_output option is activated. UV coordinates go from <0, 0> to <1, 1>. Deactivated by default.

2.4.3.1. Description of the .cth file format:

The file format is simple: the first line describes the cloth dimensions (number of points n1 and n2, normalized length between 2 neighbors nlng), and the springs strength ks. The other lines describe the location in space and velocity of each point. All values (3 for location, 3 for speed) are separated by commas, and each line is terminated by a comma as well.

Then, there are the constraints definitions. Constraints are 3 coefficients (1 for each axis) that will control the velocity vector of a given point of the cloth. It will be possible, for instance, to slow down a corner of the cloth along one axis, to completely stop it along another axis, and let it free along the last one. A constraint is defined by an integer (index), and 3 floating point coefficients, representing the constraint (respectively on x, y, z axis), all this on the same line and separated by commas. The index is the rank of the point (beginning at 0) in order of declaration of the cloth points. Constraints can be declared in any order.

You could see the cloth as 2 arrays of vectors Points[n1][n2], and Velocity[n1][n2], and its constraints Indexn, coefn. The *.cth file will look like this:

n1, n2, nlng, ks,
Points[0][0], Velocity[0][0],
Points[0][1], Velocity[0][1],
...
Points[0][n2-1], Velocity[0][n2-1],
Points[1][0], Velocity[1][0],
Points[1][1], Velocity[1][1],
...
Points[1][n2-1], Velocity[1][n2-1],
Points[2][0], Velocity[2][0],
...
...
Points[n1-1][n2-1], Velocity[n1-1][n2-1],
Index1, coef1[x], coef1[y], coef1[z],
Index2, coef2[x], coef2[y], coef2[z],
Index3, coef3[x], coef3[y], coef3[z],

For an example of a macro writing such a file (see Section 4.1.1.1.1, “Writing a *.cth file”).

2.4.4. Isosurface

2.4.4.1. Control of max gradient message

Yvo & René Smellenbergh

In POV-Ray™ 3.5 the messages concerning the max_gradient follow a heuristic method to be displayed. This means that the message only appears when the difference with the set max_gradient is more than a certain percentage. Also when using a loop with hundreds of isosurfaces which have different max_gradient's, you need to wait after the render for all those messages to be displayed: this can take several minutes. Basically, you cannot control these messages.

In MegaPOV 1.0 you can use the keyword message to control the message flow:

  • message on will always show all max_gradient messages
  • message off will never show a max_gradient message
  • without a message keyword the default heuristic method will be used

This keyword is used in the isosurface{} block and should be used after the function{} block and before any material.

By using conditional expressions, you can now control messages in a loop.

2.5. Effects

2.5.1. Glow

Chris Huff

This atmospheric glow effect makes a fast-rendering glow effect. It is based on the light source glow effect from POV-AFX, written by Marcos Fajardo, but has been heavily modified.

Syntax is:

glow {
  type 0 | 1 | 2 | 3
  location VECTOR
  size FLOAT
  radius FLOAT
  fade_power FLOAT
  color COLOR
  TRANSFORMATIONS
}

You can specify glows individually, or attached to a light_source. If created in a light source, they will be automatically initialized with the light's position and color (though transforming the light source will not give the expected result).

Choose a glow type from 0, 1, 2 or 3. Type 2 and 3 glows are not completely implemented yet, but 2 will be based on the exp() function and 3 will simulate a sphere with constant density.

The size keyword adjusts the scale of the glow effect. It is not an absolute size, just a scaling amount (because some glows are infinite). It does not quite work properly yet, it causes strange effects with changing distances of objects behind the glow.

The radius keyword specifies a clipping radius confining the glow to a circular area perpendicular to the ray. If the glow is still visible at this radius, it will make a sudden transition.

The fade_power keyword allows you to provide an exponent to adjust the falloff with.

[Note]Note

A glow is not an object, it is an atmospheric effect. Therefore glows cannot be used in CSG operations.

Transformations on a glow only affect the location vector. So will scale not change the size or shape of a glow, but scale the location coordinates.

2.5.2. Motion blur

Nathan Kopp

A motion_blur object is created by averaging many transformed copies of that object. Because only part of the image has to go through some extra calculations, this internal motion blur is usually faster than averaging whole images with an external program.

This patch only does per-object motion blur. The camera cannot be blurred using this method.

Also lights can be blurred using this method: the performance is comparable to the performance of area lights.

To initialize motion blur, add the following to your global_settings block:

  global_settings {
    motion_blur SAMPLES, SHUTTER-TIME
  }

SAMPLES is the number of time-frames that will be sampled. More samples will give smoother results, but will take longer to render.

SHUTTER-TIME is the amount of time the shutter is open in POV-clock units. Depending on the specified type, this time interval will be centered around, or added to the clock value for the current frame.

[Note]Note

Especially in animations it will give more natural results when this value is kept close to the clock_delta value. You could #declare Shutter_time = clock_delta*Small_factor;

To create a Motion Blur object, use the following syntax:

  motion_blur {
    type 0 | 1
    OBJECT | LIGHT-SOURCE
    OBJECT-MODIFIERS
  }

Type 0 will oscillate the motion blur around the current clock value. Half of the SHUTTER-TIME value is subtracted from, the other half added to that clock value. Type 0 is the default.

Type 1 will add the full SHUTTER-TIME value to the current clock value.

Motion blur is triggered by the keyword clock. Any modifier in the motion_blur block that contains the clock keyword will show a blurring effect on that modifier.

Example:

  motion_blur {
    sphere { 0, 1  material { My_material rotate x*clock}}
    translate x*clock
  }

Here the clock keyword within the material will trigger a rotational blurring of this material and the clock keyword within the motion_blur block will trigger a motion blur in the translation of the sphere.

[Note]Note

A motion_blur object contains many copies of the blurred object (one copy for each time sample). For this reason, adding this kind of motion blur can use a lot of memory. Be careful of this. (Remember that multiple copies of mesh objects do not use much memory, though.)

[Important]Important

The blurring is achieved by parsing the contents of the motion_blur object (everything between the curly braces) many times (once for each time sample). Anything outside of the motion_blur block is only parsed once. This means that only one copy gets created of any item declared outside the blur object. And this static copy is applied to each copy of the motion-blurred object.

2.5.3. Fur

Thomas Willhalm

The fur patch extends media to generate faked three dimensional fur. This is done by "filling" a media container with a new scattering type 6. The light is scattered inside the container approximately like a lot of hairs would scatter them. Furthermore, the density is varied between dense regions ("Here is a hair.") and sparse regions ("Space between the hairs").

The syntax is:

scattering { 6, COLOUR
	[ structure { OBJECT_TYPE } ]
	[ ratio FLOAT ]
	[ falloff FLOAT ]
	[ frequency FLOAT ]
	[ diffuse FLOAT ]
	[ reflection FLOAT ]
	[ reflection_exponent FLOAT ]
	[ force VECTOR ]
	[ waves FLOAT ]
	[ pigment PIGMENT ]
}

OBJECT_TYPE:
  sphere { VECTOR, FLOAT } |
  torus { FLOAT, FLOAT } |
  box { VECTOR, VECTOR } |
  cylinder { VECTOR, VECTOR, FLOAT } |
  cone { VECTOR, VECTOR, FLOAT } |
  plane { VECTOR, FLOAT } |
  smooth_triangle { VECTOR, VECTOR, VECTOR, VECTOR, VECTOR, VECTOR }

In order to simulate fur, we need a structure to which we attach the hairs. The structure provides the positions and directions in which the hairs grow. The possible object types sphere, torus, box, cylinder, cone, plane, and smooth_triangle and their respective parameters are known from POV-Ray™. Remark however, that the provided structure is not necessarily tied to the type of container you use. You are free to fill a (complicated) container with a different (approximating) structure. The default structure is a sphere at the origin with radius 1.

With the next three parameters you can influence the way hairs are grown. The ratio is the ratio between hairs and empty space (default: 0.3). The falloff value describes how fast the density changes from dense (hair) to sparse (space). It you change the default value 0.9, you can create sharper hairs or more fluffy fur. The frequency (default 200.0) determines the scale of the fur (lots of thin hairs vs. fewer thicker hairs).

The next three parameters describe how light is reflected in the media. The diffuse component is similar to the diffuse reflection in usual textures. The default value however is 5.0. The reflection component creates highlights on the hairs. The default reflection is 1.0. The appearance of the reflection can be modified by the reflection_exponent varying from bright spots to soft areas. The default exponent is 1.0.

With the parameter force you can simulate a force pulling the hairs in one direction. Applications include gravity and wind. The vector that you provide determines the direction and the strength of the force.

Curly fur can be created by setting the parameter waves. The larger this parameter is, the bigger the turbulence of the hairs.

Last but not least the fur patch provides a convenient way of setting a pigment of the fur. If you're modelling a tiger or a cow, you can realize the colors by using pigment. The default value is the usual colour of the media. Using a pigment overrides this colour.

2.6. Textures and patterns

2.6.1. Angle of incidence

Mael

The value returned by this pattern is proportional to the angle between a certain ray and the (perturbed) normal at the surface of the object. The range of returned values goes from 0 to 1.

Syntax is:

pigment { aoi [ POINT ] }

When no POINT is given, the incident ray of rendering is used. This is not necessarily the ray coming from the camera, it can also be a secondary ray from reflection or refraction effects.

[Note]Note

With this option and without reflection and refraction, the range of return values on the visible surfaces goes from 0 to 0.5 since the angle between ray and normal can only be less than 90 degrees

When a POINT is specified, the reference ray for measuring the angle will be the ray between this specified point and the intersection point on the object.

[Important]Important

This pattern can only be used in situations where the intersection information of the rendering process is available. This applies for usage in pigments, textures and normals but not in media densities or functions.

2.6.2. Listed pattern

Chris Huff

Syntax is:

pigment {
  listed FLOAT
  color_map { color_map stuff } } |
  pigment_map { pigment_map stuff } }
}

normal {
  listed FLOAT
  normal_map { normal_map stuff } }
}

This "pattern" is simply a solid pattern, the value of FLOAT is used as the return value of the pattern. This means that the pattern listed at the specified FLOAT value is used as the pattern for the whole object.

This is very useful in having a progression of objects blending from one texture to another, and can also be useful in animating textures.

2.6.3. Projection pattern

Mael

In this pattern the pattern value is determined by shooting a ray in a certain direction. When this ray hits a specified object it returns 1, if not it returns 0. There are a few options to specify the direction of this ray.

Syntax is: