Research: primitive UV seams, SDF bevel meshing, Manifold face provenance

Eyes pass for the brush-tree seam, UV, bevel and brush-identity forks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-10-10 22:03:03 +02:00
commit fa1ee72aa6

View file

@ -0,0 +1,100 @@
<!-- Serves brush-tree forks seam-policy, uv-channels, bevel-operator, bevel-to-mesh and brush identity on faces. Eyes pass eyes-brush-tree-seams-bevels, 2026-10-10. -->
# Prior art: UV seams/parameterisation, SDF microbevels to mesh, Manifold ID/property tracking (Eyes, 2026-10-10)
Serves forks (campaign brush-tree, target brush-tree:target:r1; drafts in scratchpad\brush-tree-target\questions.md): `seam-policy`, `uv-channels`, `bevel-operator`, `bevel-to-mesh`, and `brush-identity` on faces (Manifold ID tracking, section C).
Extends GameCult.Geometry.Csg docs/research/brush-surfaces-and-sdf-bricks-prior-art.md (df89568) ([BS]); does not repeat it. Facts only; no conclusions.
Tags: FETCHED = page body read this pass (WebFetch returns a small-model extraction of the page, so quotes are extraction-mediated); SEARCH = search-result snippet/summary only; KNOWLEDGE = memory, unverified.
Fetch failures: iquilezles.org/articles/smin (404 again, also via http redirect), developer.valvesoftware.com Valve_Map_Format (403), projects.blender.org issue 47478 (403), Blender manual bevel page body (extraction returned navigation only), raw manifold.h/common.h (MeshGL struct not in them), Houdini tube/sphere pages (first 100k chars, no UV text), cgal.geids.org (dns).
## A. UV seams and parameterisation
### A1. Blender primitive UVs (source: bmesh operators bmo_primitive.cc, raw GitHub main) FETCHED
- Cylinder and cone are one path, `bmo_create_cone_exec`; UVs from `BM_mesh_calc_uvs_cone(bm, mat, rad2, rad1, segs, cap_ends, FACE_MARK, cd_loop_uv_offset)`.
- Cap layout: circles packed in lower half of the unit square when capped: `uv_center_y = cap_ends ? 0.25f : 0.5f`; top cap centre x 0.25, bottom 0.75; `uv_radius = cap_ends ? 0.24f : 0.5f`. Cap scale = `uv_radius / radius_top` (own radius per cap), measured in local space (via inverse matrix); top/bottom chosen by `dot(f->no, local_up) > 0`.
- Side strip: upper half when capped (`uv_height = cap_ends ? 0.5f : 1.0f`); U steps `1/segments` per face starting at `x = 1.0` and decreasing. No explicit seam marker in this code; seam is the start/end of the strip, and the extraction notes it depends on face iteration order.
- UV sphere (`bmo_create_uvsphere_exec`): poles at (0,0,+-rad); duplicate pole vertices merged with `remove_doubles`; pole fan triangles take U from atan2 of the average XY of the three vertices (`f->len == 3 && |x|,|y| < 0.0001`); `luv[0] = 0.5 + theta/(2pi)`, `luv[1] = 1 - phi/pi` (equirectangular; poles at V=1 and V=0). Seam at the atan2 branch cut; borderline coordinates "shifted to the left"; straddling faces get +1.0 on far vertices when U gap > 0.5; final pass subtracts global min U.
- UVs computed in local unrotated space before the matrix is applied.
- Torus: not in this file. SEARCH: Blender issue #47478 (new default UVs on some primitives "poor/missing") proposed equirectangular UV sphere and noted pole rings are triangles; torus UVs tracked separately in #47489 (not read, 403). SEARCH: helper functions declared in bmesh_operators.h: `BM_mesh_calc_uvs_grid/_sphere/_circle/_cone/_cube`; grid-seam fixes T52066 (2017), T67523 (2019, wrap threshold slightly below 1.0 so last column does not overlap first); T51180 (2017) made the UV-layer offset a parameter.
- Blender Geometry Nodes Cylinder node page: extraction returned only navigation (no UV text). Not read.
### A2. TrenchBroom (manual, trenchbroom.github.io/manual/latest, 256k chars; read chars 0-200000) FETCHED
- Format support: Quake standard and Valve 220. "Alignment lock in the Shear tool only works in Valve 220 format maps." Face attributes: plane, material, X/Y offset and scale, rotation angle.
- Projection: Paraxial = projection axis is the coordinate axis closest to the face normal (can shear slanted faces; "perfect alignment locking is impossible"). Parallel = projects along the face normal, offered only for Valve 220 maps. Shearing needs parallel projection.
- UV Lock (separate preference): when enabled, "will attempt to keep vertex UV coordinates the same" during vertex editing/face moves; alignment lock is "precise ... for all brush editing operations".
- Scale step default 0.1 per step (0.25 or 0.01 with modifiers); offset step = grid size; angle step 15 deg.
- CSG material rule: for CSG operations TrenchBroom "looks for an input face on the same plane and copies its material and attributes", otherwise applies the current material (paraphrase of extraction; no statement on cutter's-vs-target's surface for cut faces beyond this).
- Primitive creation (cylinder, cone, UV sphere, arch; scalable circles 12/24/48/96 sides): no text on how they are textured in the part read. Chars 200000-256434 not read.
- Valve 220 line syntax and default scale: page 403; remains KNOWLEDGE (see [BS] §A).
### A3. Unity ProBuilder (docs.unity3d.com/Packages/com.unity.probuilder, SEARCH snippets)
- Two UV modes: Auto (default; projects texture, Tiling scale value, "World Space" checkbox to align UVs to the world so same-angle faces line up, UVs "do not stay put when you move the object") and Manual (per vertex/edge). Auto UVs editable only per face; editing an edge/vertex converts to Manual; manual edits do not transfer back.
- No ProBuilder text found on texel density, tile-to-metre units, or cylinder/sphere-specific UVs. Pages not opened (workflow-uvs.html, auto-uvs-actions).
### A4. RealtimeCSG (Unity) SEARCH
- Asset Store text: "edit your texturing by dragging, rotating or scaling your material over the brushes". No documentation found on automatic UV method or cut-face UVs. Source-level behaviour of the successor Chisel is already in [BS] §A (per-surface 2x4 UV matrix, evaluated from final vertex positions; cut face = cutter's own base polygon surface, inferred). SabreCSG (comparison) lists per-face UV edit tools; not read.
### A5. Houdini FETCHED (negative) + SEARCH
- Tube and Sphere SOP pages (first 100k chars): no UV text. Sphere SOP: mesh-type sphere meridians meet at the poles; "Unique Points per Pole" controls whether meridians share one pole point or keep their own; "Triangular Poles" turns the degenerate pole quads into triangles.
- Houdini Boolean SOP UV/attribute transfer: see [BS] §A (SEARCH only); not extended.
### A6. OpenCASCADE / CadQuery (BRep parameter spaces) SEARCH
- `Geom_CylindricalSurface`: S(U,V) = Loc + R cos(U) X + R sin(U) Y + V Z; U in [0,2pi], periodic; V unbounded; XAxis gives U origin; a seam edge lies at U=0/2pi. (Location of the seam for `BRepPrimAPI_MakeCylinder` is the snippet author's inference from the parametrisation, not stated by a source.)
- `Geom_SphericalSurface`: U rotation about main axis, X axis gives U origin; V rotation about YDirection; poles at V limits; topology uses degenerate edges at both poles plus a seam edge joining them (tutorial, Chinese-language aliyun article, snippet). Toroidal: V increases about main axis, U chosen so D1U x D1V points outward; U/V ranges not returned.
- CADEX mesher option (SDK docs, snippet): stores UVs "of mesh nodes in parametric space domain of each B-Rep surface"; OCC forum: face-triangulation UVs can fall outside 0-1 and have very large values, fix is to normalise before export.
- Onshape/Fusion export (SEARCH): Onshape export presets (Coarse/Medium/Fine/Custom with distance/angular tolerance, max chord length) for glTF/OBJ/3MF; user reports of no `vt` in OBJ export, glTF UVs present but "no consistency in proportions"; Onshape emits a sub-mesh per face. Fusion reports conflict (one says cube exports with UVs, an older one says no texture info). No source for how planar/cylindrical faces are mapped.
### A7. Property/ID propagation through booleans (cut-face attributes)
- Manifold: section C.
- libigl `mesh_boolean` (SEARCH, header comments of a mirror at git.inf-cv.uni-jena.de/3DFaces/libigl_Martin): output `J` = "#FC list of indices into [Flist[0];Flist[1];...;Flist[k]] revealing 'birth' facet" (two-mesh overload: indices into [FA;FB]). PyMesh (SEARCH): per-face attribute `source` (0 = first operand) and `source_face` (combined input face index). Property interpolation across new vertices: not described in the snippets. Mirror is old; current upstream unconfirmed.
- CGAL Polygon_mesh_processing corefinement (SEARCH): `PMPCorefinementVisitor` concept with face hooks `before_face_copy` / `after_face_copy` (Boolean-specific, 5.1 docs), `before_subface_creations` / `after_subface_created` (face split during corefinement); edge hooks added from 5.3. Default is `Corefinement::Default_visitor`. No official example found propagating a property map through a Boolean.
- DarkRadiant subtract and Hammer texture lock: [BS] §A.
### A8. Not found (curved-primitive questions)
- Texel-density keeping across primitives: no source found in any tool above (ProBuilder gives Tiling/World Space only; Blender cap circle scaled to unit-square cell by its own radius, the side strip fixed to 1/segments per face). Cube-sphere/octahedral/torus/sweep sources: none fetched this pass. Blender torus UV code, Valve 220 spec, Blender Geometry Nodes primitive UV text, Houdini UV attribute on primitives: not read.
## B. Turning SDF microbevels into mesh
### B1. hg_sdf operators (mercury.sexy/hg_sdf/hg_sdf.glsl) FETCHED
- Header: "Stay Lipschitz continuous. That means: don't have any distance gradient larger than 1." "Underestimating distances will happen. That's why calling it a 'distance bound' is more correct." "The invariant is: each fSomething() function returns a correct distance bound."
- Operator section: the ops "are designed to actually produce correct distances or distance bounds, unlike popular 'smooth minimum' operators, on the condition that the gradients of the two SDFs are at right angles." "When they are off by more than 30 degrees or so, the Lipschitz condition will no longer hold (i.e. you might get artifacts)." Most take a radius `r`; some check `if ((-a < r) && (-b < r))` to limit influence and cost to a region.
- fOpUnionChamfer: `min(min(a,b), (a - r + b)*sqrt(0.5))`, "45-degree chamfered edge (the diagonal of a square of size r)". fOpUnionRound: `u = max(vec2(r-a, r-b), 0); return max(r, min(a,b)) - length(u)`, "quarter-circle". Correction term is zero when a and b are both >= r. fOpUnionSoft: "Similar to fOpUnionRound, but more lipschitz-y at acute angles (and less so at 90 degrees)"; `e = max(r - abs(a-b), 0); min(a,b) - e*e*0.25/r` (same as Dreams soft_min in [BS] §C); deviates from min only where abs(a-b) < r. fOpPipe `length(vec2(a,b)) - r`, "not a boolean operator". fOpEngrave `max(a, (a + r - abs(b))*sqrt(0.5))`. fOpUnionColumns: differs from min only where both a,b < r. fOpUnionStairs: "much less stupid version by paniq". Source states no bound property for Chamfer/Round/Engrave/Columns/Stairs individually; the only stated condition is the right-angle gradient clause above.
### B2. Smooth-min (Quilez) SEARCH, article body not read
- Search summary of iquilezles.org/articles/smin: exponential smin gives the same result regardless of chaining order (smin(a,smin(b,c)) == smin(b,smin(a,c))); polynomial and root variants do not; exponential generalises to n distances. Article's bound/exactness statements: not obtained. [BS] §C already holds the polynomial formula and a Shadertoy comment that smooth-min is not SDF-preserving.
- Sphere tracing and smooth union (SEARCH): a source says max and the smooth operators return a lower bound on true distance (never larger, sometimes smaller); a smaller step costs iterations rather than causing overshoot; overshoot arises when gradient exceeds 1. Segment-tracing paper (Galin et al., "Segment Tracing Using Local Lipschitz Bounds", CGF 2020) sets a global Lipschitz bound of 1.45 "to accommodate field compression"; blog (digitalfreepen.com) reports stepping up to ~50% faster than the derived limit before visible artefacts (~3x with Perlin noise added). A shader demo (gamedev.net shaderlab 28) describes polynomial smooth-min as leaving the surface slightly outside the intersection and adding a quadratic correction; gradient magnitude not analysed. Whether polynomial smin of two 1-Lipschitz fields can exceed gradient 1: not found in sources (KNOWLEDGE only).
### B3. Meshing implicit fields with sharp features
- Dual Contouring (Ju, Losasso, Schaefer, Warren, SIGGRAPH 2002) SEARCH: contours a signed grid with Hermite data (exact edge intersections and normals); avoids a separate feature-detection step; vertices at QEF minimiser per cell, made numerically stable; QEF also drives octree simplification. Schaefer-Warren follow-up: "mass points" for rank-deficient QEFs, handling of non-manifold sign configurations. Manifold DC (Schaefer, Ju, Warren): states DC "may generate non-manifold surfaces" (edge shared by >2 polygons; vertex neighbourhood not a disk). Thin features (sheet thinner than a cell): none of the retrieved sources discuss it. PDFs located but not read: cs.wustl.edu/~taoju/research/dualContour.pdf, people.engr.tamu.edu/schaefer/research/dualcontour.pdf, dualsimp_tvcg.pdf, dmc.pdf.
- "Dual Contouring of Signed Distance Data" (arXiv 2604.00157, 2026) FETCHED (html): reconstructs from SDF grid values without arbitrary function access or gradients; init: sign-change edge intersections by linear interpolation, normals from trilinear-interpolant gradients, cell vertex at Hermite-point centroid; outer loop re-assigns SDF samples to cells by closest mesh point, optimises vertex with distance term + DC Hermite term, refits Hermite data by PCA; inner loop linearised regularised quadratic; vertex may leave its cell. Reported failure modes: self-intersections and face flips when vertices leave cells; sensitivity to noise (chamfer error worse than some baselines at noise 0.01); isolated dents along feature curves; high Hermite weight unstable (spikes); manifoldness not guaranteed (future work). Fillets and thin features not discussed. Newton projection not used or mentioned.
- libfive (SEARCH, secondhand Curv mailing-list post, groups.google.com/g/curv/c/7hMmGQFav7w): libfive's mesher is "mostly manifold dual contouring, which snaps to sharp features and is watertight and manifold, but may contain self-intersections"; uses partial derivatives to place vertices on features, so integrations must supply derivatives. libfive's own docs/Keeter's paper not fetched this pass. Fidget/MPR details (JIT, tapes, autodiff normals) are in [BS] §D.
- nTop (docs.ntop.com, SEARCH): "Mesh from Implicit Body" tolerance step-down (start at 30-50% of minimum feature size); sharpening option, 3 iterations recommended start, `Sharpen Extents` to limit region; simplification and remesh options (growth rate 1.2-1.5 for fidelity; span angle and chord height controls); export target closed, edge-manifold, oriented, not self-intersecting; field health checked in a Field Viewer (parallel evenly spaced contours = healthy SDF, "Show Defects" for discontinuities; common field defects from edge-to-edge booleans, "fake zeros" from coincident surfaces, distorted fields from custom equations); booleans of distant bodies share one voxel grid so sharp edges may round off. No fillet/blend-field-specific meshing text found.
### B4. Manifold smoothing and fillet-like options (manifoldcad.org jsuser Manifold.html + wiki Manifold-Library) FETCHED
- `smoothOut(minSharpAngle=52.5, minSmoothness=0)`: edges sharper than minSharpAngle stay sharp; others smoothed to G1; flat faces of >=3 triangles stay flat; "minSmoothness ... The default gives a hard edge, while values > 0 will give a small fillet on these sharp edges"; 1 equals minSharpAngle 180.
- `smoothByNormals(normalIdx=0)`: fills halfedgeTangent vectors; geometry unchanged until `refine`/`refineToLength` interpolates; vertices where multiple disagreeing normals exist become sharp edges.
- `refine(n)`: splits every edge into n; new vertices coplanar unless halfedgeTangents are present, then moved to the interpolated surface by barycentric coordinates. `refineToLength`, `refineToTolerance` ("All vertices are exactly on the surface, within rounding error").
- Wiki: smoothing aims at G1 (G2 explicit non-goal); each edge gets two weighted cubic Bezier control points; sharpening takes half-edges with smoothness 0..1, "a crease is only formed at a smoothness of zero"; "The Boolean works only on flat triangles and ignores control points, so refine before booleaning curved meshes."
- `calculateNormals(normalIdx=0, minSharpAngle=52.5)`: fills normal properties; "Flat faces composed of three or more triangles will remain flat"; edges beyond the angle get different normals on each side; 0 gives faceted. Non-zero normalIdx "will not be supported in a future release".
### B5. Mesh-boolean-then-bevel practice
- Blender Bevel modifier (4.1 manual snippets, SEARCH; 5.2 page body not extracted): Harden Normals adjusts bevel-face vertex normals to match surrounding faces so flat neighbours stay flat and the bevel shades smoothly, needs custom split normals (auto-enabled; 2.8x required Auto Smooth); Mark Seam / Mark Sharp keep seam/sharp propagation consistent when bevelling edges that cross; Face Strength (None/New/Affected, older: All) sets strengths (new edge faces Medium, vertex faces Weak, Affected adds Strong on adjacent) for a following Weighted Normals modifier with Face Influence. UV handling of bevel faces: not found.
- Hard-surface game workflow (polycount threads and vendor guide, SEARCH; practitioner opinion): one smoothing group + bevels + weighted normals instead of hard-edge splits (fewer split vertices, cleaner normal-map gradients when a normal map is used); one poster found chamfer/support loops on the low poly bake less finely than a high-poly bevel and cost more polygons than hard edges when silhouette is kept; wavy reflections on fake bevels at low texel density; ordering: fix topology and bevel width, then hard/soft boundaries, then weighted normals last; "resolve Boolean intersections before beveling" (duplicate faces give unstable highlights); triangulate late and inspect long diagonals on non-planar faces; custom normals can be lost on FBX import; Blender GSoC 2018 thread: Weighted Normal modifier last in the stack; weighted-normal gradients baked into a low poly can cause a compensating gradient when baking from high poly. Hard Ops/Boxcutter: [BS] §C.
- CGAL/other "bevel on a mesh" operators: not searched.
### B6. Not found
- Newton projection onto f=0 for strip vertices as an established mesh-extraction technique: no source surfaced. Edge-strip emission at CSG cut edges from a field: none. Failure modes for overestimating bounds specifically in meshing: only the sphere-tracing material in B2 (rendering, not meshing).
## C. Manifold: properties and original-ID tracking through booleans
- Properties (wiki Manifold-Library, manifoldcad.org docs) FETCHED/SEARCH: arbitrary number of float channels per vertex ("merely float values indexed by channel number"); user decides meaning (colour, UV, normal); linearly interpolated across each triangle; vertices and property verts are not one-to-one: "along a Boolean intersection curve each vertex will have different properties on each side"; the design allows "sudden property changes, e.g. at Boolean intersections, without sacrificing manifoldness". Properties of separate input objects "are kept separate" so channel meaning need not agree across inputs. The pages do not state the interpolation rule at the new vertices of a boolean beyond this (FETCHED, negative).
- MeshGL fields (manifoldcad.org C++ docs, structmanifold_1_1_mesh_g_l_p.html) FETCHED: `numProp` ">= 3", `vertProperties` flat interleaved, first three always position; `triVerts` CCW from outside; `mergeFromVert`/`mergeToVert` optional (vertices to merge to reconstruct the manifold; same position, possibly different other properties); `runIndex` ("runs of triangles that correspond to a particular input mesh instance", start index divisible by 3); `runOriginalID` ("The OriginalID of the mesh this triangle run came from", several runs may share an ID); `runTransform` (3x4 column-major per run); `faceID` ("Optional: Length NumTri, contains the source face ID this triangle comes from"); `halfedgeTangent` (weighted XYZW for smooth Refine; empty = faceted); `tolerance` ("for mesh simplification"; edges shorter may be collapsed); `Merge()`.
- IDs (wiki + jsuser) FETCHED: each Manifold built from scratch gets a unique sequential `originalID`; after booleans each triangle refers back via `originalID` and `faceID`; `faceID` is an input triangle index, and for coplanar triangles "the index of the largest area triangle of that face is used as the faceID for all of those triangles"; each input instance appears as its own triangle run, sorted by originalID. `reserveIDs(n)`: "Returns the first of n sequential new unique mesh IDs for marking sets of triangles that can be looked up after further operations. Assign to Mesh.runOriginalID vector." `asOriginal()`: resets IDs so descendants reference this mesh; "also condenses all coplanar faces in the relation, and collapses those edges." `originalID()` returns the ID for an original, -1 for a product. JS guide for multi-material input: call `reserveIDs()` to give each material a unique originalID and sort materials into triangle runs.
- Boolean precision (wiki): no tolerance parameter; "does not account for any tolerance", uses symbolic perturbation; manifold carries internal epsilon; `MeshGL.Merge` takes a `precision` argument.
- Header manifold.h (raw, master) FETCHED: confirms `SetProperties(numProp, fn)`, `CalculateNormals`, `Refine*`, `SmoothByNormals`, `OriginalID`, `AsOriginal`, `ReserveIDs`; no behaviour text in the header. Error enum includes `RunIndexWrongLength`, `FaceIDWrongLength`, `PropertiesWrongLength`, `InvalidTangents`.
- OpenSCAD: Manifold is the default backend (announcement quoted in SEARCH result; CGAL via `--backend=cgal`); 3MF coloured export reported working on the Manifold backend (Fabbaloo/mailing-list snippets). How OpenSCAD maps colours onto originalID/runOriginalID: not found (OpenSCAD source not read).
- Local note: the mapping from a brush to a Manifold originalID would be a user choice of `reserveIDs` per input; nothing in the pages read assigns IDs per brush automatically.
## Gaps for a follow-up
Quilez smin article body (bound/exactness per variant); Valve 220 spec text; Blender torus/cube UV code and Geometry Nodes primitive UV text; Blender bevel manual body and bevel UV behaviour; DC paper body (thin features, QEF limits); libfive docs; sphere/cube-sphere/octahedral/torus/sweep UV sources; texel-density-across-primitives sources; Manifold interpolation rule for properties at new boolean vertices (source code `src/boolean3` / `boolean_result.cpp` unread); OpenSCAD colour-to-originalID mapping; libigl upstream `J`; CGAL property propagation example; Newton-projection-onto-isosurface literature.