Screen-space ambient occlusion (SSAO) parameters.
Ambient occlusion is a shading method used to calculate how exposed each point in a scene is to ambient lighting. The more occluded a point is, the darker it appears. SSAO is an efficient, real-time approximation of ambient occlusion that operates in screen space. It enhances the depth and realism of a scene by adding subtle shadowing effects in creases, holes, and surfaces that are close to each other. See https://www.kitware.com/ssao/ for an overview.
The default parameter values below have been chosen as a best-guess effort at producing good quality images. They may not be optimal for your particular scene.
To understand how to tune these parameters, you need a bit of insight into how ambient occlusion works generally, and how SSAO works specifically. For each pixel, its "occlusion factor" is determined by examining a hemispherical area around the pixel's position in 3D space (oriented based on its normal). The fraction of the hemisphere contained within geometry is the occlusion factor.
SSAO produces a discrete approximation of the true occlusion factor. It evaluates a discrete number of samples within the hemisphere and compares their depths (in the OpenGL-camera sense) with that of the pixel being shaded to determine how much of the hemisphere is occupied by geometry. As with all discrete approximations, there is a tradeoff between fidelity and cost. The parameter documentation below provides some guidance on the effect of each parameter on the final rendered image.
#include <drake/geometry/render_vtk/render_engine_vtk_params.h>
Public Member Functions | |
template<typename Archive > | |
void | Serialize (Archive *a) |
Passes this object to an Archive. More... | |
Public Attributes | |
double | radius {0.25} |
The radius (in meters) of the sampling hemisphere. More... | |
double | bias {0.01} |
SSAO works in screen space; so it uses the depth image to determine whether a sample lies within the hemisphere or not. More... | |
int | sample_count {128} |
This is simply the number of samples taken. More... | |
double | intensity_scale {1.0} |
Once the occlusion factor is computed, prior to applying the factor to the shaded pixel, you can apply a final affine transformation: More... | |
double | intensity_shift {0.0} |
bool | blur {true} |
The discrete sampling approach will ultimately produce shading with a noisy pattern. More... | |
void Serialize | ( | Archive * | a | ) |
Passes this object to an Archive.
Refer to YAML Serialization for background.
double bias {0.01} |
SSAO works in screen space; so it uses the depth image to determine whether a sample lies within the hemisphere or not.
We compare the depth of a sample point with the recorded depth in the same direction. In principle, if the sample point is farther than the recorded depth, the sample is occluded. This bias pads that calculation by specifying how far in front (in meters) the recorded distance has to be before the sample is considered occluded. Larger bias values will classify fewer samples as occluded, reducing the amount of ambient occlusion (darkness) in the final image.
A non-zero value is usually helpful to help resolve potential issues due to depth map precision issues (so-called "acne"), but it should generally be small.
bool blur {true} |
The discrete sampling approach will ultimately produce shading with a noisy pattern.
More samples will reduce the noise, but you can also apply a blur to the final occlusion image to reduce the noise. This is a screen space blur, so it is fast. However, it will also reduce the sharpness of occlusion patterns. You can disable blurring to speed things up, but it will emphasize the sampling noise.
double intensity_scale {1.0} |
Once the occlusion factor is computed, prior to applying the factor to the shaded pixel, you can apply a final affine transformation:
occlusion = (occlusion - intensity_shift) * intensity_scale
Using these two values allows you to tune the contrast and mean occlusion value independent of the sampling algorithm above. Remember, the more occlusion, the more darkness. So, scale factors greater than one will make the image darker as will negative shift values.
One reason to consider shifting is is based on the total lighting in the scene. For a very brightly lit scene with a large camera exposure, the ambient occlusion effects should have a smaller influence. A scale less than one, or a shift greater than zero, will reduce the SSAO effect.
double intensity_shift {0.0} |
double radius {0.25} |
The radius (in meters) of the sampling hemisphere.
There is no "correct" value. Heuristically, it should scale with your scene. A rubric of 1/10th the size of your scene is reasonable. For example, 0.25 meters is good for a robot working at a table top.
If the radius is too large, pixels will exhibit occlusion (darkness) from objects that might seem too distant to be relevant. A too-small radius would have the opposite effect; missing occlusion where it seems it should occur.
int sample_count {128} |
This is simply the number of samples taken.
More samples lead to smoother occlusion patterns. Large numbers will produce better images but at a higher computational cost. You should use the smallest number that still provides acceptable visual quality.