Skip to content

feat(cli,core,lang,wasm): add translucent/emissive materials, non-GLB --scene exports, and CLI multi-part ergonomics - #138

Merged
wrong-nebula merged 2 commits into
mainfrom
feat/cli-scene-translucency-srgb
Dec 4, 2026
Merged

wrong-nebula merged 2 commits into
mainfrom
feat/cli-scene-translucency-srgb

Conversation

@wrong-nebula

Copy link
Copy Markdown
Owner

Summary

Addresses real-world CLI evaluation feedback where agents using Forma via CLI (with SKILL.md, forma spec, and forma --help only) struggled to discover multi-part scene export, attempted expensive boolean unions across architectural scenes, and could not express translucent/emissive materials (e.g., steam, water, glowing shoji/lanterns).

1. CLI Multi-Part Export Ergonomics & Parity

  • Clear --help (KEY OPTIONS: & EXAMPLES:): Both native forma (crates/forma-cli/src/main.rs) and WASM forma-3d (bin/forma.mjs) now explicitly explain --scene vs single-part default export and list forma spec --topic.
  • Stderr NOTE: when --scene is omitted on multi-part scenes: Running --out / --render / --draw without --scene on a scene with parts > 1 now emits an actionable NOTE: on stderr (keeping --json stdout strictly valid JSON).
  • WASM CLI parity: Added --critique, --raw-box, and lint subcommand support to bin/forma.mjs.
  • Docs & specs synced: Updated SPEC_PIPE, spec_topic("scene"), SKILL.md (explicit CLI --scene comments, workflow guidance, and CLI forma spec --topic listing), AGENTS.md, docs/reference/cli.md, and docs/reference/language-and-formats.md.

2. Translucency, Emissive, Transmission, IOR & Dielectric Color Consistency

  • Material model & Forma-Pipe syntax (mat(...) / color(...)):
    • Added alpha= / opacity= / a= and 4-tuple RGBA color=(r, g, b, a).
    • Added emissive=(r, g, b), emissive_strength=, transmission=, ior=, and double_sided=.
    • Changed default metallic from 0.1 → 0.0 so non-metals (wood, plaster, foliage, stone, steam) default to physically accurate dielectrics.
  • glTF 2.0 .glb export & round-trip import (export.rs, import.rs):
    • Unified build_gltf_material across single-mesh and multi-node --scene GLB exports.
    • Emits "alphaMode": "BLEND" whenever alpha < 1.0, "doubleSided": true, sRGB→linear "emissiveFactor" (matching existing sRGB→linear baseColorFactor), and KHR extensions (KHR_materials_transmission, KHR_materials_ior, KHR_materials_emissive_strength) with root "extensionsUsed".
    • Round-trips all new material fields on .glb import (read_glb_bytes).
  • Software preview renderer (render.rs):
    • Added a back-to-front alpha-blended translucent pass (raster_tri_blend) tested against opaque depth without Z-write, transmissive preview opacity, emissive glow, and double_sided shading.

3. Non-GLB Multi-Part --scene Export

  • Added write_scene_obj_bytes (multi-object o <name> groups), write_scene_3mf_bytes_with_unit (multi-<object> 3MF), write_scene_step_bytes_with_unit (multi-solid STEP), and combined .stl scene export via Scene::export_scene_bytes and Scene::export_scene_path.
  • Exposed forma_session_export_scene_format in forma-wasm and updated lib/edge.mjs, lib/index.d.ts, bin/forma.mjs, bin/forma-mcp.mjs, and rebuilt wasm/forma.wasm.

Verification

  • cargo test -p forma-cli --test scene_materials_cli -p forma-core --test kernel_tests -p forma-lang --test validation --release — 37/37 passed (including new tests for sRGB/linear + translucency/emissive/transmission/IOR GLB round-trips, multi-part OBJ/3MF/STL/STEP --scene exports, and native CLI --scene / missing---scene NOTE:).
  • cargo check --workspace --tests — clean across all 7 workspace crates.
  • npm run build:wasm && npm test — rebuilt wasm/forma.wasm and passed 5/5 smoke suites (ESM, Edge/Workers, WASM CLI --scene + non-GLB + stderr NOTE:, all 5 SKILL.md recipes, and MCP stdio server).
  • python3 scripts/check_local_paths.py — clean across all tracked files.

… --scene exports, and CLI multi-part ergonomics
…ucency-srgb

# Conflicts:
#	crates/forma-core/src/export.rs
#	crates/forma-core/src/render.rs
#	crates/forma-lang/src/lib.rs
@wrong-nebula
wrong-nebula merged commit 847f62e into main Dec 4, 2026
3 checks passed
@wrong-nebula
wrong-nebula deleted the feat/cli-scene-translucency-srgb branch December 4, 2026 07:29
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