Repository navigation
feat(uv): add box_uv(tile=) world-scale box projection for tiling materials - #134
Open
farisbasha wants to merge 1 commit into
Open
farisbasha wants to merge 1 commit into
farisbasha wants to merge 1 commit into
Conversation
Projects each face onto its dominant axis plane so one UV unit spans `tile` metres on every face (scene unit converted), without mirroring opposite faces. UVs go to faces[].uvs, so .glb export carries them. Closes wrong-nebula#67
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.
Adds an explicit world-scale box projection op for tiling materials, as asked in #67.
Problem
unwrap()packs LSCM islands into[0,1]^2, which is right for unique baked textures but breaks repeating materials (brick, concrete, planks): texel density changes from face to face. Onmain, a.glbonly getsTEXCOORD_0when faces carry UVs, so withoutunwrap()there are no UVs to tile with at all.What it adds
box_uv(tile=1): each face is projected onto the plane of its dominant normal axis (triplanar box mapping), and one UV unit spanstilemetres. Model units are converted with the scene unit, so mm/inch scenes get the same repeat size as metre scenes.faces[].uvs, so.glbexport carries them likeunwrap()UVs.tilemust be a positive finite number; the op is listed in theuvspec topic and in the GBNFpipe-oprule.Core function:
forma_core::uv::unwrap_box(mesh, meters_per_unit, tile).Tests
crates/forma-lang/tests/box_uv.rs(4 tests): per-face UV extent equals the face size in metres,tileand mm scenes give the same repeat, no mirrored faces, badtilevalues rejected.crates/forma-core/tests/box_uv_export.rs(2 tests): the GLBTEXCOORD_0data spans[-1,1]^2for a 2 m box withtile=1; bad inputs tounwrap_boxare rejected.cargo test --locked --release -p forma-core -p forma-lang -p forma-cli -p forma-mcp -p forma-server -- --skip test_10000_fuzzed_modeling_operations_zero_crashes_zero_nans: 163 passed, 0 failed (Linux). I did not run the npm/WASM smoke tests.Closes #67
This PR was prepared with AI assistance (Claude).