textureSampleGrad
On this page

textureSampleGrad

Function

Samples a float texture through the sampler smp with the explicit gradients ddx and ddy, which have the width of the coordinate, in any stage.

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

Syntax

declare function textureSampleGrad(
tex: texture_2d<f32>,
smp: sampler,
uv: vec2,
ddx: vec2,
ddy: vec2,
): vec4
declare function textureSampleGrad(
tex: texture_2d_array<f32>,
smp: sampler,
uv: vec2,
layer: number,
ddx: vec2,
ddy: vec2,
): vec4
declare function textureSampleGrad(
tex: texture_cube<f32>,
smp: sampler,
dir: vec3,
ddx: vec3,
ddy: vec3,
): vec4
declare function textureSampleGrad(
tex: texture_3d<f32>,
smp: sampler,
coord: vec3,
ddx: vec3,
ddy: vec3,
): vec4
declare function textureSampleGrad(
tex: texture_cube_array<f32>,
smp: sampler,
dir: vec3,
layer: number,
ddx: vec3,
ddy: vec3,
): 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.

Parameters

Return value

vec4

Description

On a texture_2d_array the layer comes before the gradients. Compiles to textureSampleGrad on WGSL and textureGrad on GLSL.

Targets

WGSL
textureSampleGrad(a, b, c, d, e)
GLSL ES 3.00
textureGrad(a, c, d, e)

Examples

See also

Edit this page Report a problem