-
Pixel-to-camera rays that hit some object in the scene.
-
Used to resolve noise/artifacts from:
-
Geometry and Curve Details
-
Displacement
-
Depth of Field
-
Motion Blur
-
On this page |
Overview ¶
Sampling is the heart of modern render engines. Sampling refers to the simulated light rays Karma sends into the scene to determine the color of each pixel of the rendered image.
Tip
The terms sample, path, and ray are generally interchangeable when talking about path tracing.
First Karma sends samples out from the camera that then hit objects in the scene. These are the primary samples. When objects are hit, Karma uses the object properties (such as surface orientation and materials) to send out secondary samples. These additional rays hit other surfaces and lights, until the final color of the pixel is determined.
Tip
The behavior of Primary Samples can usually refer to Path Traced Samples.
Primary samples ¶
Secondary samples ¶
-
Rays cast from the hit position of primary samples, toward other directions in the scene.
-
Direct Samples are position-to-light rays:
-
Light Samples
-
-
Indirect Samples are position-to-position rays:
-
Diffuse
-
Reflection
-
Refraction
-
Sub-Surface Scattering
-
Volume
-
Oversampling (sending out more rays than you need for a given quality level) and under-sampling (sending out too few rays to achieve a given quality level) are sources of slow-downs when rendering. Understanding the differences between primary and secondary samples will help you to use Karma more effectively.
Convergence Ray Counts ¶
Understanding how primary and secondary samples are related helps estimate the maximum number of rays Karma uses when rendering. User settings, per-object overrides, and algorithms make predicting the exact number impossible. Understanding how these parameters influence one another helps debug performance.
The number of rays Karma uses is determined by the total number of primary samples and secondary samples fired for each pixel. Beyond that, we need to know the engine and convergence mode being used.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Choosing an engine ¶
Choosing which engine and/or convergence mode is the first step. By default Karma CPU with Automatic convergence is enabled. After considering some of these points, and doing some testing of course, you might consider a different engine/mode.
Engine |
Reasons |
---|---|
|
|
|
Sampling in Karma CPU ¶
Karma CPU offers a much wider array of sampling controls compared to Karma XPU. It supports Path Traced convergence (see below), but defaults to a sophisticated adaptive sampling approach for both primary and secondary rays.
Primary samples ¶
The rays that Karma sends from the camera into the scene are called primary samples. Primary samples resolve anti-aliasing artifacts from small geometry detail (such as curves or displacement), depth of field, and motion blur. Sufficient pixel samples improves the overall sharpness and quality of the image.
Tip
Primary Samples are sometimes also called camera rays, AA samples, or pixel samples, especially by other renderers.
A single primary sample is usually too coarse for anything more than debugging. Increasing the pixel samples gives much smoother representation of the shapes in the scene. While this improves quality, even in secondary noise, it can be overkill because primary samples are a multiplier on the secondary samples. For Karma CPU, the pixel oracle can help Karma avoid over-sampling the pixels.
Pixel oracle ¶
Karma CPU supports adaptive primary samples, using pixel oracles. Pixel oracles represent the logic Karma should use when casting rays from each pixel. Currently, Karma ships with 2 pixel oracles: Variance and Uniform.
By default, Karma uses the Variance Oracle, which detects differences between neighboring pixels to avoid sending too many primary samples by stopping when each additional sample will have very little effect on the final pixel color. Karma will send a small number of primary samples, then the Variance Oracle starts comparing pixels against the Oracle’s Variance Threshold. Once the variance between the previous samples of the current pixel and adjacent pixels fall below that threshold, Karma stops firing primary samples for that pixel.
The Uniform Oracle simply sends the same number of primary samples from every pixel in the scene. You may want to switch to the Uniform Oracle when extreme depth of field (DOF) or motion blur dominates the image. In those cases, Karma ends up fully sampling every pixel anyway, so measuring variance just adds overhead.
Warning
Karma XPU does not currently support Pixel Oracles for GPU or CPU devices. It casts the same number of path traced samples from every pixel.
Pixel Oracle Render Properties
Pixel Oracle
When rendering, a Pixel Oracle tells karma which pixels need additional sampling and which pixels are converged. This parameter tells karma which oracle to use.
uniform
Uniformly distribute rays to each pixel. Each pixel will always get the same number of ray-samples.
variance
Distribute rays based on variance in the rendered image.
Secondary samples ¶
Once a primary ray intersects an object, Karma will cast Secondary Samples from each primary ray’s hit location. For every hit position, Karma will send direct and indirect secondary samples. Direct samples are sent towards lights. Indirect samples are sent along directions determined by the geometry and shader, at the hit position. Secondary samples can be diffuse, reflection, refraction, subsurface, or volume rays.
Volumetric objects are handled a bit different from surfaces. Instead of sampling only a single hit position, Karma marches along the ray, sampling multiple points through the volume. At each positions along the ray, direct and indirect rays are sent out into the scene. Not every position within the volume is used; instead Karma intelligently chooses a subset of positions to sample.
Min/Max Secondary Properties
Pixel Samples
The number of ray-samples sent through each pixel. More samples will result in a less noisy image. “”Pixel Samples“ and ”Primary Samples" are the same.
Min Secondary Samples
Minimum number of rays to cast in per-component variance anti-aliasing.
Max Secondary Samples
Maximum number of rays to cast in per-component variance anti-aliasing.
Secondary Noise Level
Noise threshold to determine the number of indirect rays cast for indirect bounce when the Convergence Mode is set to “Automatic”. Decreasing this threshold (for example, to 0.001
) will theoretically send more indirect rays and decrease noise, however the “extra” rays will likely be cancelled out by the Max Ray Samples parameter. The correct way to decrease noise is to increase the number of samples per pixel, rather than change this threshold.
If you are using Variance Pixel Oracle, you should set the same value for both threshold parameters. Setting the oracle’s threshold lower may make the indirect component reach its threshold sooner and cast fewer indirect rays, but the oracle decides to cast more expensive camera rays because the amount of final noise in the beauty pass is higher than the oracle’s threshold.
Limits ¶
To avoid rays potentially traveling forever, Karma provides per-type “bounce” limits. You may need to increasing these limits to ensure Karma takes enough indirect samples to get the desired look. Refraction often needs a higher limit, to improve the quality of scenes with glass and liquid materials. Volumes may also benefit from increased limits, to capture the subtle effects of volumetric lighting.
Increasing the limits can increase render times substantially. Only increase limits as needed, to achieve a desired look.
Limits Render Properties
Diffuse Limit
The number of times diffuse rays can propagate through your scene.
Unlike Reflect Limit and Refract Limit, this parameter will increase the overall amount of light in your scene and contribute to the majority of global illumination. With this parameter set to values greater than 0
, diffuse surfaces will accumulate light from other objects in addition to direct light sources.
In this example, increasing the Diffuse Limit has a dramatic effect on the appearance of the final image. To replicate realistic lighting conditions, it is often necessary to increase the Diffuse Limit. However, since the amount of light contribution usually decreases with each diffuse bounce, increasing the Diffuse Limit beyond 4
hardly improve the visual fidelity of a scene. Additionally, increasing the Diffuse Limit can dramatically increase noise levels and render times.
This is a float because all limits are stochastically picked per-sample, so for example you can set the diffuse limit to 3.25
and have 25% of the rays with a diffuse limit of 4
and 75% of rays with a diffuse limit of 3
.
Reflection Limit
The number of times a ray can be reflected in your scene.
This example shows a classic “Hall of Mirrors” scenario with the subject placed between two mirrors.
This effectively creates an infinite series of reflections.
From this camera angle the reflection limits are very obvious and have a large impact on the accuracy of the final image. However, in most cases the reflection limit will be more subtle, allowing you to reduce the number of reflections in your scene and optimize the time it takes to render them.
Remember that the first time a light source is reflected in an object, it is considered a direct reflection. Therefore, even with Reflect Limit set to 0
, you will still see specular reflections of light sources.
This is a float because all limits are stochastically picked per-sample, so for example you can set the diffuse limit to 3.25
and have 25% of the rays with a diffuse limit of 4
and 75% of rays with a diffuse limit of 3
.
Refraction Limit
This parameter control the number of times a ray be refracted in your scene.
This example shows a simple scene with ten grids all in a row.
By applying a refractive shader, we will be able see through the grids to an image of a sunset in the background.
From this camera angle, in order for the image to be accurate, the refraction limit must match the number of grids that that are in the scene. However, most scenes will not have this number of refractive objects all in a row and so it is possible to reduce the refract limit without affecting the final image while also reducing the time it takes to render them.
Keep in mind that this Refract Limit refers to the number of surfaces that the ray must travel through, not the number of objects.
Remember that the first time a light source is refracted through a surface, it is considered a direct refraction. Therefore, even with Refract Limit set to 0
, you will see refraction of light sources. However, since most objects in your scene will have at least two surfaces between it and the light source, direct refraction is often not evident in your final render.
This is a float because all limits are stochastically picked per-sample, so for example you can set the diffuse limit to 3.25
and have 25% of the rays with a diffuse limit of 4
and 75% of rays with a diffuse limit of 3
.
Volume Limit
The number of times a volumetric ray can propagate through a scene. It functions in a similar fashion to the Diffuse Limit parameter.
Increasing the Volume Limit parameter will result in much more realistic volumetric effects. This is especially noticeable in situations where only part of a volume is receiving direct lighting. Also, in order for a volumetric object to receive indirect light from other objects, the Volume Limit parameter must be set above 0
.
With the Volume Limit set to values greater than 0
, the fog volume takes on the characteristic light scattering you would expect from light traveling through a volume. However, as with the Diffuse Limit, the light contribution generally decreases with each bounced ray and therefore using values above 4
does not necessarily result in a noticeably more realistic image.
Also, increasing the value of this parameter can dramatically increase the amount of time spent rendering volumetric images.
This is a float because all limits are stochastically picked per-sample, so for example you can set the diffuse limit to 3.25
and have 25% of the rays with a diffuse limit of 4
and 75% of rays with a diffuse limit of 3
.
SSS Limit
The number of times a SSS ray can propagate through a scene. It functions in a similar fashion to the Diffuse Limit parameter.
This is a float because all limits are stochastically picked per-sample, so for example you can set the diffuse limit to 3.25
and have 25% of the rays with a diffuse limit of 4
and 75% of rays with a diffuse limit of 3
.
Color Limit
The maximum value a shading sample is allowed to contribute to an LPE image plane to reduce appearance of “fireflies” caused by undersampling of extremely bright light sources. Note that reducing this value can result in an overall reduction in the amount of light in your scene.
Shared Color Limit
When turned on, indirect bounces use Color Limit value and Indirect Color Limit parameter is ignored.
Indirect Color Limit
Color limit applied to indirect bounce only. Note that this parameter is ignored unless Shared Color Limit is turned off.
Russian Roulette Cutoff Depth
Depth at which indirect rays start to get stochastically pruned based on ray throughput.
Light Tree ¶
Karma automatically builds a light tree to make rendering scenes with many lights more efficient. This helps Karma efficiently decide which lights should be sampled the most, and are most likely to resolve faster. Karma automatically builds a light tree, and automatically adds lights to it, when it reaches certain thresholds:
Karma CPU |
10 Lights |
Karma XPU |
2 Lights |
There are some cases where lights will not be added to the light tree, such as dome and directional lights, or lights which have light filters. Light Sampling Mode can change this behavior, and tell Karma to sample all lights in a scene. Long, thin rectangle lights are not great for the light tree. Internally it represents lighting with bounding spheres, so these lights can cause the light tree to add more noise.
Once Karma determines which light to sample at a given hit position, the Light Sampling Quality parameter determines how many rays are fired towards the light.
Light Properties
Light Sampling Mode
Whether Karma should perform uniform sampling of lights or whether rendering should use the light tree. The light tree can be significantly faster for scenes that have large numbers of lights.
Some lights cannot be added to the light tree, and will all be sampled by Karma:
-
Dome Lights
-
Distant Lights
-
Point Lights
-
Lights with Light Filters
-
Lights with shaping controls (i.e. spot lights)
Light Sampling Quality
This is a global control to improve sampling quality for all lights. This acts as a multiplier on the individual light quality controls. Increasing the quality will improve direct light sampling as well as shadows/occlusion.
Convergence modes ¶
The convergence mode is the strategy used by Karma to send secondary samples into the scene. Karma supports two convergence modes: Automatic and Path Traced. While convergence mode determines secondary rays, this choice also influences how many pixels samples are necessary for the scene.
Note
Karma CPU supports both Automatic and Path Traced modes, but Karma XPU only supports Path Traced convergence, and does not support the Pixel Oracles.
Convergence Mode Properties
Convergence Mode
When set to Path Traced, maximum of 1 indirect ray is generated per bounce. When set to Automatic, the number of indirect rays is calculated based on initial noise estimate, target noise threshold, and the maximum number of camera rays. Also note that under Automatic mode, number of samples for direct lighting is adjusted based on noise estimate as well.
Automatic ¶
By default, Karma is setup to use Automatic convergence, as it is generally results in cleaner final renders, and offers more controls to reduce noise without over-sampling areas of the render.
Primary Sample Controls |
Secondary Sample Controls |
---|---|
|
|
For every primary sample that hits an object, Karma will fire secondary samples. Karma will trace at least one ray for each type of lobe the shader produces (diffuse
, reflection
, refraction
, sss
and/or volume
). Karma will send secondary rays until the Max Secondary Samples value is reached, or the variance falls below the threshold.
Karma provides an addition set of Indirect Sample Quality controls. You can use these to reduce noise in specific lobes. The values are multipliers for the Min/Max Secondary Sample values, but only apply to each specific ray type.
Automatic Properties
Pixel Samples
The number of ray-samples sent through each pixel. More samples will result in a less noisy image. “”Pixel Samples“ and ”Primary Samples" are the same.
Min Secondary Samples
Minimum number of rays to cast in per-component variance anti-aliasing.
Max Secondary Samples
Maximum number of rays to cast in per-component variance anti-aliasing.
Secondary Noise Level
Noise threshold to determine the number of indirect rays cast for indirect bounce when the Convergence Mode is set to “Automatic”. Decreasing this threshold (for example, to 0.001
) will theoretically send more indirect rays and decrease noise, however the “extra” rays will likely be cancelled out by the Max Ray Samples parameter. The correct way to decrease noise is to increase the number of samples per pixel, rather than change this threshold.
If you are using Variance Pixel Oracle, you should set the same value for both threshold parameters. Setting the oracle’s threshold lower may make the indirect component reach its threshold sooner and cast fewer indirect rays, but the oracle decides to cast more expensive camera rays because the amount of final noise in the beauty pass is higher than the oracle’s threshold.
Light Sampling Mode
Whether Karma should perform uniform sampling of lights or whether rendering should use the light tree. The light tree can be significantly faster for scenes that have large numbers of lights.
Some lights cannot be added to the light tree, and will all be sampled by Karma:
-
Dome Lights
-
Distant Lights
-
Point Lights
-
Lights with Light Filters
-
Lights with shaping controls (i.e. spot lights)
Light Sampling Quality
This is a global control to improve sampling quality for all lights. This acts as a multiplier on the individual light quality controls. Increasing the quality will improve direct light sampling as well as shadows/occlusion.
Pixel Oracle
When rendering, a Pixel Oracle tells karma which pixels need additional sampling and which pixels are converged. This parameter tells karma which oracle to use.
uniform
Uniformly distribute rays to each pixel. Each pixel will always get the same number of ray-samples.
variance
Distribute rays based on variance in the rendered image.
Diffuse Quality
This parameter acts as a multiplier on Min Secondary Samples and Max Secondary Samples for indirect diffuse component.
Reflection Quality
This parameter acts as a multiplier on Min Secondary Samples and Max Secondary Samples for indirect reflect component.
Refraction Quality
This parameter acts as a multiplier on Min Secondary Samples and Max Secondary Samples for indirect refract component.
Volume Quality
This parameter acts as a multiplier on Min Secondary Samples and Max Secondary Samples for indirect volume component.
SSS Quality
This parameter acts as a multiplier on Min Secondary Samples and Max Secondary Samples for the SSS component.
Path traced ¶
In Path Traced convergence mode, the only control is Path Traced Samples. This sets the number of primary samples Karma will cast. The expected range of values is different compared to Automatic mode, so the parameter uses a different name to help reduce confusion.
Primary Sample Controls |
Secondary Sample Controls |
|
|
In this mode, when a primary ray hits an object, Karma will send two secondary samples by default: one direct sample toward a light, and one indirect sample into the scene. This simplicity can make Path Traced convergence very fast and interactive initially, but offers very few controls for resolving noise from specific secondary ray types in the scene. Light Sampling Quality will determine the number of times each light is sampled, but Karma decides how many lights to sample, based on the Light Sampling Mode. Karma also randomly chooses the indirect sample lobe.
Note
In interactive viewport rendering, Karma does some path tracing for the first few samples, before switching over to automatic convergence. This improves the interactive experience in Solaris.
Path Traced Properties
Path Traced Samples
The number of ray-samples sent through each pixel when using the path traced convergence mode. More samples will result in a less noisy image.
Light Sampling Mode
Whether Karma should perform uniform sampling of lights or whether rendering should use the light tree. The light tree can be significantly faster for scenes that have large numbers of lights.
Some lights cannot be added to the light tree, and will all be sampled by Karma:
-
Dome Lights
-
Distant Lights
-
Point Lights
-
Lights with Light Filters
-
Lights with shaping controls (i.e. spot lights)
Light Sampling Quality
This is a global control to improve sampling quality for all lights. This acts as a multiplier on the individual light quality controls. Increasing the quality will improve direct light sampling as well as shadows/occlusion.
Sampling in Karma XPU ¶
The primary rays that Karma XPU sends from the camera into the scene are called path traced samples. Path traced samples resolve anti-aliasing artifacts from small geometry detail (such as curves or displacement), depth of field, and motion blur. With Karma XPU the only control is Path Traced Samples. This sets the number of primary samples the XPU engine will project for each pixel.
Tip
Because XPU does not currently support adaptive path traced samples, the primarysamples
AOV values will be the same path traced samples
value for every pixel in the image.
Primary Sample Controls |
Secondary Sample Controls |
|
|
In this mode, when a ray hits an object, Karma will send two secondary samples by default: one direct sample toward a light, and one indirect sample into the scene. This simplicity can make Path Traced convergence very fast and interactive initially, but offers very few controls for resolving noise from specific secondary ray types in the scene. Light Sampling Quality will determine the number of times each light is sampled, but Karma decides how many lights to sample, based on the Light Sampling Mode. Karma also randomly chooses the indirect sample lobe.
Path Traced Properties
Path Traced Samples
The number of ray-samples sent through each pixel when using the path traced convergence mode. More samples will result in a less noisy image.
Light Sampling Mode
Whether Karma should perform uniform sampling of lights or whether rendering should use the light tree. The light tree can be significantly faster for scenes that have large numbers of lights.
Some lights cannot be added to the light tree, and will all be sampled by Karma:
-
Dome Lights
-
Distant Lights
-
Point Lights
-
Lights with Light Filters
-
Lights with shaping controls (i.e. spot lights)
Light Sampling Quality
This is a global control to improve sampling quality for all lights. This acts as a multiplier on the individual light quality controls. Increasing the quality will improve direct light sampling as well as shadows/occlusion.
Local Sample Overrides ¶
Many of the sampling settings can also be set on objects of the scene. Per-light and per-object settings are usually multpliers on their global counterpart. If a property does not mention “scale” or “multiplies” in its description, then it overrides the equivalent global property.
Also it’s worth noting that if an engine or convergence mode does not support a given sampling style/feature, per object overrides won’t have an effect.
Note
Karma does not support per-object overrides for Primary/Path Traced Samples.
Next steps ¶
With an understanding of how sampling works in Karma, next we’ll look at some practical tips to reduce noise in your renders.