Skip to content

interpolate

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

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

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

Tip: Integer outputs cannot be interpolated.

TInterpolation extends "perspective" | "linear" | "perspective, center" | "perspective, centroid" | "perspective, sample" | "linear, center" | "linear, centroid" | "linear, 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),
};

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

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

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
};