From 827ba9259a89a9d62401f32f255c6b8d86ef0d94 Mon Sep 17 00:00:00 2001 From: Chris Hassebrook Date: Wed, 18 Nov 2026 18:54:45 -0500 Subject: [PATCH] Publish a selected graph as MCMAT v3 and bake it to MaterialX (#270) * Publish selected graphs as MCMAT v3 and bake parameterized MaterialX exports * Preserve material bake dimensions, color conventions and completed exports * fix(export): preserve grayscale transfer round trips and float defaults * fix(material): preserve disabled nodes and localized typed inputs * Fix capability FIFO opens and save destination link rebasing * Keep material export dialogs bound to their source package * fix(material): bound inline assets and pin merged MCMAT * fix(sbs): reject graph interfaces that exceed reader bounds * Bound resize scheduling test raster workload * fix(material): retain inline precedence on budget errors * fix(material): preserve bounded fallback and XML identifiers * fix(material): bound discarded inline inflation work * Preserve bounded material dependencies and explicit export options * Auto: Pin workspace saves and preserve material export choices Hold the resolved save directory across SBS serialization and writes. Only clean up owned staging files and compare existing assets incrementally. Bound source assets before archive serialization, limit discarded SBS inflation, and account for shared graph depth. Decode preview inputs on demand and release failed browser downloads. Distinguish automatic and explicit output colors, borrow graphs while drawing export tabs, and preserve numeric export selectors and MCP option validation. --------- Co-authored-by: Dylan M. Taylor --- Cargo.lock | 31 +- Cargo.toml | 7 +- README.md | 9 +- apps/materialcraft-cli/Cargo.toml | 3 + apps/materialcraft-cli/src/main.rs | 147 ++++- apps/materialcraft-cli/tests/published.rs | 101 ++++ crates/automation/Cargo.toml | 1 + crates/automation/src/headless.rs | 91 ++-- crates/automation/src/rpc.rs | 44 +- .../src/server/material_craft_mcp.rs | 23 +- .../src/server/parameter/export_params.rs | 50 +- .../parameter/material_export_params.rs | 34 +- crates/automation/src/workspace.rs | 244 ++++++++- crates/automation/tests/package_files.rs | 107 +++- crates/engine/Cargo.toml | 7 + crates/engine/src/commands.rs | 1 + crates/engine/src/export_request.rs | 52 +- crates/engine/src/export_size.rs | 9 +- crates/engine/src/file_cmds.rs | 76 ++- crates/engine/src/graph_cmds.rs | 21 +- crates/engine/src/lib.rs | 1 + crates/engine/src/linked_files.rs | 108 +++- crates/engine/src/linked_resource.rs | 35 +- crates/engine/src/material_bake.rs | 283 ++++++++++ crates/engine/src/material_cmds.rs | 249 +-------- crates/engine/src/material_cmds.test.rs | 503 ++++++++++++++++++ crates/engine/src/material_options.rs | 102 +++- crates/eval/src/graph_execution.rs | 41 +- crates/eval/src/node_execution.rs | 3 +- crates/eval/src/tests.rs | 105 ++++ crates/formats/src/image.rs | 37 +- crates/formats/src/lib.rs | 1 - crates/formats/src/material/archive.rs | 352 +++++++----- crates/formats/src/material/image_input.rs | 2 + crates/formats/src/material/manifest.rs | 22 - crates/formats/src/material/map_entry.rs | 11 - crates/formats/src/material/mod.rs | 12 +- crates/formats/src/material/parameter.rs | 10 - crates/formats/src/material/preset_entry.rs | 9 - .../formats/src/material/snapshot_builder.rs | 227 ++++++++ crates/formats/src/sbs/constant.rs | 4 +- crates/formats/src/sbs/embedded.rs | 127 ++++- crates/formats/src/sbs/embedded_error.rs | 28 + crates/formats/src/sbs/instance_interface.rs | 138 +++++ crates/formats/src/sbs/mod.rs | 4 + crates/formats/src/sbs/presets.rs | 56 ++ crates/formats/src/sbs/read.rs | 11 +- crates/formats/src/sbs/sbs_document.rs | 7 +- crates/formats/src/sbs/sbs_reader.rs | 62 ++- crates/formats/src/sbs/sbs_writer.rs | 18 +- crates/formats/src/sbs/tests.rs | 80 +++ crates/ui-egui/Cargo.toml | 5 +- crates/ui-egui/src/export/export_settings.rs | 4 +- crates/ui-egui/src/export/export_tests.rs | 94 +++- .../src/export/material_export_settings.rs | 85 +-- crates/ui-egui/src/export/material_tab.rs | 115 ++-- crates/ui-egui/src/export/mod.rs | 181 ++++++- crates/ui-egui/src/export/outputs.rs | 55 +- crates/ui-egui/src/export/texture_depth.rs | 24 + crates/ui-egui/src/i18n/ar.rs | 14 +- crates/ui-egui/src/material_craft_app.rs | 7 + crates/ui-egui/src/native_dialogs.test.rs | 8 +- crates/ui-egui/src/web_files.rs | 29 +- crates/ui-egui/src/windows.rs | 7 +- crates/ui-egui/src/windows.test.rs | 6 +- crates/ui-egui/tests/it/export_window.rs | 57 +- crates/ui-egui/tests/resize.rs | 24 +- crates/ui-egui/tests/snapshot.rs | 25 +- docs/architecture.md | 7 +- docs/control-protocol.md | 62 ++- docs/gaps.md | 3 +- docs/target-app-parity.md | 2 +- 72 files changed, 3525 insertions(+), 995 deletions(-) create mode 100644 apps/materialcraft-cli/tests/published.rs create mode 100644 crates/engine/src/material_bake.rs create mode 100644 crates/engine/src/material_cmds.test.rs delete mode 100644 crates/formats/src/material/manifest.rs delete mode 100644 crates/formats/src/material/map_entry.rs delete mode 100644 crates/formats/src/material/parameter.rs delete mode 100644 crates/formats/src/material/preset_entry.rs create mode 100644 crates/formats/src/material/snapshot_builder.rs create mode 100644 crates/formats/src/sbs/embedded_error.rs create mode 100644 crates/formats/src/sbs/instance_interface.rs create mode 100644 crates/formats/src/sbs/presets.rs create mode 100644 crates/ui-egui/src/export/texture_depth.rs diff --git a/Cargo.lock b/Cargo.lock index f2fdfa6..fdeb993 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -937,9 +937,18 @@ dependencies = [ ] [[package]] -name = "craft-mcmat" +name = "craft-materialx" version = "0.1.0" source = "git+https://github.com/storytold/craft-libs?rev=453b0da782ccef39be9a6dac8d27c80b553ef1cc#453b0da782ccef39be9a6dac8d27c80b553ef1cc" +dependencies = [ + "craft-xml", + "thiserror 2.0.21", +] + +[[package]] +name = "craft-mcmat" +version = "0.1.0" +source = "git+https://github.com/storytold/craft-libs?rev=7a7a18cb40ac4cd5fca29c0dc224ac5178d40a89#7a7a18cb40ac4cd5fca29c0dc224ac5178d40a89" dependencies = [ "craft-zip", "serde", @@ -990,6 +999,16 @@ dependencies = [ "encoding_rs", ] +[[package]] +name = "craft-platform" +version = "0.1.0" +source = "git+https://github.com/storytold/craft-libs?rev=453b0da782ccef39be9a6dac8d27c80b553ef1cc#453b0da782ccef39be9a6dac8d27c80b553ef1cc" +dependencies = [ + "js-sys", + "wasm-bindgen", + "web-sys", +] + [[package]] name = "craft-quit" version = "0.1.0" @@ -1112,7 +1131,7 @@ dependencies = [ [[package]] name = "craft-zip" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=453b0da782ccef39be9a6dac8d27c80b553ef1cc#453b0da782ccef39be9a6dac8d27c80b553ef1cc" +source = "git+https://github.com/storytold/craft-libs?rev=7a7a18cb40ac4cd5fca29c0dc224ac5178d40a89#7a7a18cb40ac4cd5fca29c0dc224ac5178d40a89" dependencies = [ "flate2", "thiserror 2.0.21", @@ -2823,6 +2842,7 @@ dependencies = [ "schemars", "serde", "serde_json", + "tempfile", "thiserror 2.0.21", "tokio", ] @@ -2834,6 +2854,7 @@ dependencies = [ "materialcraft-automation", "materialcraft-engine", "serde_json", + "tempfile", "tokio", "winresource", ] @@ -2851,6 +2872,7 @@ dependencies = [ name = "materialcraft-engine" version = "0.4.1" dependencies = [ + "craft-materialx", "craft-texture", "image", "materialcraft-core", @@ -2858,9 +2880,11 @@ dependencies = [ "materialcraft-formats", "materialcraft-geom", "materialcraft-nodes", + "rustix 1.1.6", "serde", "serde_json", "sha2", + "tempfile", "thiserror 2.0.21", ] @@ -2942,6 +2966,7 @@ dependencies = [ "craft-atomic", "craft-dialogs", "craft-keymap", + "craft-platform", "craft-quit", "craft-ui", "craft-update", @@ -2951,7 +2976,6 @@ dependencies = [ "egui-phosphor", "egui_kittest", "image", - "js-sys", "log", "materialcraft-engine", "materialcraft-render", @@ -2961,7 +2985,6 @@ dependencies = [ "sha2", "sys-locale", "tempfile", - "wasm-bindgen", "wasm-bindgen-futures", "web-sys", "zip 2.6.1", diff --git a/Cargo.toml b/Cargo.toml index e971cdd..c5c26f4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -83,14 +83,17 @@ flate2 = { version = "1", default-features = false, features = ["rust_backend"] cap-std = "4" getrandom = "0.3" # Shared Craft egui components from storytold/craft-libs -# MIT OR Apache-2.0; all shared dependencies use one reviewed revision +# MIT OR Apache-2.0 egui_kittest = "0.37" -craft-mcmat = { git = "https://github.com/storytold/craft-libs", rev = "453b0da782ccef39be9a6dac8d27c80b553ef1cc" } +craft-materialx = { git = "https://github.com/storytold/craft-libs", rev = "453b0da782ccef39be9a6dac8d27c80b553ef1cc" } +# MCMAT v3 uses its merged archive revision and the matching ZIP crate +craft-mcmat = { git = "https://github.com/storytold/craft-libs", rev = "7a7a18cb40ac4cd5fca29c0dc224ac5178d40a89" } craft-ui = { git = "https://github.com/storytold/craft-libs", rev = "453b0da782ccef39be9a6dac8d27c80b553ef1cc", features = ["serde"] } # Keyboard bindings (chords, dispatch and display text): storytold/craft-libs, MIT OR Apache-2.0 craft-keymap = { git = "https://github.com/storytold/craft-libs", rev = "453b0da782ccef39be9a6dac8d27c80b553ef1cc", features = ["egui"] } # Native dialogs that do not block the event loop: storytold/craft-libs, MIT OR Apache-2.0 craft-dialogs = { git = "https://github.com/storytold/craft-libs", rev = "453b0da782ccef39be9a6dac8d27c80b553ef1cc" } +craft-platform = { git = "https://github.com/storytold/craft-libs", rev = "453b0da782ccef39be9a6dac8d27c80b553ef1cc" } # The platform quit and the macOS Quit menu item: storytold/craft-libs, MIT OR Apache-2.0 craft-quit = { git = "https://github.com/storytold/craft-libs", rev = "453b0da782ccef39be9a6dac8d27c80b553ef1cc", features = ["egui"] } craft-menu = { git = "https://github.com/storytold/craft-libs", rev = "453b0da782ccef39be9a6dac8d27c80b553ef1cc" } diff --git a/README.md b/README.md index a2155a8..fd9a762 100644 --- a/README.md +++ b/README.md @@ -145,11 +145,12 @@ cargo run --release -p materialcraft # desktop app cargo run --release -p materialcraft -- package.sbs # open an SBS package cargo run --release -p materialcraft -- --control 7878 # + JSON control channel cargo run --release -p materialcraft-cli -- mcp # MCP server (stdio) -cargo run --release -p materialcraft-cli -- new wood wood.sbs -cargo run --release -p materialcraft-cli -- render wood.sbs wood.png --scene sphere --full --hq -cargo run --release -p materialcraft-cli -- export wood.sbs textures --format png --depth 16 +cargo run --release -p materialcraft-cli -- new pbr surface.sbs --name Surface +cargo run --release -p materialcraft-cli -- render surface.sbs surface.png --scene sphere --full --hq +cargo run --release -p materialcraft-cli -- export surface.sbs textures --format png --depth 16 cargo run --release -p materialcraft-cli -- export my.sbs out --set wear=0.7 # with a graph input "wear" set first -cargo run --release -p materialcraft-cli -- run my.sbs file.exportMaterial '{"path": "my.mcmat", "size": 2048}' # for TextureCraft +cargo run --release -p materialcraft-cli -- publish surface.sbs surface.mcmat --graph Surface +cargo run --release -p materialcraft-cli -- export surface.mcmat build/surface --profile materialx --size 512 cd apps/materialcraft-web && trunk serve # web build cargo xtask ci # fmt, clippy, tests, layering, wasm ``` diff --git a/apps/materialcraft-cli/Cargo.toml b/apps/materialcraft-cli/Cargo.toml index c46ca73..025c1c4 100644 --- a/apps/materialcraft-cli/Cargo.toml +++ b/apps/materialcraft-cli/Cargo.toml @@ -17,3 +17,6 @@ tokio = { workspace = true } [build-dependencies] winresource = "0.1" + +[dev-dependencies] +tempfile = "3" diff --git a/apps/materialcraft-cli/src/main.rs b/apps/materialcraft-cli/src/main.rs index fa7a15e..621a2fa 100644 --- a/apps/materialcraft-cli/src/main.rs +++ b/apps/materialcraft-cli/src/main.rs @@ -13,8 +13,10 @@ materialcraft-cli: headless MaterialCraft USAGE: materialcraft-cli --version - materialcraft-cli info - Graphs, nodes, outputs and cook results, as JSON. + materialcraft-cli info + JSON graph inspection, or the published interface of a .mcmat. + materialcraft-cli publish --graph + Publish the selected material graph with its reachable source dependencies. materialcraft-cli commands [--filter ] List the engine commands (id, label, params). materialcraft-cli nodes [--filter ] [--category ] @@ -25,11 +27,16 @@ USAGE: Run [{\"id\", \"params\"}, ...] or {\"open\": , \"steps\": [...], \"save\": }. materialcraft-cli new