Open Search
    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;
    Definition: basearray.h:414
    ResultMem Resize(Int newCnt, COLLECTION_RESIZE_FLAGS resizeFlags=COLLECTION_RESIZE_FLAGS::DEFAULT)
    Resizes the array to contain newCnt elements. If newCnt is smaller than GetCount() all extra elements...
    Definition: basearray.h:1231
    PyObject * x
    Definition: bytesobject.h:38
    void Py_ssize_t * pos
    Definition: dictobject.h:50
    Py_ssize_t char * output
    Definition: unicodeobject.h:985
    #define MAXON_SCOPE
    Definition: apibase.h:2922
    maxon::Float32 Float32
    Definition: ge_sys_math.h:59
    maxon::UInt16 UInt16
    Definition: ge_sys_math.h:50
    maxon::Int32 Int32
    Definition: ge_sys_math.h:51
    maxon::Int Int
    Definition: ge_sys_math.h:55
    maxon::UInt32 UInt32
    Definition: ge_sys_math.h:52
    const char const char grammar * g
    Definition: parsetok.h:52
    unsigned long Py_ssize_t width
    Definition: pycore_traceback.h:88
    #define iferr_return
    Definition: resultbase.h:1531
    A vector consisting of four components X, Y, Z and W.
    Definition: vec4.h:21

    Further Reading