# Difference between revisions of "Reference:Sampling Parameters & Methods"

Jholsenback (talk | contribs) m (typo) |
Jholsenback (talk | contribs) m (continued cleanup) |
||

Line 3: | Line 3: | ||

{{#indexentry:intervals, media}} | {{#indexentry:intervals, media}} | ||

{{#indexentry:keyword, intervals}} | {{#indexentry:keyword, intervals}} | ||

− | <p>Media effects are calculated by sampling the media along the path of the ray | + | <p>Media effects are calculated by sampling the media along the path of the ray. The <code>method</code> keyword specifies what sampling type is used. POV-Ray has three different types of media sampling methods.</p> |

− | <p class="Note"><strong>Note:</strong> As of version 3.5 sampling <code>method</code> 3 is now the default. Sampling methods 1 and 2 have been retained for legacy purposes.</p> | + | <p class="Note"><strong>Note:</strong> As of version 3.5 it is highly recommended to use sampling <code>method</code> 3. It is now the default. Sampling methods 1 and 2 have been retained for legacy purposes.</p> |

{{#indexentry:aa_threshold, media}} | {{#indexentry:aa_threshold, media}} | ||

Line 12: | Line 12: | ||

{{#indexentry:keyword, aa_level}} | {{#indexentry:keyword, aa_level}} | ||

− | <p><strong>Sampling Method 3:</strong> uses adaptive sampling which is very much like the sampling method that was used with the POV-Ray 3.0 atmosphere feature. | + | <p><strong>Sampling Method 3:</strong> uses adaptive sampling which is very much like the sampling method that was used with the POV-Ray 3.0 atmosphere feature. Another sample is taken between two existing, if the difference between the two end samples is greater than <code>aa_threshold</code>. This leads to fewer samples being taken in areas where the effect from the media remains constant. Keep in mind that <em>true</em> adaptive sampling only occurs when samples is set to 3 or more.</p> |

<p class="Note"><strong>Note:</strong> <em>Exclusively</em> with method 3, when using two values for samples, the second parameter is silently ignored.</p> | <p class="Note"><strong>Note:</strong> <em>Exclusively</em> with method 3, when using two values for samples, the second parameter is silently ignored.</p> | ||

Line 18: | Line 18: | ||

<p>Implementation of the <code>intervals</code> keyword is also different with this method. Consequently it is usually best to use <em>only</em> one interval, since more intervals will dramatically increase the render time without giving any appreciable improvement. In other words: <code>samples 10</code> and <code>intervals 3</code> will render slower than <code>samples 50</code> and <code>intervals 1</code>.</p> | <p>Implementation of the <code>intervals</code> keyword is also different with this method. Consequently it is usually best to use <em>only</em> one interval, since more intervals will dramatically increase the render time without giving any appreciable improvement. In other words: <code>samples 10</code> and <code>intervals 3</code> will render slower than <code>samples 50</code> and <code>intervals 1</code>.</p> | ||

− | <p> | + | <p>Additionally these parameters are available as follows:</p> |

<ul> | <ul> | ||

Line 25: | Line 25: | ||

<li> The <code>jitter</code> keyword followed by a float enables / sets that feature.</li> | <li> The <code>jitter</code> keyword followed by a float enables / sets that feature.</li> | ||

</ul> | </ul> | ||

+ | |||

+ | <p class="Note"><strong>Note:</strong> The keywords: <code>confidence</code>, <code>variance</code> and <code>ratio</code> are used only with methods 1 and 2.</p> | ||

+ | |||

+ | <p>See also: [[Reference:Media|Media]] for default values.</p> | ||

<p><strong>Sampling Method 1:</strong> uses the <code>intervals</code> keyword to specify the integer number of intervals used to sample the ray. 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.</p> | <p><strong>Sampling Method 1:</strong> uses the <code>intervals</code> keyword to specify the integer number of intervals used to sample the ray. 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.</p> | ||

Line 44: | Line 48: | ||

<p class="Note"><strong>Note:</strong> The maximum number of samples limits the calculations even if the proper variance and confidence are never reached.</p> | <p class="Note"><strong>Note:</strong> The maximum number of samples limits the calculations even if the proper variance and confidence are never reached.</p> | ||

+ | |||

+ | <p>See also: [[Reference:Media|Media]] for default values.</p> | ||

<p><strong>Sampling Method 2:</strong> distributes samples evenly along the viewing ray or light ray. The latter can make things look smoother sometimes. If you specify a maximum number of samples higher than the minimum number of 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. | <p><strong>Sampling Method 2:</strong> distributes samples evenly along the viewing ray or light ray. The latter can make things look smoother sometimes. If you specify a maximum number of samples higher than the minimum number of 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. | ||

<code>jitter</code> 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.</p> | <code>jitter</code> 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.</p> | ||

+ | |||

+ | <p class="Note"><strong>Note:</strong> When using multiple medias, it's strongly recommend all use the same sampling method. With the current code there is the possibility of some keyword setting bleed between methods.</p> | ||

<p>See also: [[Reference:Media|Media]] for default values.</p> | <p>See also: [[Reference:Media|Media]] for default values.</p> |

## Revision as of 17:36, 15 February 2021

Media effects are calculated by sampling the media along the path of the ray. The `method`

keyword specifies what sampling type is used. POV-Ray has three different types of media sampling methods.

**Note:** As of version 3.5 it is highly recommended to use sampling `method`

3. It is now the default. Sampling methods 1 and 2 have been retained for legacy purposes.

**Sampling Method 3:** uses adaptive sampling which is very much like the sampling method that was used with the POV-Ray 3.0 atmosphere feature. Another sample is taken between two existing, if the difference between the two end samples is greater than `aa_threshold`

. This leads to fewer samples being taken in areas where the effect from the media remains constant. Keep in mind that *true* adaptive sampling only occurs when samples is set to 3 or more.

**Note:** *Exclusively* with method 3, when using two values for samples, the second parameter is silently ignored.

Implementation of the `intervals`

keyword is also different with this method. Consequently it is usually best to use *only* one interval, since more intervals will dramatically increase the render time without giving any appreciable improvement. In other words: `samples 10`

and `intervals 3`

will render slower than `samples 50`

and `intervals 1`

.

Additionally these parameters are available as follows:

- The anti-aliasing recursion depth is set by using the
`aa_level`

keyword followed by an integer - The anti-aliasing threshold is set by using
`aa_threshold`

followed by a float. - The
`jitter`

keyword followed by a float enables / sets that feature.

**Note:** The keywords: `confidence`

, `variance`

and `ratio`

are used only with methods 1 and 2.

See also: Media for default values.

**Sampling Method 1:** uses the `intervals`

keyword to specify the integer number of intervals used to sample the ray. 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*,

*keyword specifies the minimum and maximum number of samples taken per interval. The default values are*

`Max`

`samples 1,1`

. The value for Max may be omitted, in which case the range Min = Max will be used.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.

See also: Media for default values.

**Sampling Method 2:** distributes samples evenly along the viewing ray or light ray. The latter can make things look smoother sometimes. If you specify a maximum number of samples higher than the minimum number of 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.

**Note:** When using multiple medias, it's strongly recommend all use the same sampling method. With the current code there is the possibility of some keyword setting bleed between methods.

See also: Media for default values.