---
title: "hostFieldTexture"
description: "The texture a JavaScript-stepped grid is read through."
group: "simulation"
groupTitle: "Simulation"
categoryId: "sim.grids"
categorySlug: "sim-grids"
categoryTitle: "Grid programs"
kind: "function"
sourceUrl: "https://github.com/shader-effects-inc/shaders/blob/main/packages/core/src/std/sim/grids.ts#L491"
---

# hostFieldTexture

The texture a JavaScript-stepped grid is read through.

```ts
hostFieldTexture(
  params: GpuFragmentParams,
  opts: {size: number; label: string},
): {texData: Uint16Array; texture: ReturnType<GpuFragmentParams['registerMediaTexture']>; upload(): void}
```

Import `sim` from `shaders/std` and use `sim.grids.hostFieldTexture`.

Pack the cells into `texData` (four half-floats per cell, row by row), call `upload()`, and sample `texture` in the fragment.

`size` is the grid's side in cells. The texture filters smoothly, so a coarse grid reads as a continuous field.

## Parameters

| Name | Type | Notes |
|---|---|---|
| `params` | `GpuFragmentParams` |  |
| `opts` | `{size: number; label: string}` |  |

## Example

```ts
const field = hostFieldTexture(params, {size: 32, label: 'flow'})
```

> **Tip.** Values go in as half-floats: convert each number with `toHalfFloat` before writing it into `texData`.

## See also

- [`hostGridProgram`](/docs/primitives/sim-grids/hostgridprogram) — A frame program for a small grid stepped in plain JavaScript: the steps run in order every frame until one returns `'skip'`.

## Used by

[ChromaFlow](/docs/components/chromaflow), [PixelThrow](/docs/components/pixelthrow)