---
title: "shapedSurface"
description: "Turns a shape prop into a surface your material shades."
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#L237"
---

# shapedSurface

Turns a shape prop into a surface your material shades.

```ts
shapedSurface(spec: ShapedSurfaceSpec): ShapedSurfaceEffect
```

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

Spread the result into a definition that declares the `center`, `scale`, `rotation` and `shape` props (copy them from any shape effect). Your `surface` function receives a `SurfaceFrame` and returns the color at this pixel. Flat shapes, SVG shapes and 3D shapes all arrive through the same frame.

## Parameters

| Name | Type | Notes |
|---|---|---|
| `spec` | `ShapedSurfaceSpec` |  |

## Example

```ts
...shapedSurface({
  pattern: 'raw',
  surface: (frame, params) => {
    const u = params.uniforms
    const field = surfaceField(frame, params, {scale: u.scale})
    const n = geometricNormal(frame, field, {bevelWidth: u.bevelWidth, bevelShape: u.bevelShape})
    const key = keyLightAt(direction(u.lightAngle), -0.7)
    const rgb = mul(u.color.member('rgb'), lambert(n, key.member('L'), {wrap: 0.3}))
    return guarded(insideShape(field.sdf, field.pxH), vec4(rgb, silhouette(field, u.edgeSoftness)), vec4(0, 0, 0, 0))
  },
}),
```

> **Tip.** Start from `surfaceField`, end with `guarded` around `insideShape`. Everything between is the look.

## See also

- [`surfaceField`](/docs/primitives/materials/surfacefield) — The first line of a material: the field taps, the signed distance and the pixel size, bound once.
- [`geometricNormal`](/docs/primitives/materials/geometricnormal) — The surface normal of the shape, whichever kind of shape is active.
- [`silhouette`](/docs/primitives/materials/silhouette) — The shape's coverage at this pixel: 1 inside, 0 outside, soft across the edge.
- [`guarded`](/docs/primitives/materials/guarded) — Evaluates an expression only where a condition holds, and a cheap fallback everywhere else.

## Used by

[BrushedMetal](/docs/components/brushedmetal), [CarbonFiber](/docs/components/carbonfiber), [Chrome](/docs/components/chrome), [Crystal](/docs/components/crystal), [Emboss](/docs/components/emboss), [Frost](/docs/components/frost), [Glass](/docs/components/glass), [Goo](/docs/components/goo), [Heatmap](/docs/components/heatmap), [Hologram](/docs/components/hologram), [Holographic](/docs/components/holographic), [Irradiance](/docs/components/irradiance), [LightEdge](/docs/components/lightedge), [LiquidMetal](/docs/components/liquidmetal), [Nebula](/docs/components/nebula), [Neon](/docs/components/neon), [Obsidian](/docs/components/obsidian), [Plastic](/docs/components/plastic), [ThinFilm](/docs/components/thinfilm), [Water](/docs/components/water)