textureGather
On this page

textureGather

Function

Reads one channel from the four texels a linear filter would blend at the coordinate on mip level 0, through the sampler smp, and returns them as a vec4 in the order (umin,vmax), (umax,vmax), (umax,vmin), (umin,vmin), in any stage.

The signature and the sentence under each name are the compiler's own text at commit 26de7be8.

Syntax

declare function textureGather<E extends TextureElem = f32>(
component: number,
tex: texture_2d<E>,
smp: sampler,
uv: vec2,
): Vec4OfElem<E>
declare function textureGather<E extends TextureElem = f32>(
component: number,
tex: texture_2d_array<E>,
smp: sampler,
uv: vec2,
layer: number,
): Vec4OfElem<E>
declare function textureGather<E extends TextureElem = f32>(
component: number,
tex: texture_cube<E>,
smp: sampler,
dir: vec3,
): Vec4OfElem<E>
declare function textureGather<E extends TextureElem = f32>(
component: number,
tex: texture_cube_array<E>,
smp: sampler,
dir: vec3,
layer: number,
): Vec4OfElem<E>
declare function textureGather(tex: texture_depth_2d, smp: sampler, uv: vec2): vec4
declare function textureGather(tex: texture_depth_2d_array, smp: sampler, uv: vec2, layer: number): vec4
declare function textureGather(tex: texture_depth_cube, smp: sampler, dir: vec3): vec4
declare function textureGather(tex: texture_depth_cube_array, smp: sampler, dir: vec3, layer: number): vec4

A number in a parameter or a return position is the scalar slot. The ambient file declares a GPU scalar as a branded number whose brand is optional, so a literal and any branded scalar both fill it.

type f32 = number & { readonly [f32Tag]?: true }

A declaration you write still needs a width, and a bare number on a field or a parameter is refused; the TypeScript constructs page carries that row with the compiler's own message.

A signature may name a type the ambient file declares for its own use. These are those declarations.

TextureElem
type TextureElem = f32 | i32 | u32

Parameters

Return value

Vec4OfElem<E>vec4

Description

On a colour texture the first argument is the channel, a whole number from 0 to 3 written in the call; a depth texture has one channel and takes none; an array texture takes the layer after the coordinate. Compiles to textureGather on WGSL; GLSL ES 3.00 has no gather, so a module using it emits WGSL alone.

Targets

WGSL
textureGather(a, b, c, d)
GLSL ES 3.00
textureGather has no GLSL ES 3.00 spelling (textureGather is ES 3.10)

Examples

See also

Edit this page Report a problem