Render Filter

About

Render filters are used to post-process rendered images. They are currently used to implement the denoiser filter.

The filter interfaces are defined in the render_filter.framework.

FilterContex

A FilterContexRef is the central class to create and use images, filters and queues.

Context implementations are found at the maxon::FilterContextClasses registry:

  • maxon::FilterContextClasses::OIDNCONTEXT: Open Image Denoiser context implementation.

Queue

A command queue allows queuing of multiple filters.

Queue implementations are found at the maxon::FilterCommandQueueClasses registry:

  • maxon::FilterCommandQueueClasses::OIDNFILTERCOMMANDQUEUE: Open Image Denoiser queue implementation.

Filter

The maxon::FilterInterface allows to use a render filter.

Filter implementations are found at the maxon::FilterClasses registry:

  • maxon::FilterClasses::OIDNFILTERRT: Intel Denoiser Raytracing implementation.

FilterImage

A filter image contains the actual image data.

Image implementations are found at the maxon::FilterImageClasses registry:

  • maxon::FilterImageClasses::OIDNFILTERIMAGE: Open Image Denoiser image implementation.

An image is created with maxon::FilterContextInterface::CreateImage() using these parameters:

  • maxon::FilterImageDescriptionParameters::WIDTH: Image width.
  • maxon::FilterImageDescriptionParameters::HEIGHT: Image height.

Open Image Denoiser parameters

The Open Image Denoiser filter can further be configured with these parameters:

  • maxon::OIDNFilterParameter::HDR: If the input data is in hight dynamic range.
  • maxon::OIDNFilterParameter::SRGB: True if the color data is in sRGB.
  • maxon::OIDNFilterParameter::ALBEDO: Albedo buffer.
  • maxon::OIDNFilterParameter::NORMAL: Normal buffer.

Example

// This example copies the given BaseBitmap into the color buffer and
// applies the Intel denoiser filter to the image.
// source image buffer
bufferColor.Resize(pixelCount) iferr_return;
// target image buffer
bufferDenoised.Resize(pixelCount) iferr_return;
// covnert BaseBitmap to array
{
Int pos = 0;
for (Int32 y = 0; y < height; ++y)
{
for (Int32 x = 0; x < width; ++x)
{
UInt16 r, g, b = 0;
bitmap->GetPixel(x, y, &r, &g, &b);
const Float32 rf = Float32(r) / 255.9f;
const Float32 gf = Float32(g) / 255.9f;
const Float32 bf = Float32(b) / 255.9f;
const maxon::Vector4d32 color { rf, gf, bf, 1.00f };
bufferColor[pos] = color;
++pos;
}
}
}
// get context for Intel Open Image Denoise
maxon::FilterContextRef filterContext = maxon::FilterContextClasses::OIDNCONTEXT().Create() iferr_return;
filterContext.Init() iferr_return;
// create command queue
maxon::FilterCommandQueueRef commandQueue = filterContext.CreateCommandQueue() iferr_return;
// create filter
maxon::FilterRef filter = filterContext.CreateFilter(maxon::FilterClasses::OIDNFILTERRT.GetId()) iferr_return;
// create images
maxon::DataDictionary imgDesc;
imgDesc.Set(maxon::FilterImageDescriptionParameters::WIDTH, static_cast<UInt32>(width)) iferr_return;
imgDesc.Set(maxon::FilterImageDescriptionParameters::HEIGHT, static_cast<UInt32>(height)) iferr_return;
maxon::FilterImageRef beauty = filterContext.CreateImage(imgDesc) iferr_return;
maxon::FilterImageRef output = filterContext.CreateImage(imgDesc) iferr_return;
// Load image data
beauty.ReadFromCPUMemory(bufferColor) iferr_return;
// execute queue
commandQueue.AttachFilter(filter, beauty, output) iferr_return;
filterContext.ExecuteCommandQueue(commandQueue) iferr_return;
// get result image
output.WriteToBuffer(bufferDenoised) iferr_return;

Further Reading

Int
maxon::Int Int
Definition: ge_sys_math.h:49
UInt32
maxon::UInt32 UInt32
Definition: ge_sys_math.h:46
Float32
maxon::Float32 Float32
Definition: ge_sys_math.h:53
maxon::BaseArray::Resize
ResultMem Resize(Int newCnt, COLLECTION_RESIZE_FLAGS resizeFlags=COLLECTION_RESIZE_FLAGS::DEFAULT)
Definition: basearray.h:1077
maxon::Vec4
A vector consisting of four components X, Y, Z and W.
Definition: vec4.h:14
iferr_return
#define iferr_return
Definition: resultbase.h:1434
maxon::BaseArray
Definition: basearray.h:366
UInt16
maxon::UInt16 UInt16
Definition: ge_sys_math.h:44
Int32
maxon::Int32 Int32
Definition: ge_sys_math.h:45
BaseBitmap::GetPixel
void GetPixel(Int32 x, Int32 y, UInt16 *r, UInt16 *g, UInt16 *b) const
Definition: c4d_basebitmap.h:678
MAXON_SCOPE
#define MAXON_SCOPE
Definition: apibase.h:2603