---
title: "TextureElem: type in Types, TypeShade API reference"
description: "TextureElem, a type in Types. The element type of a sampled texture: WGSL's texture_2d<T> type parameter, or GLSL ES 3.00's sampler prefix."
url: https://typeshade.dev/api/textureelem/
language: en
---

# `TextureElem`

Type in Types

The element type of a sampled texture: WGSL's `texture_2d`<T> type parameter, or GLSL ES 3.00's sampler prefix.

`import type { TextureElem } from 'typeshade'`
`import type { TextureElem } from 'typeshade/core/ir'`

The signature, the description and the examples come from the compiler's own source at commit af54ddad5.

## Syntax

```ts
type TextureElem = 'f32' | 'u32' | 'i32';
```

## Description

All three are core in both targets.

An integer texture is unfilterable: interpolating integer texels is undefined, and WGSL rejects `textureSample` on a `texture_2d<u32>`. GLSL would accept `texture(usampler2D, …)` with nearest filtering, but a construct that compiles on WebGL2 and cannot be expressed on WebGPU is what authoring once for both targets is meant to rule out. Read an integer texture with [`textureLoad`](https://typeshade.dev/api/textureload/), [`textureDimensions`](https://typeshade.dev/api/texturedimensions/) and [`textureNumLayers`](https://typeshade.dev/api/texturenumlayers/); [`textureSample`](https://typeshade.dev/api/texturesample/) and [`textureSampleLevel`](https://typeshade.dev/api/texturesamplelevel/) on an integer key are `tsc` errors.

## See also

- [`textureLoad`](https://typeshade.dev/api/textureload/)
- [`textureDimensions`](https://typeshade.dev/api/texturedimensions/)
- [`textureNumLayers`](https://typeshade.dev/api/texturenumlayers/)
- [`textureSample`](https://typeshade.dev/api/texturesample/)
- [`textureSampleLevel`](https://typeshade.dev/api/texturesamplelevel/)

## Source

[`src/core/ir/types/storage-texture.ts`, line 14](https://github.com/typeshade/typeshade/blob/af54ddad5/src/core/ir/types/storage-texture.ts#L14), at commit af54ddad5
