util-lanczos

This contains the function and coefficients to perform a 2x Lanczos downsample along a specific direction (either horizontal or vertical).

The code has been optimized to take advantage of linear texture filtering (using the same technique used to generate the gaussian filters at https://drilian.com/gaussian-kernel/, using 4 texture samples for an 8-tap filter.

Index

Constants

Functions

Constants

float k_coeffs[4]
An array of coefficients to use for the downsample. Each entry of this table is multiplied with the result of a single sample of the input texture.
float k_offsets[4]
An array of texture coordinate offsets to use for the downsample, in texels. Each value is scaled down to standard texture coordinate space then added to the texture coordinate before each sample of the input texture.

Functions

Lanczos2xDownsample
                float4 Lanczos2xDownsample(
                  DECLARE_TEXTURE2D_AND_SAMPLER_PARAM(sourceTexture, samp),
                  float2 centerTexCoord,
                  float2 filterDir)
              
Description

Perform a 2x Lanczos downsample along a specific direction (either horizontal or vertical).

Called by downsample-2x and tonemap-and-downsample.

Parameters
sourceTexture, samp

Type: DECLARE_TEXTURE2D_AND_SAMPLER_PARAM

A texture and sampler pair used to sample the texture to be filtered.

centerTexCoord

Type: float2

The texture coordinate for the center of the filter.

filterDir

Type: float2

The direction of the filter: (1, 0) for a horizontal downsample and (0, 1) for a vertical downsample.

Return Value
Type: float4

The result of the 2x downsample.