Repository navigation
feat: import, CAD and hand-offs, materials and the material library - #4
Merged
Merged
Conversation
Shelf, category, query, tile size, scroll offset and the active tile are stored in one localStorage entry, written after a short delay and on page hide. Ran npx tsc --noEmit.
Shelf, category, type and empty-state strings of the Library panel; strings another namespace already translates keep that translation, the rest are English placeholders, es-MX and fr-CA are empty. Checked strings.json is sorted and unique.
Three thumbnails at a time, newest request first, decoded before they are handed to a tile, so a tile never shows a half-drawn image; a request is dropped when its tile leaves the view and failures wait a minute before a retry. Ran npx tsc --noEmit.
Tiles are a fixed pool positioned by transform inside a sized spacer, rebound in place on scroll or new results, with thumbnails requested only once an IntersectionObserver sees the tile and a fade on the image alone. Arrow keys, Page keys, Home, End, Enter and the menu key work on the focused grid. Ran npx tsc --noEmit.
lib-engine's thumbnail route serves a cached file as immutable when the preset's sha256 comes along, so the URL carries it whenever the list reply has one. Ran npx tsc --noEmit.
A glass popover in the overlay root, built once and patched, shows the preset's swatch, category and type, its main surface values, tags and the source citation with notes, from library.get. Ran npx tsc --noEmit.
Commands for applying a preset to the selected parts, their groups or every part with the same material, toggling a favorite, opening details and removing a user preset, gathered in the context.library.tile menu. Ran npx tsc --noEmit.
Finds the part under a point with the raster id buffer, or view.pick when there is no raster scene, and outlines the parts a drop would change through the raster renderer's selection outline, restoring the real selection afterwards. Ran npx tsc --noEmit.
A pointer drag past five pixels shows a small glass hint in the overlay root naming the part under the pointer; Alt targets the group, Shift every part with the same material, Escape cancels and a drop on empty space only shows a toast. Ran npx tsc --noEmit.
A small dialog for the name and category of the selected part's material, sent with library.save; the command is enabled only when the engine has library.save and a selected part wears a material. Ran npx tsc --noEmit.
The mesh route appends uv set 0 and tangents after the indices when the engine sends them and marks each in the high half of the version word (bit 16 uv0, bit 17 tangents), so readers that ignore the flags read the same prefix. Ran mesh_block on a synthetic reply with and without the sections in the service venv.
The FSHM parser reads the flagged uv0 and tangent sections after the indices (the base64 fallback reads uv0_b64 and tangents_b64), and the scene listing keeps the per-material revisions. Ran npx tsc --noEmit.
scene.meshes instances carry tinted, so the raster material view knows a part tint overrides the base colour map as it does in the path tracers. Ran cargo clippy -p fsh-commands with -D warnings and npx tsc --noEmit.
MaterialSource asks material.preview_maps for a material at a size, decodes the four PNG maps into ImageBitmaps without colour conversion or premultiplication, shares requests in flight and remembers failures per key, revision and size. Ran npx tsc --noEmit.
Meshes upload uv0 and tangents as attributes 2 and 3; materials upload base colour (sRGB), roughness, metalness and normal maps with mipmaps, replacing old textures only after the new ones exist. The material shader samples them by uv0 with a tangent or derivative frame and replaces the studio light lobes with GGX lights; solid, wireframe and overlay are unchanged. Ran npx tsc --noEmit.
In material mode the raster view fetches preview maps for the materials parts wear, keyed by material revision and a size from the viewport quality (64, 128 or 256, default 128), drops late answers for superseded revisions, frees textures of removed materials and tints the environment by the document's environment colour. Ran npx tsc --noEmit.
Every string the Library panel, its tile menu, the details popover, the drag hint and the save sheet show, in strings.json and every language file of the namespace. Regenerated the tables from strings.json and checked the order.
Shelves All, Favorites, Recent, In project and User, categories with counts of the current shelf and search, a debounced library.list search, a three-step tile size slider and the state restored on reload; double-click or Enter applies to the selection and right-click opens the tile menu. Ran tsc and vite build, then scrolled 1992 tiles in headless Chrome at 4x CPU throttle against a stand-in: 20 tile nodes throughout.
Material.labels is left out of the JSON when empty, listed in MATERIAL_FIELDS, validated for unique ids, and its textures follow texture_keys and map_textures. A throwaway program saved and reloaded .fshot files: without labels byte-identical, with labels kept as a known field.
texpack writes the directory, level records, the sRGB decode table and the texels (rgba8 as two exact floats per texel, rgbaf32 as four) with offsets relative to the directory so they stay exact floats; missing or malformed images get zero levels. Verified with cargo check of fsh-render-gpu.
Refusals::check lists material_program for used materials whose program fails its check, needs more registers, reads a uv set past four or names a procedural without a GPU port; the vertex estimate now counts every attribute slot. Verified with cargo check of fsh-render-gpu.
Material records take the program's constant block; non-constant programs append their encode_f32 blob after the texture block and set MAT_PROGRAM; uv sets and tangents are packed only for meshes an instance with a program wears. Verified with cargo check of fsh-render-gpu.
GpuScene::set_textures rewrites tables from the texture block, the material records and the lights, refusing with texture_memory when tables would pass the binding size; material edits write tables from the program blobs and a change in packed attributes rebuilds the geometry. Verified with cargo check of fsh-render-gpu.
GpuRenderer::set_textures mirrors the CPU renderer (reset, texture_memory refusal kept across snapshots); Features gains programs, the USE_PROGRAMS specialisation, so scenes without programs compile the interpreter out. Verified with cargo check of fsh-render-gpu.
…lands The first empty render before the engine answered saved an empty active tile and a zero scroll over the stored ones; the panel now ignores scroll and active changes until a real list arrived, then restores both. Checked in headless Chrome: Glass, scroll 1500 and the active tile survive a reload.
decode_image detects the format and returns RGBA pixels (8 bit, 16 bit or float), with an OpenEXR scanline reader for none, RLE, ZIPS and ZIP and half, float or uint channels. EXR decodes matched the OpenEXR library bit for bit on six files, PIZ and lossy codecs report unsupported, 1500 damaged EXRs gave no panic; clippy and the wasm32 check pass.
The count grew from empty to its text and widened its box when the list arrived; it now fills the footer's free width. Checked in headless Chrome: no tile, category, count or grid box moves while the list and thumbnails arrive, and no layout-shift entries.
New texture members are textures/<32 hex digits of SHA-256>.<ext> through texture_member and embed_texture, which refuses images above 256 MiB. Loading accepts both this form and the older <fnv64>-<length> names, each checked against its content. cargo check -p fsh-format passes.
RawScene gains extras (slots and extension values per material) and embedded images beside the existing tables, so RawMaterial literals elsewhere keep compiling. The conversion builds TextureSlots, applies specular tint, sheen, volume, thin film, dispersion and anisotropy, and marks masked parts with material.alpha_cutoff. cargo check -p fsh-io passes.
The root is FORMSHOT_LIBRARY, then the desktop bundle's resource folder for each platform, then assets/library above the running program. User data and cache follow the platform rules with FORMSHOT_USER_DATA and FORMSHOT_CACHE overrides, and writes go through an atomic rename. Compiled with cargo check -p fsh-commands.
Applying any paint_metallic preset kept the type graph's blue flake mix, so metallic red, silver, pearl white and the others rendered blue; the mix now runs from the preset's base colour to 1.5 times it. The thumbnail look marker moves to ball-3 so cached blue pictures are dropped. Rendered eight paint thumbnails through library.thumbnail over a cache holding the old pictures and looked at them.
8-bit images whose alpha is 255 everywhere now use storage 2 (r + 256 g + 65536 b, alpha 1) in the texture block, halving their memory, so glTF models with several 2k maps no longer exceed lavapipe's 128 MiB storage binding and fall back to the CPU. NormalTangentMirrorTest, WaterBottle and AlphaBlendModeTest now render on lavapipe with CPU MAD 0.00033, 0.00016 and 0.00050 at 320x240 16 spp.
Region updates on the CPU fell back to a full reset whenever the material count changed, and the default material's index moves with it, so library.apply and assigning a new material restarted the whole picture. The check now compares the default material by content and lets parts whose material index moved count as changed. library.apply on one part of product-white during a render now answers reset region with only the band's rectangle cleared; templates render byte-identical.
The GPU preview answered every Region change with a full reset. GpuRenderer::update_region now applies the snapshot without resetting and clears accumulation only over the changed instances' first-hit rectangle, as the CPU does, and GpuPreview uses it when only materials or part colours changed. On lavapipe library.apply on one part answers reset region with the same rectangle as the CPU, the job continues and the render converges; bench MAD 0.00001.
Environment images loaded only Radiance files, though fsh-io decodes OpenEXR since the texture work; EXR HDRIs now load through decode_image (scene-linear sRGB, top row first). Rendered a diffuse sphere under the CC0 Studio Small 09 HDRI as .hdr and .exr: same picture, mean absolute difference 0.0015 at 64 spp.
environment.set to an HDRI file now embeds the image as an fshot:textures member like slot images, the engine loads fshot: environment paths from the kept project, and fsh-format writes the member the environment names. Set an HDRI by path, saved, moved the project, deleted the file and rendered the reopened project: the HDRI lit it with no warning; templates still render byte-identical.
Normal and bump maps that tilt the shading normal steeply sent mirror reflections below the geometric surface, where the BSDF rejects them, so normal-mapped metals showed black rims. A normal changed by a material program is now bent so the mirror direction stays just above the horizon (normal clamping after Keller et al. 2017); unchanged normals are untouched. NormalTangentMirrorTest's gold columns now read like the geometry column; templates render byte-identical.
Port of the CPU normal clamping: a shading normal changed by the material program is bent so the mirror direction of the view stays above the geometric horizon. NormalTangentMirrorTest on lavapipe (ray queries and software traversal) is within 0.00032 MAD of the new CPU picture and 0.0042 from the old one; the dome normal and bump scene within 0.00001.
Every stone preset got the stone type's marble graph, so concrete, limestone, sandstone, slate and travertine showed marble veins; non-marble stones now get fractal mottling (granite 4 mm cells) around the preset's tone, and the thumbnail marker moves to ball-4. Rendered the ten stone thumbnails and looked at them: marbles keep their veins, the others read as mottled stone.
alphaMode MASK imported as soft coverage, so AlphaBlendModeTest's cutoff panels faded instead of cutting; a masked material with a textured alpha now gets a small graph (texture alpha times the factor, stepped at the cutoff with subtract, multiply and clamp) driving opacity. Imported AlphaBlendModeTest and looked at the render: the 0.25, default and 0.75 panels cut exactly at their green arrows.
The WebGPU viewport never received environment pixels, so an HDRI scene showed the studio there; the session now decodes the environment image the loaded project embeds (fshot: path) with the engine's environment_image, which moved to textures.rs, and the viewport hands it to the tracer when the path changes. A native throwaway program loading a project with an embedded HDRI reports a 1024 x 512 environment_image in Scene.counts; wasm32 clippy clean; HDRI renders through the CLI byte-identical. The browser viewport itself was not run.
The preview's CPU fallback after a GPU failure was built from the GPU renderer's snapshot and environment only, so every texture fell back to its constant; GpuPreview now remembers its texture set and the fallback hands it to the CPU renderer. With FORMSHOT_GPU_FAULT=pass on lavapipe the textured scene's preview finished on the CPU with the brick and orientation images in place (before: plain grey).
An image embedded by a command inside an open history group never reached the crash journal (it cannot snapshot mid-group), so a recovered session named a member it did not hold and could not even be saved; the hand-over now waits for the group's end. Killed an engine after begin_group, set_slot with a path and end_group: the recovered session saves with the member (before: inconsistent document error); the ungrouped crash check still passes.
Native log entries that said material.get was missing, the preview bake had no images, sources were never pruned, the hello wait was a fixed 90 s, the MASK cutoff waited for an opcode and environments read Radiance only now point to what the polish and QA passes changed. Checked against eee83f3.
Adds entries for the MASK cutoff graph, referenced sources and the environment member on save, the CAD hello timeout, procedural normals, merging graphs and the cylinder cap, the bent-normal clamp, material.get and cad.parts, embedded command images and environments, preview maps from the cache, region resets and fallback textures, preset graph fixes, the window environment, GPU storage 2 and region updates. Checked against eee83f3.
Adds the backend entry for dispatch_outside and its change events from /api/agent and MCP, and corrects the texture route entry: uploaded slot images are now embedded by the engine. Checked against backend/app on eee83f3.
Adds the window log's polish section (engine reads instead of snapshot ZIP reads, with both removed readers quoted in full; the change-none refresh; merged graph value drags) and marks the labels namespace and the two GPU texture notes as translated. Checked against eee83f3.
Updates the library bundle entry: the desktop shell now sets FORMSHOT_LIBRARY for the frozen service when unset and the bundled index exists. Checked against src-tauri/src/main.rs; the shell was only compiled.
GPU-ENGINE.md now lists the opaque 8-bit texture storage packed in one float, region resets for material edits with update_region, and the bent-normal clamp, with what ran on lavapipe. Checked against fsh-render-gpu on eee83f3.
MATERIALS.md now says the preview bake samples real images, images named by path in commands are embedded, procedural normal outputs are safe to link directly, set_graph can merge, material.get exists and bent normals are clamped. Checked against eee83f3.
ARCHITECTURE.md and VIEWPORT.md now describe region resets for material edits on both engines, outside edits relayed to the window, the preview bake with real images, the embedded environment in the window, material.get and cad.parts, and the catalogue at 121 entries counted from the tables. Checked against eee83f3.
FILE-FORMAT.md now says which commands embed the images they name and when, that the environment may name a fshot:textures member a save keeps, and what an older engine does with it. Checked against fsh-commands textures.rs and fsh-format project.rs on eee83f3.
IMPORT.md now describes the MASK cutoff graph, FORMSHOT_CAD_HELLO_TIMEOUT, sources saved only while referenced and cad.parts; FILE-FORMAT.md's older-engine row no longer guesses that an older engine falls back to the studio. Checked against eee83f3.
LIBRARY.md now describes the metallic paint colour mix and the stone mottling graphs, the ball-4 look marker, the thumbnails that were looked at, and FORMSHOT_LIBRARY set by the desktop shell. Checked against ext/library and src-tauri on eee83f3.
README.md and the wiki pages Materials, Import, Architecture and CAD and Hand-offs now say chosen images are stored in the project, material edits refresh only their parts on both tracers, agent edits reach the window, Material preview shows real images, masked glTF alpha cuts sharply, the worker wait is configurable, and the catalogue has 121 entries. No version string changed.
The ui-shell, materials, command-registry, engine-service and cad-and-handoffs sub-skills and the router now name material.get and cad.parts, the change-none refresh and merged graph drags, embedded command images, bent normals, dispatch_outside and the CAD hello timeout, and count 121 commands. Scanned for emoji and em dashes.
Texture decoding added zune-jpeg and its zune-core; the lock now records them so builds resolve the same versions. Ran cargo clippy on the workspace with -D warnings.
FormShot 0.6.0 adds materials and the library: eighteen material types, texture slots with mapping, the node graph with ten procedural patterns, labels, thin film and dispersion, a material program both path tracers run with textures from PNG, JPEG, HDR and EXR, imported textures and chosen images kept inside the project, the Material page, the graph editor, preview maps for the raster view, textures in the window's WebGPU engine, region refreshes on material edits, and 249 presets from measured and published data with list, search, apply, thumbnails and the Library panel; CHANGELOG.md gains its section, which says the window's WebGPU engine ran with textures only against a stand-in viewport and no real GPU or desktop bundle was run. Version sites moved from 0.5.0 to 0.6.0: VERSION, frontend package.json and the two package-lock.json root entries, version.ts, tauri.conf.json, src-tauri Cargo.toml and its Cargo.lock entry, backend __init__.py, the thirteen native crate manifests and their native/Cargo.lock entries, fsh-py pyproject.toml, the formshot-engine usage line, the current-version lines of README, CONTRIBUTING, NOTICE, SECURITY, ARCHITECTURE, the harness skill and the HASHOUT log headers, and the agent manifest and rendering skill tool reference regenerated by ./formshot agents sync from a 0.6.0 release engine (121 commands). Run: cargo check --locked in native/ and cargo clippy --locked in src-tauri with the sidecar placeholder (both pass), cargo build --release of fsh-cli (formshot-engine reports 0.6.0), ./formshot agents check (clean), python3 -m json.tool on package.json, package-lock.json, tauri.conf.json and agents/manifest.json.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
feat: import, CAD and hand-offs, materials and the material library
Summary
Turn 3 of the plan: P5 import and P6 CAD and family hand-offs (0.5.0), then P7 materials and P8 the material library (0.6.0). 494 commits on
main(6af1a73), in phase order: every P5 and P6 commit,chore(release): 0.5.0(commit 153), every P7 and P8 commit,chore(release): 0.6.0(commit 494).0.5.0, models come in more ways:
import.probe, import options, background import jobs (import.start,status,cancel; one undo step; stale when the document changes) andfile.reimportwith stable part ids (scene.set_part_mesh).0.6.0, materials and the library:
material.getandcad.parts, agent edits relayed to the open window, and HASHOUT logs, docs (MATERIALS, IMPORT, LIBRARY, FILE-FORMAT, GPU-ENGINE, VIEWPORT, ARCHITECTURE), wiki pages and the skill kit for all of it.New dependencies: roxmltree (MIT OR Apache-2.0), ufbx (MIT OR Unlicense; its package ships no licence file), bevy_mikktspace (Zlib AND (MIT OR Apache-2.0)), zune-jpeg and zune-core (MIT OR Apache-2.0 OR Zlib). The engine catalogue has 121 commands;
./formshot agents syncregenerated the manifest and tool reference in each release commit.Commits
chore(release): 0.5.0: 2chore(release): 0.6.0: 2The short hashes change when the commits are signed.
Version
0.4.0 to 0.5.0 to 0.6.0, each bump the last commit of its release, in every version site the 0.4.0 release used (VERSION, package.json and package-lock.json, version.ts, tauri.conf.json, src-tauri Cargo.toml and Cargo.lock, backend
__init__.py, the thirteen native crates andnative/Cargo.lock, fsh-py, the engine usage line, README, CONTRIBUTING, NOTICE, SECURITY, ARCHITECTURE, the harness skill, the HASHOUT headers, the agent manifest). CHANGELOG.md has both sections.Checks
Every step of the five CI jobs, run by hand on Ubuntu from a fresh clone of this branch:
npm audit --audit-level=low(0 vulnerabilities), typecheck, build: pass../formshot engine check(cargo check and clippy over the workspace, all targets,-D warnings, Rust 1.99.1): pass, 164 s from an empty build folder on 2 cores. Also clippy of fsh-wasm for wasm32: pass. The 0.5.0 commit on its own also passes clippy, typecheck and the service import.pip install -r requirements.txt, compileall,import app.main: pass.cargo check --locked,cargo clippy --locked -- -D warnings: pass.bash -n,py_compile, the em dash and emoji scan: pass.Rendering: materials without slots, graphs or labels render byte-identically to 0.4.0 on the CPU and at the same speed on both tracers. Thirty QA scenes (Khronos glTF samples, every material type, procedurals, labels, thin film, dispersion, a preset per library category, under the sky and a CC0 HDRI) agree between the CPU and software Vulkan within 0.0009 mean absolute difference (tolerance 0.005), with no NaN pixels.
library.applyon one part clears the same region on both tracers and the rest keeps its samples. The window's pages ran in headless Chrome against the real engine with the CPU slowed 4 times.Not run: any physical GPU (all GPU work ran on lavapipe), a textured frame from the window's own WebGPU engine (SwiftShader cannot compile the kernel), the Tauri desktop app, macOS and Windows, the CAD worker outside Linux x86_64, a live FormSurface export, native review of the translations.
Merging
Merge with a merge commit so each commit and its signature stays. Do not squash.