---
title: "clothCoords"
description: "Where on the unfolded cloth a point lands: the material coordinates to draw a pattern in, so it follows the folds instead of floating over them."
group: "light"
groupTitle: "Noise, light & materials"
categoryId: "noise"
categorySlug: "noise"
categoryTitle: "Noise"
kind: "function"
sourceUrl: "https://github.com/shader-effects-inc/shaders/blob/main/packages/core/src/std/paint/noise.ts#L299"
---

# clothCoords

Where on the unfolded cloth a point lands: the material coordinates to draw a pattern in, so it follows the folds instead of floating over them.

```ts
clothCoords(
  coords: {along: Expr | number; across: Expr | number},
  folds: Fold[],
  opts: DrapeOptions & {foreshorten?: number},
): {along: Expr; across: Expr}
```

Import `noise` from `shaders/std` and use `noise.clothCoords`.

Takes the same `coords`, `folds` and options as `drapedFolds`. The cloth riding each ridge moves sideways with its spine, and each flank uses up cloth, so a pattern drawn in these coordinates bends with the ripples and bunches on the steep sides of every ridge. `foreshorten` (default 0.25) is how much cloth a flank consumes. Rebuild a point from the result with the drape's frame and hand it to a grain word in place of the screen point.

## Parameters

| Name | Type | Notes |
|---|---|---|
| `coords` | `{along: Expr \| number; across: Expr \| number}` |  |
| `folds` | `Fold[]` |  |
| `opts` | `DrapeOptions & {foreshorten?: number}` |  |

## Example

```ts
const m = clothCoords(drape.coordsOf(q), folds, {...drapeOpts, foreshorten: 0.25})
const onCloth = add(mul(drape.tangent, m.along), mul(drape.perp, m.across))
const threads = grainNoise(fibre.coordsOf(onCloth), {freq: [12, 420]})
```

> **Tip.** One more pass over the folds per pixel. Call it once and reuse the point.

## See also

- [`drapedFolds`](/docs/primitives/noise/drapedfolds) — The height of a draped cloth at a point: rounded ridges running along one direction, each rippling and swaying along its length, gathered where the cloth is pinned.
- [`foldSet`](/docs/primitives/noise/foldset) — Lays out the ridges of a draped cloth: `count` folds spread evenly across `spread`, each nudged sideways, widened and raised by a seeded amount so no two are alike.
- [`grainNoise`](/docs/primitives/materials/grainnoise) — One octave of smooth signed noise along and across a direction, for grain.

## Used by

[Satin](/docs/components/satin)