Skip to main content

SeparableFilter

The SeparableFilter class implements a flexible GPU-based filtering system that applies separable convolution operations in horizontal and vertical directions using compute shaders. It allows customization of shader code for input and output stages, supports various filter types including Gaussian, Sobel, and box filters, and enables users to define or normalize custom weights. Filters can be configured with different border handling modes and dispatched efficiently on textures with optional slice and parameter control.

#include <graphics/TellusimSeparableFilter.h>

Constructors

SeparableFilter()

Methods

Clear filter.

void clear()

Check filter.

bool isCreated(Format format, uint32_t size) const

Input shader source.

void setInputSource(Mode mode, const char *src)
String getInputSource(Mode mode) const
TypeNameDescription
const char*srcShader source.

Output shader source.

void setOutputSource(Mode mode, const char *src)
String getOutputSource(Mode mode) const
TypeNameDescription
const char*srcShader source.

Create filter.

bool create(const Device &device, Format format, uint32_t size, Flags flags = DefaultFlags)
TypeNameDescription
FormatformatTexture format.
uint32_tsizeFilter size in pixels, the actual filter size is (size * 2 + 1).

Filter weights.

void setWeights(Mode mode, Array<Vector4f> weights, bool normalize = false)
void setWeights(Mode mode, Array<float32_t> weights, bool normalize = false)

Gaussian filter weights.

void setGaussianWeights(uint32_t size, Vector4f sigma)
void setGaussianWeights(uint32_t size, float32_t sigma)

Sobel filter weights.

void setSobelXWeights(uint32_t size)
void setSobelYWeights(uint32_t size)

Box filter weights.

void setBoxWeights(uint32_t size)

Dispatch separable filter.

bool dispatch(Compute &compute, Mode mode, uint32_t size, Texture &dest, Texture &src, Slice dest_slice, Slice src_slice, Vector4f values = Vector4f::zero) const
bool dispatch(Compute &compute, Mode mode, uint32_t size, Texture &dest, Texture &src, Slice src_slice, Vector4f values = Vector4f::zero) const
bool dispatch(Compute &compute, Mode mode, uint32_t size, Texture &dest, Texture &src, Vector4f values = Vector4f::zero) const
TypeNameDescription
TexturedestDestination texture.
TexturesrcSource texture.
Slicedest_sliceDestination texture slice.
Slicesrc_sliceSource texture slice.
Vector4fvaluesFilter parameters available for the source blocks.

Enums

Mode

Filter modes.

NameValueDescription
ModeHorizontal0Horizontal filter.
ModeVertical1Vertical filter.
NumModes2

Flags

Filter flags.

NameValueDescription
FlagNone0
FlagRepeat(1 << 0)Repeat border.
FlagZero(1 << 1)Zero border.
DefaultFlagsFlagNone