diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1da3725..def2bd7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -46,6 +46,7 @@ jobs: AZURE_SIGNING_ENDPOINT: ${{ secrets.AZURE_SIGNING_ENDPOINT }} AZURE_SIGNING_ACCOUNT: ${{ secrets.AZURE_SIGNING_ACCOUNT }} AZURE_CERT_PROFILE: ${{ secrets.AZURE_CERT_PROFILE }} + LINUX_SIGNING_KEY: ${{ secrets.LINUX_SIGNING_KEY }} # The jobs below stay here only while this repo is private. They follow the shared workflow's # FreeBSD job, on a larger runner. When the repo is public, remove them and has-freebsd: false. diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml new file mode 100644 index 0000000..8ab024c --- /dev/null +++ b/.github/workflows/sonarcloud.yml @@ -0,0 +1,19 @@ +name: SonarCloud + +on: + push: + branches: [main] + pull_request: + types: [opened, synchronize, reopened] + +permissions: + contents: read + +concurrency: + group: sonarcloud-${{ github.ref }} + cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} + +jobs: + sonarcloud: + uses: storytold/craft-common-actions/.github/workflows/sonarcloud.yml@main + secrets: inherit diff --git a/.gitignore b/.gitignore index bb3b600..1adf3bf 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,4 @@ target/ /craft-fonts *.mcraft.tmp .claude/worktrees/ +pr-review-guidelines.md diff --git a/AGENTS.md b/AGENTS.md index 8fd5da4..19ce8f5 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -11,7 +11,8 @@ The product name is always written **MaterialCraft** (`{Function}Craft` in Pasca siblings PhotoCraft, VectorCraft, FilmCraft, LightCraft, PdfCraft, EffectCraft, DesignCraft, TextureCraft) in user-facing text: UI, window titles, About, installers, release names, docs prose. Machine names stay lowercase: crates (`materialcraft-*`), binaries, file names, ids -(`ai.storyteller.materialcraft`), the native package extension `.mcraft`. +(`ai.storyteller.materialcraft`). The main project format is SBS (`.sbs`); the older native +package extension `.mcraft` is still read and written. Standards and learnings shared across the crafting apps live in `../craftrules` (checked out next to this repo, or `storytold/craftrules`). Read its `AGENTS.md` at the start of a session, follow its @@ -41,7 +42,7 @@ file first, then `docs/`. crates/ core image geom L0 document model (package, graphs, nodes, values, function graphs); float images; meshes, BVH, camera nodes L1 the node library: definitions + CPU cooks (atomic nodes, noises, patterns, filters, PBR utilities, function evaluator) - eval formats L2 graph cooking (topological order, sizes, content-addressed cache, sub-graphs); .mcraft packages, bitmaps, texture export + eval formats L2 graph cooking (topological order, sizes, content-addressed cache, sub-graphs); .sbs and .mcraft packages, bitmaps, texture export engine render L3 Session + command registry (every action is a command), inspect, samples; the 3D preview renderer (CPU PBR + IBL) automation L4 MCP server + headless JSON-lines RPC + bridge to the running app ui-egui L5 egui shell (thin: every edit goes through engine commands) @@ -96,9 +97,11 @@ workflow. Work from public documentation, general domain knowledge and public al and simplex gradient noise, Worley/cellular noise, fractal sums, Gaussian and box blurs, Felzenszwalb–Huttenlocher distance transforms, Sobel/central-difference normals, reoriented normal mapping, HSL, levels, monotone cubic curves, W3C blend modes, GGX/Smith/Schlick PBR, split-sum IBL, -ACES fitted tone mapping). Never copy proprietary code, shaders, node implementations, presets or -file formats; compatibility with the reference app's package formats is a non-goal. Always describe -MaterialCraft as a clean-room implementation, in code, docs and commits. +ACES fitted tone mapping). Never copy proprietary code, shaders, node implementations or presets. +SBS packages are the main project format (issue #49): `crates/formats/src/sbs.rs` reads and writes +them with MaterialCraft's own code, written from the format's public documentation and sample +files, never from another implementation. Always describe MaterialCraft as a clean-room +implementation, in code, docs and commits. ### Never crash (outranks feature work) diff --git a/ATTRIBUTION.md b/ATTRIBUTION.md index 32924b8..80e577f 100644 --- a/ATTRIBUTION.md +++ b/ATTRIBUTION.md @@ -26,7 +26,10 @@ images, materials, sample graphs, presets, environments) may ever be added. | `docs/images/materialcraft-lava.png` | README screenshot: the lava rock template | MaterialCraft contributors | Offscreen render of MaterialCraft's UI | MIT OR Apache-2.0 | | `docs/images/materialcraft-ground.png` | README screenshot: the mossy ground template | MaterialCraft contributors | Offscreen render of MaterialCraft's UI | MIT OR Apache-2.0 | | `docs/images/materialcraft-new-graph.png` | README screenshot: the New graph dialog | MaterialCraft contributors | Offscreen render of MaterialCraft's UI | MIT OR Apache-2.0 | +| `docs/images/materialcraft-alpha-transparency.png` | Docs screenshot: a cut-out material in the 3D view and a reroute dot on a wire | MaterialCraft contributors | Offscreen render of MaterialCraft's UI (`crates/ui-egui/tests/snapshot.rs`) | MIT OR Apache-2.0 | +| `docs/images/materialcraft-alpha-channel.png` | Docs screenshot: the 3D view's alpha channel view | MaterialCraft contributors | Offscreen render of MaterialCraft's UI (`crates/ui-egui/tests/snapshot.rs`) | MIT OR Apache-2.0 | | `docs/images/materialcraft-materials.png` | README render: eight sample materials on spheres | MaterialCraft contributors | `materialcraft-cli render --scene sphere --full --hq` of the templates, eight renders in a grid | MIT OR Apache-2.0 | +| `docs/images/materialcraft-levels-editor.png` | Docs screenshot: the Levels editor with the input histogram | MaterialCraft contributors | Offscreen render of MaterialCraft's UI (`crates/ui-egui/tests/snapshot.rs`) | MIT OR Apache-2.0 | | `docs/brand/artcraft-*.svg`, `docs/brand/artcraft-*.png` | ArtCraft logo and mark | ArtCraft Team | storytold/craftrules `assets/brand/` | ArtCraft brand terms, not open source ([`docs/brand/LICENSE-brand.txt`](docs/brand/LICENSE-brand.txt)) | | `crates/nodes/src/text.rs` (`GLYPHS`) | Single-stroke vector font of the Text node (A–Z, a–z, 0–9, punctuation) | MaterialCraft contributors | Original, designed as stroke data in code | MIT OR Apache-2.0 | diff --git a/Cargo.lock b/Cargo.lock index ce3b0fc..9e520a8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2307,7 +2307,7 @@ checksum = "5d15f86d12da44cd8d4ec3c73984537eb7f4cadcb9776a575a0a8a05ca11005c" [[package]] name = "materialcraft" -version = "0.1.0" +version = "0.1.2" dependencies = [ "eframe", "egui", @@ -2321,7 +2321,7 @@ dependencies = [ [[package]] name = "materialcraft-automation" -version = "0.1.0" +version = "0.1.2" dependencies = [ "base64 0.22.1", "cap-std", @@ -2341,7 +2341,7 @@ dependencies = [ [[package]] name = "materialcraft-cli" -version = "0.1.0" +version = "0.1.2" dependencies = [ "materialcraft-automation", "materialcraft-engine", @@ -2352,7 +2352,7 @@ dependencies = [ [[package]] name = "materialcraft-core" -version = "0.1.0" +version = "0.1.2" dependencies = [ "serde", "serde_json", @@ -2361,7 +2361,7 @@ dependencies = [ [[package]] name = "materialcraft-engine" -version = "0.1.0" +version = "0.1.2" dependencies = [ "materialcraft-core", "materialcraft-eval", @@ -2376,7 +2376,7 @@ dependencies = [ [[package]] name = "materialcraft-eval" -version = "0.1.0" +version = "0.1.2" dependencies = [ "materialcraft-core", "materialcraft-image", @@ -2386,13 +2386,17 @@ dependencies = [ [[package]] name = "materialcraft-formats" -version = "0.1.0" +version = "0.1.2" dependencies = [ + "base64 0.22.1", + "flate2", "gltf", "image", "materialcraft-core", "materialcraft-geom", "materialcraft-image", + "materialcraft-nodes", + "roxmltree", "serde", "serde_json", "thiserror 2.0.21", @@ -2402,7 +2406,7 @@ dependencies = [ [[package]] name = "materialcraft-geom" -version = "0.1.0" +version = "0.1.2" dependencies = [ "glam 0.30.10", "mikktspace", @@ -2413,7 +2417,7 @@ dependencies = [ [[package]] name = "materialcraft-image" -version = "0.1.0" +version = "0.1.2" dependencies = [ "rayon", "thiserror 2.0.21", @@ -2421,7 +2425,7 @@ dependencies = [ [[package]] name = "materialcraft-nodes" -version = "0.1.0" +version = "0.1.2" dependencies = [ "materialcraft-core", "materialcraft-image", @@ -2430,7 +2434,7 @@ dependencies = [ [[package]] name = "materialcraft-render" -version = "0.1.0" +version = "0.1.2" dependencies = [ "materialcraft-geom", "materialcraft-image", @@ -2439,7 +2443,7 @@ dependencies = [ [[package]] name = "materialcraft-ui-egui" -version = "0.1.0" +version = "0.1.2" dependencies = [ "base64 0.22.1", "craft-ui", @@ -2455,6 +2459,7 @@ dependencies = [ "rfd", "serde", "serde_json", + "sys-locale", "wasm-bindgen", "wasm-bindgen-futures", "web-sys", @@ -2463,7 +2468,7 @@ dependencies = [ [[package]] name = "materialcraft-web" -version = "0.1.0" +version = "0.1.2" dependencies = [ "eframe", "js-sys", @@ -3588,6 +3593,12 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "roxmltree" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c20b6793b5c2fa6553b250154b78d6d0db37e72700ae35fad9387a46f487c97" + [[package]] name = "rustc-hash" version = "1.1.0" @@ -5234,7 +5245,7 @@ checksum = "e450f9b2ed1dff33c94c12589a87338689467b9c4f5d8a5710bd09a847d2c8a7" [[package]] name = "xtask" -version = "0.1.0" +version = "0.1.2" dependencies = [ "serde_json", ] diff --git a/Cargo.toml b/Cargo.toml index 663ec4d..1bf7d2a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -35,7 +35,7 @@ default-members = [ ] [workspace.package] -version = "0.1.0" +version = "0.1.2" edition = "2024" license = "MIT OR Apache-2.0" rust-version = "1.95" @@ -76,6 +76,8 @@ rmcp = { version = "3.5", default-features = false, features = ["server", "macro tokio = { version = "1", features = ["rt-multi-thread", "macros", "io-std", "sync", "net", "io-util", "time"] } schemars = "1" base64 = "0.22" +roxmltree = "0.20" +flate2 = { version = "1", default-features = false, features = ["rust_backend"] } cap-std = "4" getrandom = "0.3" # Shared Craft egui components (widget palette, icon buttons, panel docking): storytold/craft-libs, diff --git a/README.md b/README.md index c521499..6c2f537 100644 --- a/README.md +++ b/README.md @@ -106,14 +106,16 @@ ray-traced ambient occlusion and a shadowed key light). - **Familiar.** The layout, panels, menus and gestures material artists already know: a package explorer, a library of nodes with previews, the node graph with live thumbnails, a 3D view, a 2D - view and a properties panel with base and specific parameters. Space opens the node search. + view and a properties panel with base and specific parameters (Levels is edited over a + histogram of its input, see [docs/levels-editor.md](docs/levels-editor.md)). Space opens the + node search. - **Fast.** Every node cooks on every CPU core, and a content-addressed cache means an edit re-cooks only what lies downstream: the brick wall sample cooks in about 40 ms at preview size. Cooking runs on a worker thread, so the UI never waits. - **Tileable by design.** Noises and patterns live on whole-number lattices, so everything tiles seamlessly at any resolution, from 16 px to 8K. - **Robust.** No panics in shipped code, every command tested with hostile input, every node cooked - with odd inputs in tests, unlimited undo from snapshots, and lossless `.mcraft` packages. + with odd inputs in tests, unlimited undo from snapshots, and lossless project files. - **Open.** Export base color, normal, roughness, metallic, height and ambient occlusion as PNG, JPEG, TGA, TIFF, BMP, WEBP, EXR or HDR at 8, 16 or 32 bits, with your own file name pattern. - **Works with TextureCraft.** **File ▸ Send to TextureCraft** puts a material on TextureCraft's @@ -131,20 +133,20 @@ ray-traced ambient occlusion and a shadowed key light). git clone https://github.com/storytold/materialcraft cd materialcraft -cargo run --release -p materialcraft # desktop app (opens the brick wall sample) -cargo run --release -p materialcraft -- package.mcraft # open a package +cargo run --release -p materialcraft # desktop app +cargo run --release -p materialcraft -- package.sbs # open a package (.sbs or .mcraft) 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.mcraft -cargo run --release -p materialcraft-cli -- render wood.mcraft wood.png --scene sphere --full --hq -cargo run --release -p materialcraft-cli -- export wood.mcraft textures --format png --depth 16 -cargo run --release -p materialcraft-cli -- export my.mcraft out --set wear=0.7 # with a graph input "wear" set first -cargo run --release -p materialcraft-cli -- run my.mcraft file.exportMaterial '{"path": "my.mcmat", "size": 2048}' # for TextureCraft +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 -- 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 cd apps/materialcraft-web && trunk serve # web build cargo xtask ci # fmt, clippy, tests, layering, wasm ``` -You need Rust 1.95 or newer. The app opens with the brick wall sample; **File ▸ New ▸ Graph...** +You need Rust 1.95 or newer. The app opens with an empty graph in a new package; **File ▸ New ▸ Graph...** starts from a PBR template or one of the sample materials. ### Use it from Claude Code and other agents @@ -172,7 +174,9 @@ area, the remaining work and what's next. SVG and Text, noises including tileable 3D ones, patterns, filters, the flood fill family, whole-material blending and weathering), function graphs with a visual editor and dynamic parameters, sub-graphs with exposed inputs and presets, the full editor (graph, library, -properties, 2D view with histogram, 3D view with your own OBJ/glTF meshes), `.mcraft` packages, +properties, 2D view with histogram, 3D view with your own OBJ/glTF meshes, alpha transparency and an +alpha channel view; wires you can select, delete, swap (X) and reroute with dots, see +[docs/wires-and-alpha.md](docs/wires-and-alpha.md)), SBS project files (`.mcraft` too), texture export, portable `.mcmat` materials that TextureCraft paints with (inputs stay editable there), the browser build with file I/O, the CLI, the control channel and the MCP server all work today. We estimate about two thirds (≈ 67%) of a material artist's daily workflow works diff --git a/apps/materialcraft-cli/src/main.rs b/apps/materialcraft-cli/src/main.rs index fef8f39..2b31f39 100644 --- a/apps/materialcraft-cli/src/main.rs +++ b/apps/materialcraft-cli/src/main.rs @@ -14,23 +14,23 @@ materialcraft-cli: headless MaterialCraft USAGE: materialcraft-cli --version - materialcraft-cli info + materialcraft-cli info Graphs, nodes, outputs and cook results, as JSON. materialcraft-cli commands [--filter ] List the engine commands (id, label, params). materialcraft-cli nodes [--filter ] [--category ] List the node library (ids, ports, parameters). - materialcraft-cli run [params-json] [-o ] + materialcraft-cli run [params-json] [-o ] Run one command and print its JSON result; -o saves the package. materialcraft-cli batch - Run [{\"id\", \"params\"}, ...] or {\"open\": , \"steps\": [...], \"save\": }. - materialcraft-cli new