---
title: "insideShape"
description: "True inside the shape and up to two pixels outside it."
group: "light"
groupTitle: "Noise, light & materials"
categoryId: "materials"
categorySlug: "materials"
categoryTitle: "Materials & surfaces"
kind: "function"
sourceUrl: "https://github.com/shader-effects-inc/shaders/blob/main/packages/core/src/std/paint/materials.ts#L131"
---

# insideShape

True inside the shape and up to two pixels outside it.

```ts
insideShape(sdf: Expr, pxH: Expr): Expr
```

Import `materials` from `shaders/std` and use `materials.insideShape`.

Pass the signed distance and pixel size from `surfaceField`. The two-pixel margin keeps the anti-aliased edge inside the shaded region. The usual condition for `guarded`.

## Parameters

| Name | Type | Notes |
|---|---|---|
| `sdf` | `Expr` |  |
| `pxH` | `Expr` |  |

## Example

```ts
guarded(insideShape(field.sdf, field.pxH), shaded, vec4(0, 0, 0, 0))
```

## See also

- [`guarded`](/docs/primitives/materials/guarded) — Evaluates an expression only where a condition holds, and a cheap fallback everywhere else.
- [`silhouette`](/docs/primitives/materials/silhouette) — The shape's coverage at this pixel: 1 inside, 0 outside, soft across the edge.

## Used by

[BrushedMetal](/docs/components/brushedmetal), [CarbonFiber](/docs/components/carbonfiber), [Chrome](/docs/components/chrome), [Frost](/docs/components/frost), [Hologram](/docs/components/hologram), [Holographic](/docs/components/holographic), [Irradiance](/docs/components/irradiance), [LiquidMetal](/docs/components/liquidmetal), [Nebula](/docs/components/nebula), [Obsidian](/docs/components/obsidian), [Plastic](/docs/components/plastic), [Water](/docs/components/water)