Anti Aliasing Sample Count#
The quality of the AA is controlled by Anti Aliasing Sample Count. Increasing this value directly increases the number of rays per pixel that are fired by the camera which in return improves image quality but also increases rendering times.
Indeed, a value of 64 spp corresponds to rendering an image that is 8 times bigger than the original specified resolution. It is also important to understand the role AA plays in sampling. Indeed, AA caps the number of samples used by integrators for material and light sampling because there can't be less than 1 material and light sample per camera ray.
For example, when using the Path Tracer, if the Material Sample Count is set explicitly to 1 spp, this value is internally maxed out by the number of samples set in Anti Aliasing Sample Count.
Even if Material Sample Count is set to 1 spp, internally Material Sample Count is capped by the Anti Aliasing Sample Count value. So in this example, the actual number of material sample count used by the path tracer is always equal to number of AA samples which is respectively 1, 16, 64 and 256 spp.
Texturing Anti Aliasing#
It is possible to drive Anti Aliasing Sample Count attribute by a texture. This way you can locally control the number of anti aliasing samples based on a black and white texture.
When texturing Anti Aliasing Sample Count, the number of samples set in Anti Aliasing Sample Count is multiplied by the input texture value. For example, if you plug a pure black texture, then the resulting number of samples will be 0. In that case no rays are even fired from the camera which is very useful to create render masks.
Camera rays are only skipped when the input texture explicitly returns 0. When the input texture output value is very small and close to 0, the raytracer rounds up the resulting value to 1 to ensure the camera launches a minimum of 1 spp.
Anti Aliasing Sample Count set to 8spp
Anti Aliasing Sample Count set to 64spp with texture limiting the sample count to 8spp for grey spheres and background
Texture used to control the AA Sample Count. Note the dark area isn't black but dark grey.
It is possible to change the seed of all random generators used during rendering. This can be very useful for certain post filter denoiser which need this information to identify where the noise comes from.
Lock Sampling Noise#
Denoiser filters tend to provide better results when sampling is not time dependent. If you wish to use a post denoiser, we then recommend you to enable Lock Sampling Noise. Lock Sampling Noise locks material, light... sampling through time in a way that noise seems to stick to the camera plane. For example, if you were to render a static frame over time, all the rendered frames would be identical: resulting noise won't be animated.
Unlike most renderers, the raytracer always tries to decouples material and light sampling from anti aliasing. In other words, increasing anti aliasing does not implicitly increase the number of samples users have set on their lights and materials.
They can tweak the number of samples necessary to remove noise without worrying about slow render times when anti aliasing or motion blur are turned on. Indeed, when the number of material and light samples is larger than Anti Aliasing Sample Count, the raytracer gracefully dispatches the number of samples in order to reach the original number of samples that is set on materials and lights.
As a result, render times are not really affected by anti aliasing and motion blur. There's no explosion of the number of samples.
It this example, when Anti Aliasing Sample Count is increased, only aliasing is removed from the render. Noise levels are identical between renders and render times are kept constrained.
However, in some cases such as renders with fine geometries or heavy motion blur scenarios, you may want to increase material and light sampling per anti aliasing samples to improve the quality of the sampling specially when using adaptive anti aliasing. In that case, it is possible to increase sampling quality according to the anti aliasing using the Shading Oversampling attribute.
When Shading Oversampling is set to 0% (default), anti aliasing doesn't increase material and light sampling. At 100%, each anti alias samples will be sampled with the number of samples set in materials and lights following this formula:
$$ TotalSampleCount = AACount * (MSCount + LSCount) $$ where:
- \(AACount\) is the Anti Aliasing Sample Count
- \(MSCount\) is the Material Sample Count
- \(LSCount\) is the Light Sample Count
In the renders below the scene has been setup with Anti Aliasing Sample Count at 9 spp, Material Sample Count at 16 spp and Light Sample Count at 16 spp.
For example: if you have anti aliasing sample count set to 9 spp and materials and lights sample count set to 16 spp, the total number of sample per pixel with a Shading Oversampling at 100% is equal to 288 samples 9 * (16 + 16).
When Shading Oversampling is set to 0%, this number is down to 41 samples per pixel.
Since the number of samples increases, so does render times. Interestingly, while the total number of samples increased by 7, render times only increased by 5.
Anti Aliasing Filtering#
Anti aliasing filtering filters anti aliasing samples when computing the final pixel color. It basically defines what is the image filter that is used when resampling down the image to the final resolution.
Anti aliasing filters can increase render quality, specially when dealing with fur an tiny objects since neighbor pixels contributes to the final pixel. The raytracer has two attributes that controls filtering:
- Anti Aliasing Filter which defines the function curve of the filter
- Anti Aliasing Filter Size which defines the size of the filter in pixel.
A filter size of 2.0 means that the current pixel takes into account the contribution of its 8 neighboring pixels weighted by the specified function curve according to their distance to the center.
|Box||Each sample has the same weight. This is the default settings. Recommended filter size is 1.0 px, 1.0 px.|
|Triangle||Sub sample weights decrease linearly according to their distance to the pixel center. Minimum recommended filter size is 2.0 px, 2.0 px.|
|Gaussian (Default)||Sub sample weights are computed using a Gaussian curve function according to their distance to the pixel center. Minimum recommended filter size is 2.0 px, 2.0 px.|
|Blackman-Harris||Sub sample weights are computed using a Blackman Harris curve function according to their distance to the pixel center. This filter is highly recommended. Minimum recommended filter size is 3.0 px, 3.0 px.|
|Mitchell||Sub sample weights are computed using a Mitchell curve function according to their distance to the pixel center. This filter is sharper than Gaussian but it has negative lobes that may introduce artifacts with HDR values or ID passes. Minimum recommended filter size is 4.0 px, 4.0 px.|
|Lanczos||Sub sample weights are computed using a Lanczos curve function according to their distance to the pixel center. This filter is quite good: a good balance between smoothness and sharpness, however similarly to Mitchell, it has negative lobes that may introduce artifacts with HDR values or ID passes. Minimum recommended filter size is 2.0 px, 2.0 px.|
Anti Aliasing Filter Mode#
Anti Aliasing Filter Mode allows you to choose the technique used to integrate camera samples to generate the final pixel. The raytracer provides two techniques:
|Splatting||All the sub pixel samples of all the pixels enclosed within the kernel filter size contribute to the final pixel. While this mode tends to render softer images in general, it comes with two drawbacks unfortunately. The first one is that the noise is spread out over all the surrounding pixels which makes the work of denoisers way more difficult. The second one is that it slightly increases render times.|
|Importance Sampling (Default)||Importance sample the anti aliasing filter curve of the current pixel. This mode offers better results but tends to introduce more noise when large kernel filter sizes are used. This mode is highly recommended since not only is it faster to render but renders are easier to denoise.|
As you can see Splatting seems to have the same amount of noise than Importance Sampling, however if we now apply a denoiser to both renders:
Results are simply night and day, since the Importance Sampling one is much better!
Subsample Quality controls the size of ray differentials for each camera sample. By default, the value is set to 0%. This means the size of each sample is about a pixel in size.
Below two renders with Subsample Quality at 0% (default)
As you can see the sharpness of the texture is comparable even if the anti aliasing increases.
When Subsample Quality is at 100% the pixel size is about the size of the actual sub-pixel. This settings affects all computations that are based on ray differentials such as texture filtering, bump and normal maps. So increasing Subsample Quality value increases the crispness/sharpness of textures.
High level of Subsample Quality can lead to two different issues:
- Reduced texture cache efficiency since the raytracer has to stream higher resolution textures. The solution is to increase cache size to improve performance. Go to Edit > Preferences... > Input Output and increase the value of Stream Texture Cache.
- Increased chance of flickering on animation (specially on bump maps) which can only be solved by increasing the Anti Aliasing Sample Count.
Adaptive Anti Aliasing (AAA)#
Adaptive anti aliasing (AAA) is a great solution to optimize render times to resolve the noise coming from depth of field, motion blur, fine geometries and avoid tweaking lights and material sampling.
The adaptive anti aliasing is able to refine the image based on local pixel variance (or noise) instead of using a fixed number of samples for the whole image. For example, using adaptive anti aliasing the raytracer will fire more samples in out-of-focus areas (where there is more noise) than in-focus ones.
The way the adaptive anti aliasing works is very simple. In this mode, the raytracer becomes a progressive renderer: ray paths are initiated from the camera and material and light sampling set by the user are completely ignored.
In other words, it greatly simplifies the workflow since it is no longer necessary to set material/light sampling as noise is directly resolved by the raytracer.
How does it work?#
When rendering, the raytracer first launches and accumulates a minimum number of samples that corresponds to Anti Aliasing Sample Count. This first pass allows the raytracer to compute the local variance of each pixels.
Then, when a pixel is above the variance threshold set in Refinement Variance Threshold, the raytracer continues to refine by firing additional rays from the camera until either the variance is lower than the specified threshold or the maximum number of refinement samples has been reached.
Only three attributes control Adaptive Anti Aliasing: Anti Aliasing Sample Count, Refinement Maximum Sample Count and Refinement Variance Threshold.
- Anti Aliasing Sample Count defines the minimum number of samples which are also used to compute the local pixel variance.
- Refinement Maximum Sample Count defines the maximum number of additional samples you let the raytracer to fire to resolve the variance.
- Refinement Variance Threshold defines the maximum variance (noise) threshold for which the raytracer should consider the pixel converged. Lowering the threshold value reduces the tolerance the raytracer allows for pixel variance (noise). A low threshold value directly translates to an increase of the number of samples fired in noisy areas.
While adaptive anti aliasing is very attractive because it simplifies greatly the render setup, it can be also very inefficient sometimes unfortunately.
Indeed, paths issued from the camera are some of the most costly and inefficient ones in a path tracer. This directly can translate to higher render times that may be doubled or tripled for an identical result when compared to renders that have been manually tweaked by an experienced artist who managed to set the ideal number of material and light samples.
Refinement Variance Mode#
Refinement Variance Mode defines the method the raytracer uses to compute the variance of the pixel in order to decide if more samples are needed. Please note that Refinement Variance Threshold value directly depends on the method selected in Refinement Variance Mode. The raytracer provides two techniques:
|Contrast (Default)||Use pixel contrast to compute the pixel variance. It compares the maximum of the the new accumulated samples to the beauty. This mode generally offers the best results.|
|Standard Deviation||Use Standard Deviation to compute the pixel variance. Unlike Contrast which is perceptually based, Standard Deviation actually measures the dispersion of the samples relative to the mean. Images resulting from standard deviation tend to have a more homogeneous level of noise since spikes in the signal are oversampled.|
There's no correspondence between Contrast and Standard Deviation thresholds.
Refinement Variance Filter#
Refinement Variance Filter allows you to specify or disable the internal kernel filter. By default, the raytracer uses the same filter as the one selected in Anti Aliasing Filter.
Changing the filter directly impacts the speed and quality of the renders since the kernel filter defines how the variance estimation of the current pixel should take into account the variance of neighboring ones.
Indeed, the idea is that the samples of the current pixel may miss some of the features that may have been properly sampled in neighboring pixels. However, while the filter may overestimate the variance leading to oversampling, it also reduces the risk of undersampling pixels when the minimum number of AA samples is too low.
AAA render with an Anti Aliasing Filter set to Gaussian 2.0 2.0
Refinement Variance Filter disabled. We can see dark spots
Resulting heat map
When set to Gaussian dark spots are gone but render is 20% slower
We can see that the whole image is oversampled and not only the dark spots
Refinement Variance LUT#
Subpixel variance computation made by the raytracer takes into account the final color space of the rendered image. This feature greatly improves the efficiency of the adaptive anti aliasing.
Refinement Variance LUT set to sRGB (default) - rgba
Refinement Variance LUT set to sRGB (default) - diagnostics_camera_sample-count AOV
Refinement Variance LUT set to Linear - rgba
Refinement Variance LUT set to Linear - diagnostics_camera_sample-count AOV
Refinement Variance LUT set to sRGB (default) on top renders and set to Linear on the bottom ones. The image is noisier using the Linear one, as well as being 40% slower to render. Also note how many samples were wasted on the background.
We therefore highly recommend to set the Refinement Variance LUT to the LUT used for the final render. However, if the final LUT is not known it is still possible to set the Refinement Variance LUT to linear so that subpixel variance computations are performed in linear space.
AAA and Shading Oversampling#
One of the issue of adaptive anti aliasing is that noise is resolved from the camera and paths starting from the camera are the most expensive ones. There are quite a few reasons why but this is beyond the scope of this guide.
In order to reduce the variance per iteration it can be useful to increase ever so slightly Shading Oversampling on scene configurations that have fine geometries (small leaves, hair...) or motion blur.
Indeed, increasing Shading Oversampling improves the quality of each iteration since they benefit from the extra samples allocation. This leads to iterations that have smaller variance which results to faster render times.