QMC & Adaptive Sampling

Материал из Blender3D.

Перейти к: навигация, поиск

QMC Sampling Types

Many rendering techniques generate a final result by averaging multiple samples - blurry reflections average a set of samples taken in a cone shape around the reflection ray, ambient occlusion averages samples in a hemisphere around the shaded point, soft shadows average samples taken across the light source shape, and so on.

A popular method for generating the points/directions to sample from is 'Quasi-Monte Carlo (QMC) Sampling'. Monte Carlo sampling refers to pure random sampling (named after the city of casinos and games of chance), and so Quasi-Monte Carlo refers to various techniques to generate samples that are 'almost random', but better distributed than pure random samples.

In random sampling, it's often the case that sample points will fall very close to each other, and leave large gaps in the sampled space. This uneven concentration of sample points leads to noise in the rendered image, since it's possible that one pixel will have a set of samples that are concentrated too heavily on one part of the scene, whereas the next pixel will be concentrated on a different part of the scene. QMC techniques aim to reduce this variance, by keeping samples evenly distributed, and in a deterministic sequence.

Blender now includes two QMC sampling methods, using a Halton sequence (Adaptive QMC) and a Hammersley sequence (Constant QMC).

QMC Sampler Types

As shown in the above illustration, the Hammersley sequence is more evenly distributed, and gives cleaner sample patterns, however the Halton sequence has one major advantage - it can be calculated incrementally, staying well distributed for each new sample added.

This allows the Halton sequence to be used for adaptive sampling, whereas the Hammersley sequence needs to be pre-calculated and used in full. Adaptive sampling means that the number of samples taken can be changed, to adapt to different situations in the image, and can be a lot more efficient in some situations.

This doesn't necessarily mean that 'Adaptive QMC' is always the better option though, if the scene is such that it doesn't benefit much from adaptive sampling, the improved distribution of the 'Constant QMC' sample pattern may give a better final image in a similar amount of time. Adaptive Sampling

Adaptive QMC Sampling is used automatically when the sampler is set to 'Adaptive QMC', and the threshold is above 0. In Blender, it currently works using a simple 'early exit' method - during the sampling process, the code checks if more samples are required by calculating against a threshold. If it determines that no more samples are needed, it will stop early before hitting the amount specified in the UI, and move on to the next set of samples. This can speed up rendering significantly, since there's not much point in calculating samples (which can be quite time consuming in raytracing) if those samples aren't going to contribute much to the quality of the final image.

Adaptive sampling is currently used in three areas of Blender:

Glossy reflection/refraction

   * Skips sampling if the statistical variance of the sampled colours so far is below the specified threshold.

This has the most impact when the reflection/refraction source has large areas of flat colour, since the samples traced will be similar, and not as many will be needed to arrive at the final colour.

Raytraced shadows

   * Skips sampling if the current point is determined to be fully shadowed or unshadowed, by checking if the shadow coverage is below the threshold.

This gives substantial speed improvements in most situations, though it is most effective when there are large areas of fully shadowed or unshadowed areas - eg. sharper shadows without wide soft umbras.

Ambient Occlusion

   * Skips sampling based on a simple contrast test - if the difference between the average of all samples up to the current, and the previous average before the last sample was taken, is below the threshold.

This doesn't always give dramatic improvements, and can also introduce noise. Depending on the situation, it may be more efficient to use Constant QMC due to its more even sample distribution. As always, to be sure what will be most efficient it can be useful to do some benchmark test renders with different settings.

Личные инструменты