package

github.com/sol-vin/pattern_material

0.1.6 / published Nov 6, 2026 / repository

Pattern Replace ShaderMaterial, 88 repeating SVG patterns, 32-color palette, spritesheet atlas builders, and 14 procedural pattern generators for Godot 4 & Lapis.

Pattern Material for Lapis 🎨

<!-- carbon:badges -->

Version Crystal License: MIT Godot Lapis CI Docs

<!-- /carbon:badges -->

Pattern Material (pattern_material) is a complete procedural and asset-driven pattern replacement material addon for Lapis (Godot Engine 4.8+ Crystal GDExtension bindings).

It combines a stylized Universal Pattern Replace Shader (pattern_replace.gdshader), 88 seamless repeating SVG patterns, 14 parametric procedural PatternGenerator < ImageTexture classes, a 32-color palette, spritesheet atlas builders, and an interactive PatternGeneratorTool editor node so you can customize and bake textures visually or procedurally in code.


Architecture Overview

flowchart TD
    subgraph Generators["Procedural & Asset Patterns"]
        PG["14 PatternGenerator < ImageTexture\n(PolkaDot, Stripe, Checker, Houndstooth, ...)"]
        SVGS["88 Bundled Repeating SVGs\n(Patterns['moroccan'], Patterns['hexagons'], ...)"]
        PAL["32-Color Palette\n(Palette['hot_watermelon'], Palette[0..31])"]
        ATLAS["SpritesheetAtlas\n(Faces, Glyphs, SvgSpritesheetBuilder)"]
    end

    subgraph MaterialLayer["Material & Shader Pipeline"]
        UM["UniversalMaterial / PatternMaterial\n(Fluent Builder API)"]
        PSM["PatternShaderMaterial < ShaderMaterial"]
        SH["pattern_replace.gdshader\n(Duotone Remap, Triplanar, Outlines, Bevel, CRT, Backdrop FX)"]
    end

    subgraph EditorTools["Godot Editor Tools"]
        PGT["PatternGeneratorTool < Node\n(Live Inspector Sliders, Preview & SVG/PNG Export)"]
        PMP["PatternMaterialPlugin < EditorPlugin"]
    end

    PG -->|to_svg / refresh!| UM
    SVGS --> UM
    PAL --> UM
    ATLAS --> UM
    UM --> PSM
    PSM --> SH
    PGT --> PG
    PGT --> PSM

Features

  • Universal Pattern Replace Shader (pattern_replace.gdshader):
    • Duotone Pattern Replacement: Replaces target color channels (replace_color / threshold) with any repeating pattern texture tinted by pattern_fg_color and pattern_bg_color, plus optional remap_unreplaced color remapping.
    • 2D Cutout & 3D Surface Modes: Supports Flat2DCutout, Lit3DSurface, WorldTriplanar, MeshUV, and Cylindrical projection modes, plus spritesheet hframes/vframes/frame indexing.
    • Rich Stylization FX: Animated boiling outlines (Outer, Inner, Center), 2D/3D bevel & rim lighting, Fresnel glow with pattern inversion, drop shadows, Bayer dithering, noise dissolve with glowing edges, and retro CRT scanline/glitch effects.
    • Transparency & Screen-Space Backdrop FX: Master opacity, alpha dither, screen-space refraction, pixelation, blur LOD, chromatic aberration, and 6 backdrop blend modes (Normal, Add, Multiply, Screen, Subtract, DuotonePaletteMap).
    • Vertex FX: Billboard modes (Disabled, Standard, YBillboard), vertex motion (SurfaceWaves3D, FlagWave, Pulse), and PSX-style vertex snapping.
  • 14 Procedural Pattern Generators (PatternGenerator < ImageTexture):
    • Mathematical, seamless repeating SVG generators rasterized at runtime or in the Godot Editor via Image#load_svg_from_string.
    • Every generator exposes typed @[Export] properties in the Godot Inspector and factory methods on Patterns.
  • Visual PatternGeneratorTool Node:
    • Live @[Tool] node for tweaking procedural pattern parameters in the Godot Inspector with instant preview and one-click .svg export.
  • 88 Seamless Repeating SVG Patterns (Patterns):
    • Curated library of 88 Hero Patterns SVGs (moroccan, circuit_board, houndstooth, hexagons, topography, zig_zag, etc.) with normalized key lookup (Patterns["zig-zag"], Patterns[0], Patterns.texture("moroccan")).
  • 32-Color Palette (Palette):
    • Built-in 32-color Afterlife 98 palette (addons/pattern_material/palette.pal and palette.tres) accessible by index (Palette[0]) or name (Palette["hot_watermelon"], Palette["ice_aqua"], Palette["deep_indigo"]).
  • Spritesheet Atlases & Builders (SpritesheetAtlas, Faces, Glyphs, SvgSpritesheetBuilder):
    • Normalize duotone SVGs and pack icon directories into multi-cell SVG/tres SpritesheetAtlas resources.
  • 4 Ready-to-Use Material Presets:
    • cutout_character.tres, sticker_glyph.tres, retro_hologram.tres, and glass_lens.tres bundled in addons/pattern_material/materials/.

Installation

Install pattern_material directly using the Lapis CLI:

# Install pre-compiled release addon from GitHub
lapis install addon github:sol-vin/pattern_material

# Or install from source and add to shard.yml
lapis install addon github:sol-vin/pattern_material --source --shard

Or add pattern_material to your project's shard.yml:

dependencies:
  lapis:
    github: sol-vin/lapis
    branch: 4.8-beta2
  pattern_material:
    github: sol-vin/pattern_material
    branch: main

Then require it in your Crystal code:

require "lapis"
require "pattern_material"
# Or when vendored in addons/:
require "../addons/pattern_material/src/pattern_material"

Quickstart

1. Fluent UniversalMaterial (PatternMaterial) Builder

umat = PatternMaterial.new
  .set_face("smile")
  .set_pattern("moroccan")
  .set_colors(
    fg: "hot_watermelon",
    bg: "ice_aqua",
    outline: "white",
    unreplaced: "deep_indigo"
  )
  .set_3d_surface(
    UniversalMaterial::ProjectionMode::WorldTriplanar,
    use_base_texture: true,
    tile_base_texture: true
  )
  .set_outline(enabled: true, width: 3.5, mode: UniversalMaterial::OutlineMode::Center, boil_amp: 0.2)
  .set_bevel(enabled: true, strength: 0.6)
  .set_fresnel(enabled: true, power: 2.5, invert_pattern: true)

# Apply to any MeshInstance3D, Sprite3D, or GeometryInstance3D
umat.apply_to(mesh_instance)

2. Using Procedural Pattern Generators

# Create a staggered polka-dot pattern texture
dots = Patterns.polka_dots(
  dot_radius: 14.0,
  columns: 3,
  rows: 3,
  stagger: true,
  ring_thickness: 0.0,
  texture_size: 256
)

# Or angled crosshatched stripes
stripes = Patterns.stripes(
  stripe_count: 6,
  duty_cycle: 0.4,
  angle_degrees: 45.0,
  crosshatch: true
)

# Plug directly into UniversalMaterial
umat = PatternMaterial.new
  .set_generator(dots)
  .set_colors(fg: "electric_lemon", bg: "royal_plum", outline: "white")

Procedural Pattern Generators Reference

All 14 generators inherit from PatternGenerator < Godot::ImageTexture and share common base parameters (texture_size : Int64 = 256, invert : Bool = false, rotation_degrees : Float64 = 0.0):

Generator ClassPatterns FactoryCustom Arguments
PolkaDotPatternPatterns.polka_dotsdot_radius, columns, rows, stagger, ring_thickness
StripePatternPatterns.stripesstripe_count, duty_cycle, angle_degrees, crosshatch
CheckerPatternPatterns.checkerscolumns, rows, cell_inset, corner_radius
ZigZagPatternPatterns.zig_zagpeaks, bands, amplitude, thickness
WavePatternPatterns.waveswaves, bands, amplitude, thickness
RingPatternPatterns.ringsring_count, ring_width, max_radius, corner_overlays
HexagonPatternPatterns.hexagonscolumns, rows, hex_radius, stroke_width, flat_top
DiamondPatternPatterns.diamondscolumns, rows, diamond_scale, hollow_stroke
CrossPatternPatterns.crossescolumns, rows, arm_length, arm_thickness, diagonal_x
StarPatternPatterns.starscolumns, rows, points, outer_radius, inner_radius, star_rotation
BrickPatternPatterns.brickscolumns, rows, mortar_gap, row_offset, corner_radius
HoundstoothPatternPatterns.houndstoothsubdivisions, tooth_slant
HalftonePatternPatterns.halftonecolumns, rows, min_radius, max_radius, radial_falloff, invert_falloff
CustomPatternGeneratorPatterns.customkind (PatternKind), columns, rows, primary_size, secondary_size, angle_degrees, stagger

Documentation, Testing & Benchmarks

This repository uses Jasper for structured multi-track documentation and Carbon for automated commit-driven versioning and changelogs.

# Run headless Crystal specifications
crystal spec

# Compile Jasper YAML guides and generate HTML API docs
jasper build
lapis docs

# Run procedural SVG synthesis benchmarks
crystal run benchmarks/example_bench.cr -- 2000
crystal run benchmarks/compare_bench.cr -- 2000

# Build addon shared library and package redistributable zip
make package

License

MIT License — see LICENSE for details.

API

  • BrickPattern

    Procedural Running-Bond Brick / Subway Tile pattern generator.

  • CellularPattern

    Procedural Voronoi / Cellular Caustics / Cobblestone pattern generator.

  • CheckerPattern

    Procedural Checkerboard and Rounded Tile grid generator.

  • CircuitPattern

    Procedural PCB Circuit Board Traces & Via Pads pattern generator.

  • CrossPattern

    Procedural Plus / Cross / X-mark grid pattern generator.

  • CustomPatternGenerator

    All-in-one multi-mode procedural pattern generator allowing users to switch between all 19 procedural pattern types with a single dropdown in the Godot Inspector.

  • DiamondPattern

    Procedural Argyle / Diamond Lattice pattern generator.

  • Faces

    Static lookup module and SpritesheetAtlas holder for res://textures/fontawesome/faces.svg.

  • FacesSpritesheetBuilder

    In-editor tool node for packing all face SVGs in textures/fontawesome/faces into the padded textures/fontawesome/faces.svg texture atlas spritesheet.

  • FontAwesomeCategories

    Categorizes and imports FontAwesome Pro 7.1.0 duotone-regular SVGs into mutually exclusive textures/fontawesome/<category>/ directories, normalizing secondary duotone layers (opacity=".4") to solid white (#ffffff) for use with addons/pattern_material/shaders/pattern_replace.gdshader.

  • Glyphs

    Static lookup module and SpritesheetAtlas holder for res://textures/fontawesome/letter_glyphs.svg.

  • HalftonePattern

    Procedural Halftone Dot Gradient pattern generator.

  • HexagonPattern

    Procedural Honeycomb / Hexagon Grid pattern generator.

  • HoundstoothPattern

    Procedural Houndstooth textile weave pattern generator.

  • LetterGlyphs
  • Palette

    Static 32-color Afterlife 98 palette registry backed by palette.pal and palette.tres.

  • PatternGenerator

    Base procedural SVG and ImageTexture pattern generator for PatternMaterial / pattern_replace.gdshader.

  • PatternGeneratorTool

    In-editor @[Tool] helper node for visually designing procedural patterns, previewing them live on a target 2D/3D node's ShaderMaterial, and exporting custom .svg textures directly to res://addons/pattern_material/textures/patterns/.

  • PatternMaterial
  • PatternMaterialAddon
  • PatternMaterialAnimator

    Attachable @[Tool] node for animating a target node's PatternMaterial (pattern_replace.gdshader) in both the Godot Editor and at runtime.

  • PatternMaterialPlugin

    Godot EditorPlugin entry point for the pattern_material addon.

  • PatternShaderMaterial

    Custom Godot ShaderMaterial resource pre-configured with pattern_replace.gdshader, Palette color/theme selectors, and Patterns / PatternGenerator Inspector controls.

  • Patterns

    Static lookup registry for all 88 black-and-white repeating SVG patterns in res://addons/pattern_material/textures/patterns/*.svg, plus factory helpers for procedural PatternGenerator textures.

  • PolkaDotPattern

    Procedural Polka Dot & Ring grid pattern generator.

  • RingPattern

    Procedural Concentric Ring / Target / Seigaiha pattern generator.

  • ScalesPattern

    Procedural Overlapping Scales / Seigaiha Wave Arch pattern generator.

  • SpiralPattern

    Procedural Multi-Arm Archimedean Spiral / Hypnotic Vortex grid pattern generator.

  • SpritesheetAtlas

    Custom Godot Resource representing a packed SVG texture atlas spritesheet and providing O(1) lookup of frame indices, grid coordinates, and UV rects by String or Char keys.

  • SpritesheetRegistryModule

    Shared lookup and metadata interface for static spritesheet modules (Faces, Glyphs).

  • StarPattern

    Procedural Multi-Point Star / Sparkle burst pattern generator.

  • StripePattern

    Procedural Stripe, Diagonal Band, and Crosshatch/Plaid pattern generator.

  • SvgSpritesheetBuilder

    Standardized in-editor tool node and builder for packing a directory of FontAwesome duotone SVGs into a padded grid .svg texture atlas and generating its corresponding .tres SpritesheetAtlas resource.

  • TartanPattern

    Procedural Multi-Band Scottish Tartan / Flannel Plaid pattern generator.

  • TruchetPattern

    Procedural Smith Arc & Diagonal Maze Truchet tile pattern generator.

  • UniversalMaterial

    Ergonomic wrapper and fluent builder around a ShaderMaterial backed by res://addons/pattern_material/shaders/pattern_replace.gdshader.

  • WavePattern

    Procedural Sine / Bezier Wave band pattern generator.

  • ZigZagPattern

    Procedural Zig-Zag / Chevron band pattern generator.