How and why use OptixDenoiserAOVType layer type

Hi! I’m creating an application using OptiX Denoiser and in the example I have come across the use of the “OptixDenoiserAOVType” layer type when adding an Specular AOV to denoise:

if( specularMode )
    layer.type = OPTIX_DENOISER_AOV_TYPE_SPECULAR;
// AOVs are not written when speclarMode is set. A single specular AOV is expected in this mode,
// to keep the sample code simple.
size_t numOut = specularMode ? 1 : 1 + aovs.size();

I did some test, and even if the comment specifies that it doesn’t write AOVs when “Specular mode” is enabled, at least when temporal mode is not being used the Specular AOV is still written along the Beauty. There’s also more types of AOV layers types, like Diffuse or Beauty. So, my doubts are:

  • What’s the benefit of setting the layer type?
  • It would be better to set the type when the specific AOV is provided?
  • It would affect anything if for example I set the Beauty/Color layer with “OPTIX_DENOISER_AOV_TYPE_BEAUTY” and AOV mode is not being used (no extra AOV is provided)?
  • In what cases the AOVs would not be written when using the layer types, if at all?

Thanks in advance!

Here’s the explanation from the author about what the OptiX SDK optixDenoiser example demonstrates with the specularMode:

The specular mode (-S in the example) helps to reduce ghosting of specular highlights in temporal denoising.

At the same time, this mode could also be used to significantly reduce ghosting of moving objects behind glass where motion vectors are often undefined, depending on the application.
You could for example specify images containing addition of reflection and refraction AOVs generated by the application.

In temporal mode, the SDK sample will not create AOVs if -S is given. This mode applies only to temporal denoising.
In static mode -S does not make sense (the sample should actually check for it).

Thanks for the explanation!

What about the other layer types? If for example I set the layer type if the corresponding AOV is given (diffuse, refraction, etc.) but denoising an static image, it would have any effect or the denoiser would simply ignore the setting unless temporal mode is used?

In other words, when it is recommended to specify the layer type?

Does this excerpt from the OptiX Programming Guide AI Denoiser chapter answer it?

OPTIX_DENOISER_MODEL_KIND_AOV

"Separate passes can be defined by many rendering systems using arbitrary output variables, or AOVs.
AOV images from a rendering system can contain diffuse, emission, glossy, specular or other types of data.
High dynamic range AOV images can be passed as input layers to optixDenoiserInvoke in addition to the beauty, RGB, albedo and normal images.
The AOV mode can be used to denoise multiple layers simultaneously and may reduce processing time.

After denoising, the denoised output layers can be composited to a noise-free beauty layer, typically by adding all RGB values from the denoised layers.

The first OptixDenoiserLayer in the list of layers passed to optixDenoiserInvoke is the noisy beauty image. Subsequent layers in this list are noisy AOVs.
A noisy beauty image is required in all modes of OptixDenoiserModelKind and the denoised image for each given layer is written back in OptixDenoiserLayer::output.

(Means you can denoise individual input AOV along with the beauty buffer in non-temporal mode in case you have a renderer which, for example, implements light path expressions which are later composited to the final image instead of just using the denoised beauty image.)

For the temporal ghosting reduction with the specular (reflection+refraction) layer, there isn’t a need to specify other layer types then.
The denoiser introduced that specifically for the ghosting reduction and if it’s not about that special purpose, no layer type should be set.