---
title: "WGSL scalars, vectors, matrices and their spelling"
description: "The WGSL type surface with the TypeShade spelling of each one: scalars, vectors, matrices, arrays and atomics, textures and samplers."
url: https://typeshade.dev/guide/language/from-wgsl/types/
language: en
---

# Types

A type is written where WGSL writes one, on a declaration, a parameter, a field and a return. The element type rides inside the name where WGSL takes a type argument, so `vec3<u32>` is `vec3u` and there is nothing in angle brackets to get wrong.

## Scalars

WGSL TypeShade

```wgsl
f32
```

```ts
f32
```

```wgsl
i32
```

```ts
i32
```

```wgsl
u32
```

```ts
u32
```

```wgsl
bool
```

```ts
bool
```

```wgsl
f16
```

No type name in this surface. `"enable f16"` beside `"use typeshade"` emits WGSL's `enable f16;`, and the reflection names the capability a host requests as `shader-f16`, but there is still no `f16` to declare a value with.

WGSL has no 64-bit float. The pass below rewrites the declaration before the writer sees it.

```ts
f64
```

A double has no WGSL type behind it. The declaration is written `f64`, and a pass rewrites every one into a pair of `f32` lanes and a library of functions over them before the writer runs. A multiplication of two doubles reaches the WGSL as one call.

```wgsl
let d = df64_mul(vec2<f32>(uv.x, 0.0), vec2<f32>(u.a, 0.0), _fp64_g);
```

## Vectors

WGSL TypeShade

```wgsl
vec3<f32>
```

```ts
vec3
```

```wgsl
vec3<f32>
```

```ts
vec3f
```

```wgsl
vec3<u32>
```

```ts
vec3u
```

```wgsl
vec3<i32>
```

```ts
vec3i
```

```wgsl
vec3<bool>
```

```ts
vec3b
```

WGSL has no 64-bit vector either, and the same pass rewrites this one.

```ts
vec3d
```

`vec2` and `vec4` read the same way as the three above. `vec3` and `vec3f` are one type, and so are `vec3d` and `vec3f64`.

## Matrices

WGSL TypeShade

```wgsl
mat2x2<f32>
```

```ts
mat2x2
```

```wgsl
mat2x3<f32>
```

```ts
mat2x3
```

```wgsl
mat2x4<f32>
```

```ts
mat2x4
```

```wgsl
mat3x2<f32>
```

```ts
mat3x2
```

```wgsl
mat3x3<f32>
```

```ts
mat3x3
```

```wgsl
mat3x4<f32>
```

```ts
mat3x4
```

```wgsl
mat4x2<f32>
```

```ts
mat4x2
```

```wgsl
mat4x3<f32>
```

```ts
mat4x3
```

```wgsl
mat4x4<f32>
```

```ts
mat4x4
```

A square matrix also answers to the short name both targets give it, so `mat4` and `mat4x4` are the same declaration. The `C` and the `R` mean what they mean in WGSL, columns then rows.

## Arrays and atomics

WGSL TypeShade

```wgsl
array<f32, 4>
```

```ts
array<f32, 4>
```

```wgsl
array<f32, 2>
```

```ts
[f32, f32]
```

```wgsl
array<f32>
```

```ts
array<f32>
```

```wgsl
atomic<u32>
```

```ts
atomic<u32>
```

```wgsl
atomic<i32>
```

```ts
atomic<i32>
```

A tuple is a list of a length the type fixes, which is what an array of a known size is, so `[f32, f32]` and `array<f32, 2>` reach the same type. A runtime-sized array and an atomic each live in a storage binding.

## Textures and samplers

WGSL TypeShade

```wgsl
texture_2d<f32>
```

```ts
texture_2d<f32>
```

```wgsl
texture_2d_array<f32>
```

```ts
texture_2d_array<f32>
```

```wgsl
texture_cube<f32>
```

```ts
texture_cube<f32>
```

```wgsl
texture_3d<f32>
```

```ts
texture_3d<f32>
```

```wgsl
texture_1d<f32>
```

```ts
texture_1d<f32>
```

```wgsl
texture_cube_array<f32>
```

```ts
texture_cube_array<f32>
```

```wgsl
texture_multisampled_2d<f32>
```

```ts
texture_multisampled_2d<f32>
```

```wgsl
texture_storage_2d<rgba8unorm, write>
```

```ts
texture_storage_2d<"rgba8unorm", "write">
```

```wgsl
texture_storage_2d_array<rgba8unorm, write>
```

```ts
texture_storage_2d_array<"rgba8unorm", "write">
```

```wgsl
texture_depth_2d
```

```ts
texture_depth_2d
```

```wgsl
texture_depth_2d_array
```

```ts
texture_depth_2d_array
```

```wgsl
texture_depth_cube
```

```ts
texture_depth_cube
```

```wgsl
texture_depth_cube_array
```

```ts
texture_depth_cube_array
```

```wgsl
texture_depth_multisampled_2d
```

```ts
texture_depth_multisampled_2d
```

```wgsl
sampler
```

```ts
sampler
```

```wgsl
sampler_comparison
```

```ts
sampler_comparison
```

```wgsl
texture_2d<u32>
```

```ts
texture_2d<u32>
```

```wgsl
texture_2d<i32>
```

```ts
texture_2d<i32>
```

A texture and a sampler are written bare, with no address-space wrapper, because a handle lives in no address space. A sampled texture takes `f32`, `i32` or `u32`, and the element decides both the WGSL spelling and which reads apply to it. A storage texture takes a format and an access mode as string literal types, which `tsc` checks before this compiler does.
