textureSampleCompare
On this page

textureSampleCompare

Function

Compares the reference depth ref against the shadow map at uv through the comparison sampler smp, with the implicit level of detail, in the fragment stage only; returns an f32, how much of the filter footprint passed.

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

Syntax

declare function textureSampleCompare(
tex: texture_depth_2d,
smp: sampler_comparison,
uv: vec2,
ref: number,
): f32
declare function textureSampleCompare(
tex: texture_depth_2d_array,
smp: sampler_comparison,
uv: vec2,
layer: number,
ref: number,
): f32
declare function textureSampleCompare(
tex: texture_depth_cube,
smp: sampler_comparison,
dir: vec3,
ref: number,
): f32
declare function textureSampleCompare(
tex: texture_depth_cube_array,
smp: sampler_comparison,
dir: vec3,
layer: number,
ref: number,
): f32

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

f32

Description

On a texture_depth_2d_array the layer comes before the reference, and on a texture_depth_cube the coordinate is a vec3 direction. Compiles to textureSampleCompare on WGSL and texture(sampler2DShadow, vec3(uv, ref)) on GLSL, where the reference folds into the coordinate.

Targets

WGSL
textureSampleCompare(a, b, c, d)
GLSL ES 3.00
texture(a, vec3(c, d))

Examples

See also

Edit this page Report a problem