---
title: "textureSampleBias: WGSL and GLSL function guide"
description: "A mip bias shifts the detail level inferred from nearby fragments. A positive bias favours coarser detail."
url: https://typeshade.dev/reference/functions/textureSampleBias/
language: en
---

# `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 assumptions**`uv = vec2(0.25, 0.25); filter = linear; mip = nearest; levels = [2 × 2, 1 × 1]`

**Example 1`implicit = 0; bias = 0`**

`0.75` `1` `0` `0.25`

Texel grid. The upper row has the higher vertical texture coordinate. Values describe one channel; comparison grids show pass or fail.

**Result**

`0`

**Example 2`implicit = 0; bias = 1`**

`0.5`

Texel grid. The upper row has the higher vertical texture coordinate. Values describe one channel; comparison grids show pass or fail.

**Result**

`0.5`

**Example 3`implicit = 0; bias = -1`**

`0.75` `1` `0` `0.25`

Texel grid. The upper row has the higher vertical texture coordinate. Values describe one channel; comparison grids show pass or fail.

**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](https://www.w3.org/TR/WGSL/) and [GLSL ES 3.00](https://registry.khronos.org/OpenGL/specs/es/3.0/GLSL_ES_Specification_3.00.pdf).

## Related functions

- [`textureSample`](https://typeshade.dev/reference/functions/textureSample/)
- [`textureLoad`](https://typeshade.dev/reference/functions/textureLoad/)
- [`textureSampleLevel`](https://typeshade.dev/reference/functions/textureSampleLevel/)
- [`textureSampleGrad`](https://typeshade.dev/reference/functions/textureSampleGrad/)
- [`textureGather`](https://typeshade.dev/reference/functions/textureGather/)

**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

```ts
declare function textureSampleBias(tex: texture_2d<f32>, smp: sampler, uv: vec2, bias: number): vec4
declare function textureSampleBias(
  tex: texture_2d_array<f32>,
  smp: sampler,
  uv: vec2,
  layer: number,
  bias: number,
): vec4
declare function textureSampleBias(
  tex: texture_cube<f32>,
  smp: sampler,
  dir: vec3,
  bias: number,
): vec4
declare function textureSampleBias(
  tex: texture_3d<f32>,
  smp: sampler,
  coord: vec3,
  bias: number,
): vec4
declare function textureSampleBias(
  tex: texture_cube_array<f32>,
  smp: sampler,
  dir: vec3,
  layer: number,
  bias: 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 `number` you write as a type is inferred from its uses, and `f32`, `i32` and `u32` fix a width; [the TypeScript constructs page](https://typeshade.dev/guide/language/from-typescript/) carries that row with the compiler's emit.

## Parameters

- `tex` `texture_2d<f32>``texture_2d_array<f32>``texture_cube<f32>``texture_3d<f32>``texture_cube_array<f32>`
- `smp` `sampler`
- `uv` optional `vec2`
- `dir` optional `vec3`
- `coord` optional `vec3`
- `bias` `number`
- `layer` optional `number`

## Return value

`vec4`

## 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.

The CPU oracle has no texture memory and no neighbouring fragments. The call throws unless the module was compiled with `{ gpuStubs: true }`, which returns a placeholder.

## Targets

**WGSL**

`textureSampleBias(a, b, c, d)`

**GLSL ES 3.00**

`texture(a, c, d)`

## Examples

- [`gallery/cube-env/cube-env.shade.ts`](https://typeshade.dev/guide/examples/cube-env/)

## See also

- [Functions](https://typeshade.dev/reference/functions/)
- [Builtin table](https://typeshade.dev/guide/language/builtins/#textures)
