textureSampleBias
Function
A mip bias shifts the detail level inferred from nearby fragments. A positive bias favours coarser detail.
Compare examples
Compare the same coordinate with different biases. The model starts with an implicit level at the base mip.
Model assumptionsuv = vec2(0.25, 0.25); filter = linear; mip = nearest; levels = [2 × 2, 1 × 1]
Example 1implicit = 0; bias = 0
0.75100.25 - Result
0
Example 2implicit = 0; bias = 1
0.5 - Result
0.5
Example 3implicit = 0; bias = -1
0.75100.25 - Result
0
The examples are calculation models and do not run GPU work. The reference below gives the complete call signatures. Decimal results are rounded for display. The stated assumptions determine each example; actual shader results follow the target precision and execution rules.
When to use it
Use it to soften a texture lookup or tune the balance between sharpness and aliasing.
Inputs and limits
The actual implicit level depends on fragment derivatives and sampler limits. Bias is a relative shift, not an absolute mip index; this call is fragment-only.
For shader input rules and precision, consult WGSL and GLSL ES 3.00.
Related functions
- WGSL
textureSampleBias(a, b, c, d)- GLSL ES 3.00
texture(a, c, d)
The signature, the sentence and any message are the compiler's own text at commit af54ddad5.
Samples a float texture through the sampler smp with the implicit level of detail shifted by bias, in the fragment stage only; the coordinate is a vec2 on a texture_2d and a vec3 on a texture_cube or a texture_3d.
Syntax
declare function textureSampleBias(tex: texture_2d<f32>, smp: sampler, uv: vec2, bias: number): vec4declare function textureSampleBias( tex: texture_2d_array<f32>, smp: sampler, uv: vec2, layer: number, bias: number,): vec4declare function textureSampleBias( tex: texture_cube<f32>, smp: sampler, dir: vec3, bias: number,): vec4declare function textureSampleBias( tex: texture_3d<f32>, smp: sampler, coord: vec3, bias: number,): vec4declare function textureSampleBias( tex: texture_cube_array<f32>, smp: sampler, dir: vec3, layer: number, bias: 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 number you write as a type is inferred from its uses, and f32, i32 and u32 fix a width; the TypeScript constructs page carries that row with the compiler's emit.
Parameters
-
textexture_2d<f32>texture_2d_array<f32>texture_cube<f32>texture_3d<f32>texture_cube_array<f32> -
smpsampler -
uvoptionalvec2 -
diroptionalvec3 -
coordoptionalvec3 -
biasnumber -
layeroptionalnumber
Return value
Description
On a texture_2d_array the layer comes before the bias. Compiles to textureSampleBias on WGSL and to texture with a bias argument on GLSL.
Targets
- WGSL
-
textureSampleBias(a, b, c, d) - GLSL ES 3.00
-
texture(a, c, d)