---
title: "r3SubCellOffset"
description: "A tiny offset for frame `frameIdx`, within one grid `cell`, that `force.pressure` reads to keep its density grid from lining up with the shape."
group: "simulation"
groupTitle: "Simulation"
categoryId: "sim.agentFrame"
categorySlug: "sim-agentframe"
categoryTitle: "Agent frame"
kind: "function"
sourceUrl: "https://github.com/shader-effects-inc/shaders/blob/main/packages/core/src/std/sim/agentFrame.ts#L266"
---

# r3SubCellOffset

A tiny offset for frame `frameIdx`, within one grid `cell`, that `force.pressure` reads to keep its density grid from lining up with the shape.

```ts
r3SubCellOffset(frameIdx: number, cell: number): {x: number; y: number; z: number}
```

Import `sim` from `shaders/std` and use `sim.agentFrame.r3SubCellOffset`.

Increment the frame index each frame.

## Parameters

| Name | Type | Notes |
|---|---|---|
| `frameIdx` | `number` |  |
| `cell` | `number` |  |

## Example

```ts
const gridOff = agentFrame.r3SubCellOffset(frameIdx++, cellSize)
```

## See also

- [`force`](/docs/primitives/sim-agentforces/force) — The pushes an agent can feel.