Skip to content

interpolate

interpolate<TInterpolation, TData>(interpolationType, data): Decorate<TData, Interpolate<TInterpolation>>

Specifies how user-defined vertex shader output (fragment shader input) must be interpolated.

Tip: Integer outputs cannot be interpolated.

TInterpolation extends "linear" | "perspective" | "linear, center" | "linear, centroid" | "linear, sample" | "perspective, center" | "perspective, centroid" | "perspective, sample"

TData extends PerspectiveOrLinearInterpolatableData

TInterpolation

How data should be interpolated.

TData

The data-type to wrap.

Decorate<TData, Interpolate<TInterpolation>>

const VertexOutput = {
a: d.f32, // has implicit 'perspective, center' interpolation
b: d.interpolate('linear, sample', d.f32),
};

packages/typegpu/src/data/attributes.ts:243

interpolate<TInterpolation, TData>(interpolationType, data): Decorate<TData, Interpolate<TInterpolation>>

Specifies how user-defined vertex shader output (fragment shader input) must be interpolated.

Tip: Default sampling method of flat is first. Unless you specifically need deterministic behavior provided by 'flat, first', prefer explicit 'flat, either' as it could be slightly faster in hardware.

TInterpolation extends "flat" | "flat, first" | "flat, either"

TData extends FlatInterpolatableData

TInterpolation

How data should be interpolated.

TData

The data-type to wrap.

Decorate<TData, Interpolate<TInterpolation>>

const VertexOutput = {
a: d.f32, // has implicit 'perspective, center' interpolation
b: d.interpolate('flat, either', d.u32), // integer outputs cannot interpolate
};

packages/typegpu/src/data/attributes.ts:268