Section 6.2.6.4
Anti-Aliasing Options

Antialias=boolTurns anti-aliasing on/off
+ATurns aa on with threshold 0.3 or previous amount
-ATurns anti-aliasing off
Sampling_Method=nSets aa-sampling method (1 or 2)
+AMnSame as Sampling_Method=n
Antialias_Threshold=n.nSets anti-aliasing threshold
+An.nSets aa on with aa-threshold at n.n
-An.nSets aa off (aa-threshold n.n in future)
Jitter=boolSets aa-jitter on/off
+JSets aa-jitter on with 1.0 or previous amount
-JSets aa-jitter off
Jitter_Amount=n.nSets aa-jitter amount to n.n. If n.n <= 0 aa-jitter is set off
+Jn.nSets aa-jitter on; jitter amount to n.n. If n.n <= 0 aa-jitter is set off
-Jn.nSets aa-jitter off (jitter amount n.n in future)
Antialias_Depth=nSets aa-depth (1 <= n <= 9)
+RnSame as Antialias_Depth=n

The ray-tracing process is in effect a discrete, digital sampling of the image with typically one sample per pixel. Such sampling can introduce a variety of errors. This includes a jagged, stair-step appearance in sloping or curved lines, a broken look for thin lines, moire patterns of interference and lost detail or missing objects, which are so small they reside between adjacent pixels. The effect that is responsible for those errors is called aliasing.

Anti-aliasing is any technique used to help eliminate such errors or to reduce the negative impact they have on the image. In general, anti-aliasing makes the ray-traced image look smoother. The Antialias=on option or +A switch turns on POV-Ray's anti-aliasing system.

When anti-aliasing is turned on, POV-Ray attempts to reduce the errors by shooting more than one viewing ray into each pixel and averaging the results to determine the pixel's apparent color. This technique is called super-sampling and can improve the appearance of the final image but it drastically increases the time required to render a scene since many more calculations have to be done.

POV-Ray gives you the option to use one of two alternate super-sampling methods. The Sampling_Method=n option or +AMn switch selects non-adaptive super-sampling (method 1) or adaptive super-sampling (method 2). Selecting one of those methods does not turn anti-aliasing on. This has to be done by using the +A command line switch or Antialias=on option.

In the default, non-adaptive method (+AM1), POV-Ray initially traces one ray per pixel. If the color of a pixel differs from its neighbors (to the left or above) by more than a threshold value then the pixel is super-sampled by shooting a given, fixed number of additional rays. The default threshold is 0.3 but it may be changed using the Antialias_Threshold=n.n option. When the switches are used, the threshold may optionally follow the +A. For example +A0.1 turns anti-aliasing on and sets the threshold to 0.1.

The threshold comparison is computed as follows. If r_1, g_1, b_1 and r_2, g_2, b_2 are the rgb components of two pixels then the difference between pixels is computed by

diff = abs(r1-r2) + abs(g1-g2) + abs(b1-b2).

If this difference is greater than the threshold both pixels are super-sampled. The rgb values are in the range from 0.0 to 1.0 thus the most two pixels can differ is 3.0. If the anti-aliasing threshold is 0.0 then every pixel is super-sampled. If the threshold is 3.0 then no anti-aliasing is done. Lower threshold means more anti-aliasing and less speed. Use anti-aliasing for your final version of a picture, not the rough draft. The lower the contrast, the lower the threshold should be. Higher contrast pictures can get away with higher tolerance values. Good values seem to be around 0.2 to 0.4.

When using the non-adaptive method, the default number of super-samples is nine per pixel, located on a 3*3 grid. The Antialias_Depth=n option or +Rn switch controls the number of rows and columns of samples taken for a super-sampled pixel. For example +R4 would give 4*4=16 samples per pixel.

The second, adaptive super-sampling method starts by tracing four rays at the corners of each pixel. If the resulting colors differ more than the threshold amount additional samples will be taken. This is done recursively, i. e. the pixel is divided into four sub-pixels that are separately traced and tested for further subdivision. The advantage of this method is the reduced number of rays that have to be traced. Samples that are common among adjacent pixels and sub-pixels are stored and reused to avoid re-tracing of rays. The recursive character of this method makes it adaptive, i. e. the super-sampling concentrates on those parts of the pixel that are more likely to need super-sampling (see figure below).


Example of how the adapative super-sampling works.

The maximum number of subdivisions is specified by the Antialias_Depth=n option or +Rn switch. This is different from the non-adaptive method were the total number of super-samples is specified. A maximum number of n subdivisions results in a maximum number of samples per pixel that is given by the following table.

      Number of samples per    Maximum number of samples
      super-sampled pixel for  per super-sampled pixel for
 +Rn  the non-adaptive method  the adaptive method
  1                1                       9
  2                4                      25
  3                9                      81
  4               16                     289
  5               25                    1089
  6               36                    4225
  7               49                   16641
  8               64                   66049
  9               81                  263169

You should note that the maximum number of samples in the adaptive case is hardly ever reached for a given pixel. If the adaptive method is used with no anti-aliasing each pixel will be the average of the rays traced at its corners. In most cases a recursion level of three is sufficient.

Another way to reduce aliasing artifacts is to introduce noise into the sampling process. This is called jittering and works because the human visual system is much more forgiving to noise than it is to regular patterns. The location of the super-samples is jittered or wiggled a tiny amount when anti-aliasing is used. Jittering is used by default but it may be turned off with the Jitter=off option or -J switch. The amount of jittering can be set with the Jitter_Amount=n.n option. When using switches the jitter scale may be specified after the +J switch. For example +J0.5 uses half the normal jitter. The default amount of 1.0 is the maximum jitter which will insure that all super-samples remain inside the original pixel. Note that the jittering noise is random and non-repeatable so you should avoid using jitter in animation sequences as the anti-aliased pixels will vary and flicker annoyingly from frame to frame.

If anti-aliasing is not used one sample per pixel is taken regardless of the super-sampling method specified.


Section 7
Scene Description Language

The Scene Description Language allows you to describe the world in a readable and convenient way. Files are created in plain ASCII text using an editor of your choice. The input file name is specified using the Input_File_Name=file option or +Ifile switch. By default the files have the extension .pov. POV-Ray reads the file, processes it by creating an internal model of the scene and then renders the scene.

The overall syntax of a scene is a file that contains any number of the following items in any order.

LANGUAGE_DIRECTIVES camera { CAMERA_ITEMS } OBJECT_STATEMENTS ATMOSPHERE_STATEMENTS global_settings { GLOBAL_ITEMS }

See section "Language Directives", section "Objects", section "Camera", section "Atmospheric Effects" and section "Global Settings" for details.


Section 7.1
Language Basics

The POV-Ray language consists of identifiers, reserved keywords, floating point expressions, strings, special symbols and comments. The text of a POV-Ray scene file is free format. You may put statements on separate lines or on the same line as you desire. You may add blank lines, spaces or indentations as long as you do not split any keywords or identifiers.
Next Section
Table Of Contents