Skip to content

feat: multicolor painted output based on displacement height - #121

Open
birnam wants to merge 7 commits into
CNCKitchen:mainfrom
birnam:multicolor-painted
Open

feat: multicolor painted output based on displacement height#121
birnam wants to merge 7 commits into
CNCKitchen:mainfrom
birnam:multicolor-painted

Conversation

@birnam

@birnam birnam commented Aug 22, 2026

Copy link
Copy Markdown

Multicolor 3MF painting (grayscale → color mapping)

Summary

Adds a "Multicolor Painting" export mode that maps the displacement texture's grayscale value to any number of user-defined colors, so a single texture can drive slicer AMS / multi-toolhead filament assignment on export. Each color owns a half-open range from its slider's percentage up to the next color's; 0% is black, 100% is white.

What's new

  • UI (index.html, style.css, js/main.js): an enable checkbox, a base-color picker, and a dynamic list of color-stop rows (color swatch + 0–100% slider), each addable/removable. Fully undo/redo-aware (multicolorStops is replaced, never mutated, per row change) and persisted in .bumpmesh projects and sessionStorage.
  • Live preview (js/previewMaterial.js): the fragment shader samples a small gradient-ramp texture (built from the current stops) using the same raw grayscale value used for export, and uses it as the lit surface color — so what you see in the viewer matches the exported result. Excluded/masked regions correctly fall back to the base color/teal shading instead of showing ramp color.
  • Export (js/multicolorPainting.js, js/exporter.js): classifies each triangle (average of its 3 vertex grayscale samples) into a material index and writes a 3MF with per-triangle slic3rpe:mmu_segmentation paint data — the same attribute PrusaSlicer, BambuStudio, OrcaSlicer, and Snapmaker Orca all read, verified against real-world encoders. Supports up to 15 color stops + base (OrcaSlicer's EnforcerBlockerType ceiling).
  • Decimation quality (js/decimation.js, js/exportPipeline.js, js/meshRepair.js): decimation gained an optional, opt-in color-boundary guard — when multicolor export is active, it never collapses an edge whose endpoints sit on opposite sides of a color threshold, so paint boundaries stay aligned to real geometry instead of drifting into a decimated triangle's interior. Fully inert when multicolor is off (default decimation path/signature unaffected).
  • README: documents the new export option and module.

Testing

  • test-multicolor-painting.html — exercises triangle classification and the exported slic3rpe:mmu_segmentation values end-to-end.
  • test-decimation-color-boundary.html — confirms the decimation guard never merges across a color threshold while still reducing triangle count within a color region, and confirms the default (non-multicolor) decimation path is byte-for-byte unaffected.
  • Manually verified live-preview color accuracy and ramp persistence across displacement-preview toggling, and re-tested after merging in current main (STEP import, preserve-untextured decimation, etc. — no regressions, all conflicts resolved to keep both feature sets working together).

Examples

image

birnam added 7 commits July 15, 2026 14:12
Implemented multicolor 3MF part support.

What changed:

  - Added Advanced/Beta “Multicolor Parts (3MF)” controls in
stlTexturizer/index.html:492.
  - Added signed displacement metadata through export so regions can be
classified by actual mm displacement.
  - Added preview tinting for raised/inset regions in
stlTexturizer/js/previewMaterial.js:44.
  - Added multipart 3MF export with separate Base, Raised Texture, and
Inset Texture objects plus display colors.

  - Added stlTexturizer/js/multicolorParts.js:1 to split
threshold-crossing triangles and build closed raised/inset shell parts.

  - Persisted thresholds in .bumpmesh/session settings.

Important behavior:

  - STL export is unchanged.
  - Normal 3MF export is unchanged when thresholds are at disabled
defaults.
  - Active multicolor 3MF export skips final decimation to preserve
clean threshold boundaries and metadata, so files can be larger.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant