Skip to content

Subdivide Shape

Fills the interior of closed shapes with a Delaunay-triangulated mesh. Designed for smooth per-vertex color gradients via ShapeAttributes.

Category: Shape Ops Menu path: Shape Ops > SubdivideShape

Ports

PortTypeDirectionDescription
shape_inshapeinputShape to subdivide
outshapeoutputShape with interior mesh

Parameters

ParamTypeDefaultDescription
gridSizescalar20Approximate spacing in pixels between interior mesh vertices (minimum 5px, 50K triangle cap)

How It Works

SubdivideShape takes closed paths and fills their interiors with a dense triangle mesh using Delaunay triangulation. The process:

  1. Resamples the boundary at the gridSize interval
  2. Generates a hex-packed interior point grid
  3. Filters interior points using point-in-polygon testing
  4. Runs Delaunay triangulation on all boundary + interior points
  5. Outputs the resulting mesh as shape paths (one triangle per path)

The output is a shape with many small triangular paths covering the interior. When combined with ShapeAttributes and a field source (Gradient, Noise, DistanceField), each triangle vertex gets its own color, and DrawShape's per-vertex color pipeline renders smooth GPU-interpolated gradients across the surface.

Open paths pass through unchanged. The triangle count is capped at 50,000 to prevent runaway computation.

Usage Examples

Basic: Shape with gradient fill

Rectangle -> SubdivideShape (gridSize: 15) -> ShapeAttributes (target: Color, field: Gradient.colorField) -> DrawShape. The rectangle is filled with a smooth color gradient that follows the Gradient node's spatial mapping.

Distance-based coloring

Circle -> SubdivideShape -> ShapeAttributes (target: Color, field: DistanceField.colorField) -> DrawShape. Colors vary smoothly from the shape's boundary inward, driven by the signed distance field.

Animated noise colors

Rectangle -> SubdivideShape -> ShapeAttributes (target: Color, field: Noise.scalarField) -> Colorize -> DrawShape. Noise drives per-vertex luminance, Colorize maps it through a color ramp. Animate Noise evolution for shifting colors.

Tips

  • Smaller gridSize produces denser meshes with smoother gradients but higher triangle count
  • Only closed paths are subdivided -- open paths pass through as-is
  • SubdivideShape is specifically designed for the per-vertex color pipeline in DrawShape. Without ShapeAttributes assigning per-vertex color, the triangles will all render the same uniform color.
  • The 50K triangle cap prevents performance issues. If you hit the cap, increase gridSize.
  • For per-path (not per-vertex) coloring, you don't need SubdivideShape -- use CloneToPoints with ShapeAttributes instead
  • ShapeAttributes -- assigns per-vertex colors from fields onto the subdivided mesh
  • DrawShape -- renders the per-vertex color mesh with GPU interpolation
  • ResampleShape -- resamples paths along their arc length (different from interior subdivision)
  • DistanceField -- SDF field source for distance-based vertex coloring