textureSampleLevel
Function
Samples a float texture through the sampler smp at an explicit mip level, in any stage; the coordinate is a vec2 on a texture_2d and a vec3 on a texture_cube or a texture_3d.
The signature and the sentence under each name are the compiler's own text at commit 26de7be8.
Syntax
declare function textureSampleLevel( tex: texture_2d<f32>, smp: sampler, uv: vec2, level: number,): vec4declare function textureSampleLevel( tex: texture_2d_array<f32>, smp: sampler, uv: vec2, layer: number, level: number,): vec4declare function textureSampleLevel( tex: texture_cube<f32>, smp: sampler, dir: vec3, level: number,): vec4declare function textureSampleLevel( tex: texture_3d<f32>, smp: sampler, coord: vec3, level: number,): vec4declare function textureSampleLevel(tex: texture_1d<f32>, smp: sampler, coord: number, level: number): vec4declare function textureSampleLevel( tex: texture_cube_array<f32>, smp: sampler, dir: vec3, layer: number, level: number,): vec4A 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
-
textexture_2d<f32>texture_2d_array<f32>texture_cube<f32>texture_3d<f32>texture_1d<f32>texture_cube_array<f32> -
smpsampler -
uvoptionalvec2 -
diroptionalvec3 -
coordoptionalvec3number -
levelnumber -
layeroptionalnumber
Return value
Description
On a texture_2d_array the layer comes before the level. Compiles to textureSampleLevel on WGSL and textureLod on GLSL.
Targets
- WGSL
-
textureSampleLevel(a, b, c, d) - GLSL ES 3.00
-
textureLod(a, c, d)