POV-Ray : Documentation : 2.6.2.2 Sampling Parameters & Methods
  POV-Ray 3.6 Documentation Online View  
2.6.2.1 Media Types   2.6.2.3 Density

2.6.2.2 Sampling Parameters & Methods

Media effects are calculated by sampling the media along the path of the ray. It uses a method called Monte Carlo integration. The intervals keyword may be used to specify the integer number of intervals used to sample the ray. The default number of intervals is 10. For object media the intervals are spread between the entry and exit points as the ray passes through the container object. For atmospheric media, the intervals spans the entire length of the ray from its start until it hits an object. For media types which interact with spotlights or cylinder lights, the intervals which are not illuminated by these light types are weighted differently than the illuminated intervals when distributing samples.

The ratio keyword distributes intervals differently between lit and unlit areas. The default value of ratio 0.9 means that lit intervals get more samples than unlit intervals. Note that the total number of intervals must exceed the number of illuminated intervals. If a ray passes in and out of 8 spotlights but you have only specified 5 intervals then an error occurs.

The samples Min, Max keyword specifies the minimum and maximum number of samples taken per interval. The default values are samples 1,1.

As each interval is sampled, the variance is computed. If the variance is below a threshold value, then no more samples are needed. The variance and confidence keywords specify the permitted variance allowed and the confidence that you are within that variance. The exact calculations are quite complex and involve chi-squared tests and other statistical principles too messy to describe here. The default values are variance 1.0/128 and confidence 0.9. For slower more accurate results, decrease the variance and increase the confidence.

Note: the maximum number of samples limits the calculations even if the proper variance and confidence are never reached.

The method keyword lets you specify what sampling method is used, POV-Ray provides three. Method 1 is the method described above.

Sample method 2 distributes samples evenly along the viewing ray or light ray. The latter can make things look smoother sometimes. If you specify a max samples higher than the minimum samples, POV will take additional samples, but they will be random, just like in method 1. Therefore, it is suggested you set the max samples equal to the minimum samples. jitter will cause method 2 to look similar to method 1. It should be followed by a float, and a value of 1 will stagger the samples in the full range between samples.

Sample method 3 uses adaptive sampling (similar to adaptive anti-aliasing) which is very much like the sampling method used in POV-Ray 3.0's atmosphere. This code was written from the ground-up to work with media, however. Adaptive sampling works by taking another sample between two existing samples if there is too much variance in the original two samples. This leads to fewer samples being taken in areas where the effect from the media remains constant. The adaptive sampling is only performed if the minimum samples are set to 3 or more.

You can specify the anti-aliasing recursion depth using the aa_level keyword followed by an integer. You can specify the anti-aliasing threshold by using the aa_threshold followed by a float. The default for aa_level is 4 and the default aa_threshold is 0.1. jitter also works with method 3. Sample method 3 ignores the maximum samples value. It is usually best to only use one interval with method 3. Too many intervals can lead to artefacts, and POV will create more intervals if it needs them.

2.6.2.1 Media Types   2.6.2.3 Density


Copyright 2003-2004 Persistence of Vision Raytracer Pty. Ltd.