Radeon ProRender

User Defined Filter

Filter

RIF_IMAGE_FILTER_USER_DEFINED

Description

An arbitrary user defined filter. Can be used to add missing image processing tools to the library.

Parameters

Parameter Type Input/Output Description
code string input User defined code.
declarations string input User defined declarations.

Usage Example

rif_image_filter filter = nullptr;
rifContextCreateImageFilter(nullptr, RIF_IMAGE_FILTER_USER_DEFINED, &filter);
const rif_char declarations[] =
                  "__constant vec4 const_v4[] = { (vec4)(0.0f, 0.0f, 0.0f, 0.0f) };"
                  "vec4 func() { return const_v4[0]; }";
const rif_char code[] =
                  "int2 coord;"
                  "GET_COORD_OR_RETURN(coord, GET_BUFFER_SIZE(outBuf));"
                  "vec4 pixel = ReadPixelTyped(inBuf, coord.x, coord.y);"
                  "pixel.xy += convert_vec2(coord.xy) * 0.01f;"
                  "pixel      += func()     ;"
                  "WritePixelTyped(outBuf, coord.x, coord.y, pixel);";

rifImageFilterSetParameterString(filter, "code", code);
rifImageFilterSetParameterString(filter, "declarations", declarations);
rifCommandQueueAttachImageFilter(queue, filter, inputImage, outputImage);
rifContextExecuteCommandQueue(context, queue, nullptr, nullptr, nullptr);

Results

Input image

Output image