Jump to content

AssetForge

From MindAttic Docs
Revision as of 17:27, 1 December 2026 by Docs Sync (talk | contribs) (md2wiki: sync from MindAttic.Docs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

AssetForge

Shared art-pipeline tooling for MindAttic projects: background cleanup, portrait framing and mesh normalisation. One engine and one command line, called by every project's own import scripts instead of each repo re-solving the same steps.

Scope

In docs/ECOSYSTEM.md (the workspace's source) AssetForge owns the art pipeline platform concern: every project's image cleanup, crop framing and mesh normalisation goes through it instead of being re-solved per repo. The complete product is written down in SPEC.md; the current finish line is RELEASE.md.

Install

The CLI is installed by the shared run menu (run.bat, or run.ps1; MAT-T279):

  • run.bat, then 1 (Redeploy), or .\run.ps1 -Redeploy, builds and installs both configurations:
    • R:\MindAttic\Apps\AssetForge\Release\assetforge.exe: self-contained, single file. This is the copy projects call. It needs no .NET install.
    • R:\MindAttic\Apps\AssetForge\Debug\assetforge.exe: framework-dependent, for trying a change.
  • .\run.ps1 -Redeploy -DryRun prints what would be built without building.

Call it by its full path, R:\MindAttic\Apps\AssetForge\Release\assetforge.exe, or put that folder on PATH. Every command prints one line of JSON on success and assetforge: <message> on stderr with exit code 1 on failure.

Packages

  • MindAttic.AssetForge: the library.
    • Background cleanup: Color-to-Alpha un-mixing with border-versus-enclosed blob erasure (BackgroundCleaner), and edge-connected flood fill with a calculated tolerance (ToleranceCleaner).
    • Portrait framing: face and figure crop boxes (PortraitCropper), and cutting and centring a figure on a square transparent canvas (PortraitFramer). The figure's alpha bounds have one owner, Imaging/AlphaBounds.
    • Mesh normalisation: recenter, rescale to a target length and yaw, with engine profiles. Anything AssimpNet reads (fbx, obj, ...) and glTF in; glTF 2.0 out (binary .glb when the output path ends in .glb, else .gltf). Both mesh paths apply one transform (NormalizeTransform).
  • MindAttic.AssetForge.Cli (assetforge): the command line over the library.

Commands

assetforge clean <input.png> <output.png> [--fuzz 3] [--hole-area 2] [--mode Auto|BorderOnly|Skip] [--border-width 12] [--dilate 2]
assetforge crop  <input.png> [--kind Face|Figure]
assetforge cut   <input> <output.png> [--method Tolerance|Unmix] [--canvas 1024] [--tolerance N] [--feather N] [--hole-area 0.005]
assetforge mesh normalize <input> <output.glb> [--engine gltf|unity|unreal|godot|<profile.json>] [--pivot Center|Base]
                          [--yaw 0] [--target-length 1] [--axis LargestDimension|X|Y|Z] [--no-recenter] [--no-scale]

clean

Removes a flat background by Color-to-Alpha un-mixing and trims the result to the figure. An image that already has partial alpha is only trimmed. Prints {"knockout":true,"originalWidth":1104,"originalHeight":1104,"trimmedWidth":804,"trimmedHeight":1009}.

crop

Prints the square crop box (--kind Face, the default: head and upper body; --kind Figure: the whole figure padded 4%) in source pixels, for example {"left":190,"top":0,"right":613,"bottom":423,"imageWidth":804,"imageHeight":1009}. A Figure box can extend past the image edges (negative left or top) when the figure fills the image.

cut

The one clean-up-and-frame step (AF-T26): removes the background, trims to the figure and centres it on a transparent square canvas (1024 by default, GridGame's portrait rule GG-T352).

  • --method Tolerance (the default) is GridGame.Studio's tools/remove_bg.py: the background colour is the median of the border pixels; the tolerance is calculated from the distance histogram (or --tolerance); only background connected to the image edge is erased, plus enclosed pockets of near-pure background at least --hole-area percent of the image; the edge is feathered over --feather (default tolerance / 2, at least 6) and defringed.
  • --method Unmix uses clean's Color-to-Alpha un-mixing instead (--hole-area default 2).
  • Framing is GridGame.Studio's fit_canvas: an image already the canvas size is kept pixel for pixel (placement included); any other is cut to its figure, scaled down only if larger than the canvas, and centred.

Prints the cut's measurements, the canvas and the figure's box as canvas fractions, for example {"cut":{"method":"Tolerance","background":[238,236,230],"tolerance":10,"feather":6,"enclosedPockets":0,"erased":0.6942},"canvas":1024,"figure":{"x":0.1074,"y":0.0068,"w":0.7852,"h":0.9854},"outputPath":"..."}.

mesh normalize

Recenters the mesh on its pivot, scales the chosen extent (--axis) to --target-length and turns it --yaw degrees about the vertical, then writes glTF 2.0. Prints {"normalized":true,"outputPath":"...","engine":"gltf","pivot":"Center","targetLengthMetres":1}; outputPath is the file written, exactly the path given.

  • Engine profiles (--engine, AF-T28): the output is always glTF (metres, +Y up, front +Z), and each engine's own glTF importer converts axes from there, so a profile never rotates the mesh. It sets where the root sits and what unit --target-length is in:
    ProfileRoot (--pivot)--target-length unit
    gltf (default)Center: the bounding box's centremetres
    unityBase: the centre of the bottom face, standing on the groundmetres (1 unit)
    godotBasemetres
    unrealBasecentimetres (1 unit), divided by 100 into the glTF's metres

    A project with other conventions passes its own profile file: --engine my-engine.json with {"name": "my-engine", "unitsPerMetre": 100, "pivot": "Base"}. --pivot overrides the profile's root. Facing a purchased pack the right way is the per-pack --yaw (Kenney's packs commonly need 180).
  • Skinned and animated glTF is read and written natively (SharpGLTF): the transform is applied above the scene's root nodes, so skins and clips play unchanged. A skinned mesh node at the scene root follows its joints instead.

Consumers

  • GridGame.Unity's portrait art (Assets/Convergence/Resources/Portraits), through GridGame.Studio's import tools, which are to call assetforge cut instead of their own remove_bg.py and portrait_cut.py copies (GGS-T72).
  • SpaceGod.Unreal's purchased-mesh imports call assetforge mesh normalize --engine unreal (US-T1087).

Each consumer's adoption is a story in its own repo that requires AssetForge's E4 (AF-T17).

Known limitation

BackgroundMode.Auto's small-enclosed-blob erasure can still misfire on art with fine internal line work (crosshatching, panel cracks) that are a similar stroke width to the subject's own outline: the lines can fragment one large pale region into many small, individually "small enough" pockets. There is no general automatic fix for this that doesn't risk bridging real background through the outline itself (tried and reverted; see git history); per-file review and a BorderOnly/Skip mode override remains the intended answer for images that hit this.

Licences

Every package the installed CLI ships, checked against the package's own nuspec in the NuGet cache (AF-T21). All allow Release builds and redistribution; none needs a paid licence.

Package Version Licence Notes
SixLabors.ImageSharp 2.1.13 Apache-2.0 Pinned on purpose: 2.1.x is the last Apache-2.0 line; 3.x and later use the Six Labors Split License, which needs a paid licence for many commercial uses (SPEC 2.2). Known advisories NU1902/NU1903 are accepted for owner-made art only (Directory.Build.props).
AssimpNet 5.0.0-beta1 MIT (wrapper) Ships the native Open Asset Import Library (assimp.dll and the Linux and macOS builds), BSD-3-Clause; both notices are in the package's License.txt, which a redistributed binary should carry.
SharpGLTF.Toolkit, SharpGLTF.Runtime, SharpGLTF.Core 1.0.7 MIT
.NET runtime and System.Text.Json 10 MIT The Release install is self-contained, so the runtime ships with it.

Do not move SixLabors.ImageSharp to 3.x or later: that is a commercial-licence dependency the SPEC rules out.

Pages in this repository

  • Code ledger: AssetForge — Every tracked source file and the ticket in this repo's tree that accounts for it (MAT-T484; method:…
  • AssetForge — Release charter — The shared art pipeline: background cleanup, portrait framing and mesh normalisation, as one library and one CLI every MindAttic project…
  • AssetForge — Product specification — In docs/ECOSYSTEM.md AssetForge owns the art pipeline platform concern. It is one engine (MindAttic.AssetForge) and one command line…
From AssetForge/docs/overview.md via MindAttic.Docs; synced automatically, so edit the repo, not this page.