@babylonjs-toolkit/agent 1.2.15 → 1.2.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -2
- package/lib/diskinfo/cli.js +40 -6
- package/lib/diskinfo/report.js +28 -15
- package/package.json +1 -1
- package/skills/bt-blender/SKILL.md +386 -0
- package/skills/bt-blender/THIRD_PARTY_NOTICES.md +141 -0
- package/skills/bt-blender/references/art-style-and-genre.md +173 -0
- package/skills/bt-blender/references/characters-and-creatures.md +644 -0
- package/skills/bt-blender/references/environments.md +478 -0
- package/skills/bt-blender/references/game-engine-export.md +284 -0
- package/skills/bt-blender/references/geometry-nodes.md +447 -0
- package/skills/bt-blender/references/hard-surface.md +720 -0
- package/skills/bt-blender/references/procedural-generation.md +358 -0
- package/skills/bt-blender/references/rigging-and-animation.md +1080 -0
- package/skills/bt-blender/references/sculpting-and-retopology.md +544 -0
- package/skills/bt-blender/references/uv-and-pbr-materials.md +381 -0
- package/skills/bt-blender/references/vehicles.md +632 -0
- package/skills/bt-blender/scripts/blender/assembly_check.py +420 -0
- package/skills/bt-blender/scripts/blender/character_blockout.py +462 -0
- package/skills/bt-blender/scripts/blender/construction_kit.py +1710 -0
- package/skills/bt-blender/scripts/blender/environment_kit.py +525 -0
- package/skills/bt-blender/scripts/blender/export_asset.py +623 -0
- package/skills/bt-blender/scripts/blender/geometry_nodes_builders.py +575 -0
- package/skills/bt-blender/scripts/blender/hard_surface_panels.py +374 -0
- package/skills/bt-blender/scripts/blender/hard_surface_trims.py +200 -0
- package/skills/bt-blender/scripts/blender/image_measure.py +568 -0
- package/skills/bt-blender/scripts/blender/materials_pbr.py +439 -0
- package/skills/bt-blender/scripts/blender/measure_stations.py +486 -0
- package/skills/bt-blender/scripts/blender/ortho_views.py +309 -0
- package/skills/bt-blender/scripts/blender/procedural_game_ready.py +258 -0
- package/skills/bt-blender/scripts/blender/procedural_generators.py +842 -0
- package/skills/bt-blender/scripts/blender/qa_check.py +729 -0
- package/skills/bt-blender/scripts/blender/retopology_tools.py +781 -0
- package/skills/bt-blender/scripts/blender/review_render.py +358 -0
- package/skills/bt-blender/scripts/blender/rigging_tools.py +1170 -0
- package/skills/bt-blender/scripts/blender/style_palette.py +190 -0
- package/skills/bt-blender/scripts/blender/tool_common.py +289 -0
- package/skills/bt-blender/scripts/blender/uv_layout.py +555 -0
- package/skills/bt-blender/scripts/blender/vehicle_parts.py +370 -0
- package/skills/bt-blender/scripts/blender/view_consistency.py +133 -0
- package/skills/bt-blender/scripts/blender/world_gate.py +219 -0
- package/skills/bt-blender/scripts/bt-blender.mjs +329 -0
- package/skills/bt-blender/scripts/validate_gltf.mjs +204 -0
- package/skills/bt-gauntlet/SKILL.md +6 -6
- package/skills/bt-gauntlet/references/critic-rubrics.md +71 -4
- package/skills/bt-gauntlet/references/spec-composition.md +13 -0
- package/skills/bt-gauntlet/references/unity-pipeline.md +18 -2
- package/skills/bt-unwrap/scripts/blender/__pycache__/bt_unwrap.cpython-313.pyc +0 -0
- package/skills/bt-unwrap/scripts/blender/__pycache__/image_utils.cpython-313.pyc +0 -0
- package/skills/bt-unwrap/scripts/blender/__pycache__/mesh_tools.cpython-313.pyc +0 -0
- package/skills/bt-unwrap/scripts/blender/__pycache__/model_io.cpython-313.pyc +0 -0
- package/skills/bt-unwrap/scripts/blender/__pycache__/previews.cpython-313.pyc +0 -0
- package/skills/bt-unwrap/scripts/blender/__pycache__/rasterizer.cpython-313.pyc +0 -0
- package/skills/bt-unwrap/scripts/blender/__pycache__/reference_views.cpython-313.pyc +0 -0
- package/skills/bt-unwrap/scripts/blender/__pycache__/reference_warp.cpython-313.pyc +0 -0
- package/skills/bt-unwrap/scripts/blender/__pycache__/texture_bake.cpython-313.pyc +0 -0
- package/skills/bt-unwrap/scripts/blender/__pycache__/texture_compose.cpython-313.pyc +0 -0
- package/skills/bt-unwrap/scripts/blender/__pycache__/uv_layout.cpython-313.pyc +0 -0
|
@@ -0,0 +1,720 @@
|
|
|
1
|
+
# Hard-surface modelling: cuts, seams, bevels, normals, trims and decals
|
|
2
|
+
|
|
3
|
+
**Load this when** an asset is manufactured rather than grown: housings, panels, hatches, machinery, weapons,
|
|
4
|
+
props, vehicle bodywork details, architecture trim. Load it in particular when you must choose between mid-poly,
|
|
5
|
+
high-to-low baking and pure low-poly, when you cut panels, holes or vents into a surface, or when a part reads
|
|
6
|
+
blocky, pinched or soft in review.
|
|
7
|
+
|
|
8
|
+
**What it assumes.** The basics are in the Agent Reference's Blender guide (`references/unity-blender-cli.md`):
|
|
9
|
+
§8.4b (measure stations and form against the references), §8.4c (research before inventing a technique) and
|
|
10
|
+
§8.4d (the construction kit: lofts, lathes, tubes, cages, holding loops at 0.57 x the loop width, radius-sized
|
|
11
|
+
bevels, the Mirror, Boolean, Bevel, Weighted Normal stack, boolean hygiene). This file goes deeper and does not
|
|
12
|
+
repeat them.
|
|
13
|
+
|
|
14
|
+
**Helpers.** `scripts/blender/hard_surface_panels.py` (grid cage, inset recess, panel groove, round socket,
|
|
15
|
+
boolean cut with rim edges, mid-poly finish, normal transfer, edge-radius measurement) and
|
|
16
|
+
`scripts/blender/hard_surface_trims.py` (trim strips, quad-strip mapping, mesh decals); for rolled panels, the
|
|
17
|
+
construction kit's `design_line_cage` and `cage_audit` (section 3a). Every recipe below is a
|
|
18
|
+
complete script: save it and run `node <skill>/scripts/bt-blender.mjs run recipe.py <out folder>`.
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## 1. The professional workflow
|
|
23
|
+
|
|
24
|
+
1. **Read the form language before anything else** (§8.4b step 0). Write it per part from the highlights:
|
|
25
|
+
- a highlight that sweeps continuously across the part is a **roll**: estimate its radius;
|
|
26
|
+
- a brightness step between flat areas is a **facet**;
|
|
27
|
+
- a thin bright line along an edge is a small **bevel** on a hard edge.
|
|
28
|
+
|
|
29
|
+
This decides the technique. The commonest failure is reading a rolled form as "hard surface" or "faceted":
|
|
30
|
+
the part is then built from planes with weighted normals, its widths all MATCH, and it still reads blocky.
|
|
31
|
+
Rolled, flowing panels follow section 3a: design lines first, then a sparse quad cage with a sharpness per
|
|
32
|
+
line.
|
|
33
|
+
In one production vehicle build, a shoulder the reference rolled over about 40 mm was modelled with a
|
|
34
|
+
chine of radius about 0. Five rounds of width fixes followed before anyone measured the radius.
|
|
35
|
+
2. **Primary, secondary, tertiary.** Block the big masses, then the medium forms (panels, steps, housings), then
|
|
36
|
+
the small details (bolts, vents, labels). Every edge and vertex should have a job. Small details go into
|
|
37
|
+
textures, trims or decals unless they change the silhouette at play size (section 8).
|
|
38
|
+
3. **Choose the production route** (section 2) before the first cut. It decides whether cuts need clean
|
|
39
|
+
quads (subdivision), whether booleans may stay as n-gons (mid-poly), and what the texture does.
|
|
40
|
+
4. **Cut on topology that is ready for the cut** (section 3), or use a boolean the route allows (section 4).
|
|
41
|
+
5. **Finish the edges and normals** (section 5), **then UVs, trims and decals** (section 6).
|
|
42
|
+
6. **Measure and gate** (section 9): the edge radii on sections, stations and IoU, qa-check, and a render at
|
|
43
|
+
the in-game pixel height.
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
## 2. Choosing the route
|
|
48
|
+
|
|
49
|
+
| Route | What ships | Edges come from | Texturing | Choose it when | Web / BabylonJS notes |
|
|
50
|
+
|---|---|---|---|---|---|
|
|
51
|
+
| **Mid-poly** (bevel + custom normals, no bake) | The bevelled mesh itself | Geometric bevels; face-area weighted normals keep the flats flat | Tiling materials and trim sheets; baked masks (curvature, AO) at most | Props and environment pieces seen up close, large surfaces with tiling texture, fast iteration, many similar assets | Custom normals export as the glTF `NORMAL` attribute. Every hard edge and UV seam splits vertices, so put hard edges on UV seams (they are free there) |
|
|
52
|
+
| **Subdivision, applied** (the kit's cage route) | A cage on the design lines with creases and holding loops, subdivided and applied | Sharpness per line: creases, and holding-loop spacing for set radii (0.57 x the loop width) | Unique UVs (bt-unwrap) or trims | Rounded, flowing manufactured forms: moulded shells, rolled shoulders, blends and junctions (section 3a) | Level 2 on rolled panels that must read smooth, level 1 on small parts; check the triangle count after applying |
|
|
53
|
+
| **High-to-low bake** | A low poly with a baked normal map | The high poly's bevels, baked | Unique UVs, baked normal, AO, curvature | Hero pieces with a tight triangle budget and unique texture | One normal map per asset; export tangents (`export` does). Baking is bt-unwrap's job |
|
|
54
|
+
| **Pure low poly** | Flat or softly shaded low poly | Silhouette only; no bevels or a single chamfer | Palette atlas, vertex colour or hand-painted | Stylised, far-seen or mobile; see `art-style-and-genre.md` | Cheapest draw and memory, but flat shading costs vertices |
|
|
55
|
+
|
|
56
|
+
How studios mix them:
|
|
57
|
+
- Mid-poly with face-weighted normals, tiling materials and floating decals was the production method on
|
|
58
|
+
space and sci-fi titles with enormous surface area. It avoids building every asset twice and frees UVs from
|
|
59
|
+
splitting at every 90-degree edge, which raises texel density.
|
|
60
|
+
- High-to-low is still preferred for hard-surface hero pieces.
|
|
61
|
+
- A mid-poly base is often baked as well. Bevel weights are kept for the bake, and baked maps then drive edge
|
|
62
|
+
wear masks.
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
## 3. Cuts that subdivide cleanly
|
|
67
|
+
|
|
68
|
+
A subdivision surface keeps a cut crisp only when loops hold it, and pinches when the cut ignores the
|
|
69
|
+
topology around it. The rules professionals work by:
|
|
70
|
+
|
|
71
|
+
| Rule | Why | How the helpers apply it |
|
|
72
|
+
|---|---|---|
|
|
73
|
+
| **Cuts land on existing loops.** Choose the cage's grid so every planned panel, hatch and hole starts and ends on grid lines. | A cut across faces leaves triangles and poles where the cage curves, and the surface ripples | `grid_plate(columns, rows)`; pick regions with `top_faces_in` |
|
|
74
|
+
| **A support ring around every cut.** Inset the region first so a quad ring separates it from the surrounding surface. | The holding loops of the cut then live on the ring, not on the big panel | `inset_recess(rim_width=...)`, `round_hole(rim_width=...)` |
|
|
75
|
+
| **Hole side count = the patch's boundary count.** A 2 x 2 patch gives an 8-sided hole, 4 x 4 gives 16. Rotate or re-grid until they match. | The ring between the square and the circle is then all quads; a mismatch forces triangles that pinch | `round_hole` projects the patch boundary onto the circle |
|
|
76
|
+
| **Six to eight spans per quarter for a visible round; four for background.** | Fewer spans facet the curve after subdivision | `steps` and grid density |
|
|
77
|
+
| **Ring width and wall depth at least twice the loop width.** A wall carries two loops (rim and floor). | The Bevel modifier's *Clamp Overlap* is **global**: one feature too tight for its loops shrinks the radius on every edge of the part (a 12 mm socket wall under 7 mm loops took all radii from 4.0 to 3.4 mm on Blender 5.3.0) | Loop width = radius / 0.57 (§8.4d); small features get a lower bevel weight (section 3 recipe) |
|
|
78
|
+
| **Poles (5+ edges) on flat areas only.** | A pole on a curve dents the subdivided surface | Keep cuts off the rolled zones |
|
|
79
|
+
| **Keep every face planar on faceted parts.** | A non-planar quad is triangulated along an arbitrary diagonal by the engine, and smooth normals then smear a fold across it (seen as warped, crumpled facets). A mirrored half can flip the diagonal. | Split strips so each quad is planar within about 1 mm, or triangulate on purpose along the crease |
|
|
80
|
+
| **A crisp element on a big rounded panel is a separate insert.** | Cutting it in forces loops across the whole panel | Model lamps, lenses and housings as separate meshes sunk 1 to 2 mm into the surface |
|
|
81
|
+
|
|
82
|
+
**Soft folds** read better as creases than as hard loops. Blender's crease saturates at 0.6 (section 3a), so use
|
|
83
|
+
0.3 to 0.5 for a soft fold and 0.6 for a defined one. Creases do not export, but they are applied with the
|
|
84
|
+
subdivision in Blender.
|
|
85
|
+
|
|
86
|
+
**Measure the radius you built.** Do not judge a holding-loop radius by eye or with a circle fit. A subdivided
|
|
87
|
+
edge is not a circular arc, so a circle fit depends on which points count as "off the flats". One 0.05 m corner
|
|
88
|
+
read anywhere from 0.038 to 0.086 m on Blender 5.3.0. Use the **equal-depth radius** instead. The distance d
|
|
89
|
+
from the sharp corner to the surface along the bisector gives r = d / (1 / sin(a / 2) - 1), which is 0.414 r
|
|
90
|
+
at 90 degrees. `panels.corner_radius_in_section` measures it, and returned 0.00399 m for loops sized to 0.004 m
|
|
91
|
+
at subdivision levels 1, 2 and 3.
|
|
92
|
+
|
|
93
|
+
**Read the clamp report.** `kit.subdivision_cage(..., holding_corner_radius=r)` returns a `holding_check`:
|
|
94
|
+
the loop width set, the width the bevel really got, the effective corner radius and any folded faces. It warns
|
|
95
|
+
when Clamp Overlap shrank the loops: an 8 mm slab in the same object took 4 mm loops to 2.28 mm everywhere
|
|
96
|
+
(measured 2.276 mm) on Blender 5.3.0. Split the thin feature into its own object or give it a lower bevel
|
|
97
|
+
weight; `clamp_overlap=False` keeps the full width but lets tight features fold.
|
|
98
|
+
|
|
99
|
+
### Recipe: a panel with a recessed hatch, a round socket and a panel line
|
|
100
|
+
|
|
101
|
+
This is the hard-surface test asset. Every edge rolls 4 mm, matching the radius measured on the reference.
|
|
102
|
+
|
|
103
|
+
```python
|
|
104
|
+
"""Hard-surface panel: hatch, socket and panel line cut into a grid cage, held by loops sized from the
|
|
105
|
+
measured edge radius, subdivided once, measured, unwrapped and saved as panel.blend."""
|
|
106
|
+
import json
|
|
107
|
+
import os
|
|
108
|
+
import sys
|
|
109
|
+
|
|
110
|
+
import bpy
|
|
111
|
+
|
|
112
|
+
import construction_kit as kit
|
|
113
|
+
import hard_surface_panels as panels
|
|
114
|
+
|
|
115
|
+
out_folder = sys.argv[sys.argv.index("--") + 1]
|
|
116
|
+
EDGE_RADIUS = 0.004 # every machined edge on the reference rolls 4 mm
|
|
117
|
+
PLATE_THICKNESS = 0.04
|
|
118
|
+
|
|
119
|
+
kit.clear_default_scene()
|
|
120
|
+
# A 1.0 x 0.4 m slab on a 0.1 m grid: every cut below starts and ends on a grid line, one cell from the rim.
|
|
121
|
+
plate = panels.grid_plate("Panel", 1.0, 0.4, PLATE_THICKNESS, columns=10, rows=4)
|
|
122
|
+
hatch = panels.inset_recess(plate, panels.top_faces_in(plate, (-0.4, -0.2), (-0.1, 0.1)), rim_width=0.02, depth=0.015)
|
|
123
|
+
# Ring width and wall depth are at least twice the loop width (0.004 / 0.57 = 7 mm), so the loops fit.
|
|
124
|
+
socket = panels.round_hole(plate, panels.top_faces_in(plate, (-0.1, 0.1), (-0.1, 0.1)), radius=0.03, depth=0.015,
|
|
125
|
+
rim_width=0.015)
|
|
126
|
+
groove = panels.panel_groove(plate, panels.top_faces_in(plate, (0.2, 0.3), (-0.1, 0.1)), width=0.008, depth=0.004)
|
|
127
|
+
|
|
128
|
+
# Holding loops on every edge sharper than 60 degrees (rims, floors, the slab's outline) at the full radius,
|
|
129
|
+
# and on the narrow groove at a quarter of it: bevel weight scales the loop width per edge, and a groove
|
|
130
|
+
# too narrow for full loops would clamp every radius on the part. Read the edges AFTER the last cut.
|
|
131
|
+
GROOVE_WEIGHT = 0.25
|
|
132
|
+
holding = {edge: 1.0 for edge in panels.outline_edges(plate)}
|
|
133
|
+
holding.update({edge: GROOVE_WEIGHT for edge in groove["lip_edges"] + groove["bottom_edges"]})
|
|
134
|
+
kit.subdivision_cage(plate, levels=1, holding_corner_radius=EDGE_RADIUS, holding_edges=holding)
|
|
135
|
+
|
|
136
|
+
# Prove the radius on sections through the evaluated mesh before applying anything.
|
|
137
|
+
hatch_rim = panels.corner_radius_in_section(plate, "X", -0.3, (0.08, PLATE_THICKNESS), window=0.02)
|
|
138
|
+
slab_edge = panels.corner_radius_in_section(plate, "X", -0.3, (0.2, PLATE_THICKNESS), window=0.02)
|
|
139
|
+
|
|
140
|
+
kit.apply_modifiers(plate)
|
|
141
|
+
kit.shade_smooth(plate) # every edge is rolled: no design lines, no angle splits
|
|
142
|
+
kit.smart_unwrap(plate)
|
|
143
|
+
plate.data.materials.append(bpy.data.materials.new("Panel_Paint"))
|
|
144
|
+
plate.data.calc_loop_triangles()
|
|
145
|
+
|
|
146
|
+
bpy.ops.wm.save_as_mainfile(filepath=os.path.join(out_folder, "panel.blend"))
|
|
147
|
+
print(json.dumps({"socket_sides": socket["sides"], "groove_lip_edges": len(groove["lip_edges"]),
|
|
148
|
+
"hatch_rim_radius_m": round(hatch_rim, 5), "slab_edge_radius_m": round(slab_edge, 5),
|
|
149
|
+
"target_radius_m": EDGE_RADIUS, "triangles": len(plate.data.loop_triangles)}))
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
Then run `qa-check --model panel.blend`. It is clean on the web profile. Both radii come out at 0.0040 m.
|
|
153
|
+
|
|
154
|
+
---
|
|
155
|
+
|
|
156
|
+
## 3a. Rounded surfacing: the professional method
|
|
157
|
+
|
|
158
|
+
Rounded manufactured forms (bodywork, pods, cheeks, cowls, helmets, housings that roll) fail in one of two
|
|
159
|
+
ways, and professionals avoid both:
|
|
160
|
+
|
|
161
|
+
| Build | Reads as | Why |
|
|
162
|
+
|---|---|---|
|
|
163
|
+
| Planar solids, unions of boxes and wedges, small bevels | **Blocks** | Every face is a plane, so the highlight breaks at every plane change. No bevel width fixes it. |
|
|
164
|
+
| A subdivided cage that carries no design lines | **Blobs** ("a bar of soap") | Perfectly smooth, but no line has a sharpness, so nothing has character |
|
|
165
|
+
| SDF or remesh blends | Crumpled | Nobody controls where the edges go |
|
|
166
|
+
| **A sparse quad cage whose edges are the design lines, with a sharpness chosen per line** | **Professional** | Broad, softly curved panels between the lines; the character comes from where the sharpness sits |
|
|
167
|
+
|
|
168
|
+
### Rules
|
|
169
|
+
|
|
170
|
+
1. **Curves and outlines first, then the quad skin. Never start from cubes.** Name every line the reference
|
|
171
|
+
shows (crisp edge, fold, highlight crest, seam, silhouette) and trace each as a 3D polyline from two views
|
|
172
|
+
(plan x(y), side z(y)). The cage is the grid of quads between those lines, so every cage edge lies on a
|
|
173
|
+
line and every line is an edge chain. Vehicle artists start from "an edge outline that works as a 3D
|
|
174
|
+
blueprint" (Karol Miklas), CAD builders give "every curve on the surface its own guideline", and Blender
|
|
175
|
+
car builds start from a single plane with Mirror and Subdivision. `kit.design_line_cage` builds this grid.
|
|
176
|
+
2. **Sparse and even.** About 6 to 12 vertices across a panel and 6 to 9 stations along it. If moving two or
|
|
177
|
+
three vertices does not move a whole highlight, the cage is too dense: "the least amount of vertices makes
|
|
178
|
+
it possible to easily create flowing reflections" (Ali Ismail). Neighbouring edges along a loop stay
|
|
179
|
+
within 1.5 : 1 on rolled zones (`cage_audit` reports `max_edge_ratio`), or the highlight bunches.
|
|
180
|
+
3. **Flow follows the form, and lines connect.** Rows run along a roll and loops run round an arc, never
|
|
181
|
+
across it. A crease or holding loop runs on to a boundary, an opening or another line; it never stops
|
|
182
|
+
mid-panel. Bundle lines and route them to the next character line (Roman Nesuko).
|
|
183
|
+
4. **Sharpness per line, creases first, support loops last.** One global bevel width is the blocky look.
|
|
184
|
+
|
|
185
|
+
| Line | Treatment |
|
|
186
|
+
|---|---|
|
|
187
|
+
| Crisp rim, lip, brow, the rim and floor of an opening | Crease 1.0 (`design_line_cage` also marks it sharp, and `sharp_edge` survives subdivision) |
|
|
188
|
+
| A short, nearly straight fold | Crease 0.3 to 0.6 |
|
|
189
|
+
| A shoulder that needs a set radius | Holding loops: a 2-segment, profile 1.0 bevel at d = r / 0.57 (`holding_corner_radius`); a smaller roll on the same part gets bevel weight r_small / r_large |
|
|
190
|
+
| A fold that curves across many stations | Shape it with the cage (the angle between the rows) or with holding loops, not a crease |
|
|
191
|
+
| Everything else | Smooth: no crease, no loop |
|
|
192
|
+
|
|
193
|
+
Two measurements on Blender 5.3.0 change the usual advice:
|
|
194
|
+
- **Creases saturate at 0.6.** Sources quote 0.6 to 0.8 for folds, but on the limit surface 0.6, 0.7 and
|
|
195
|
+
0.8 gave the same nearly crisp edge: corner sag 0.054 m on a 1 m cube, against 0.081 m at 0.5, 0.152 m
|
|
196
|
+
at 0.4, 0.238 m at 0.3 and 0.433 m uncreased, at levels 1, 2 and 3 alike. Use 0.6 for a defined fold line
|
|
197
|
+
and 0.3 to 0.5 for a soft one.
|
|
198
|
+
- **A crease on a curving line wobbles.** On a nine-station panel, crease 0.7 on a fold that bends at every
|
|
199
|
+
station put a bump in the zebra at every station, and 0.4 still did. With the crease removed and holding
|
|
200
|
+
loops on the panel's shoulder, the stripes ran clean.
|
|
201
|
+
|
|
202
|
+
Small rims (sockets, slots) take creases, not loops: Clamp Overlap is global (section 3), so a small rim with
|
|
203
|
+
loops shrinks every radius on the part.
|
|
204
|
+
5. **Poles only where it is flat.** A Catmull-Clark surface is curvature-continuous at valence-4 vertices
|
|
205
|
+
but only tangent-continuous at a pole, so a pole on a roll a highlight crosses dents it. Put valence-3 and
|
|
206
|
+
valence-5 vertices on flat crowns, behind openings or on hidden faces, a few per panel at most. Run
|
|
207
|
+
`kit.cage_audit(cage)` before subdividing: `non_quads` 0, and check every listed pole's position. Caps are
|
|
208
|
+
quad grids, never fans: `kit.loft` and `kit.curve_tube` cap with quads by default. A fan cap's pole has one
|
|
209
|
+
edge per ring point, and holding loops on its thin spokes clamped 7.0 mm loops to 5.5 mm and gave 4,640
|
|
210
|
+
triangles at level 2 on a 10-point pod cage. Put loops on a cap's rim only, never inside it.
|
|
211
|
+
6. **One continuous cage for surfaces that flow into each other.** A face, a cheek and a pod built as three
|
|
212
|
+
cages that butt together read as separate curved scoops, however smooth each is. Built as one cage per
|
|
213
|
+
side, laid out as stations × named lines, the cheek flows from the face into the pod's flank. "Make the
|
|
214
|
+
mesh as one piece as much as possible and separate it after the shape is properly formed" (Nesuko).
|
|
215
|
+
Separate only crisp inserts (a lens, a lamp housing), sunk 1 to 2 mm. Avoid cage builders that skin a
|
|
216
|
+
parameter box: they put a pole on every box corner and force rows to run round the whole part, where a
|
|
217
|
+
stations × lines grid lets rows end on openings.
|
|
218
|
+
7. **Openings are quad rings in the cage, made before subdividing.** Inset the faces inside the outline
|
|
219
|
+
(`bmesh.ops.inset_region`, 5 to 8 mm) to make a support ring, delete or sink the inner faces, and crease
|
|
220
|
+
the rim and floor 1.0. Use `use_even_offset=False` on tapered openings: an even-offset inset threw a spike
|
|
221
|
+
through the skin at an acute corner. Never cut the subdivided panel; a late seam goes on the applied skin,
|
|
222
|
+
with `panels.transfer_normals` from an uncut twin.
|
|
223
|
+
8. **Hit the traced outlines on the limit surface.** Subdivision shrinks convex cages (a pod cage came out
|
|
224
|
+
9 % low before correction).
|
|
225
|
+
- Catmull-Clark is affine invariant: an affine map of the cage maps the limit surface by the same map. So
|
|
226
|
+
measure the subdivided extents, solve a scale and offset per axis that puts them on the reference's
|
|
227
|
+
extents, and apply that to the cage. It is exact in one step.
|
|
228
|
+
- For traced outlines, use per-station ring scaling: `subdivision_cage(shrink_targets=...)` solves every
|
|
229
|
+
station together and normally converges in one round. Give whole widths on a mirrored part, never half
|
|
230
|
+
widths.
|
|
231
|
+
- For a silhouette, map each silhouette cage vertex to its limit point and slide it by target minus limit
|
|
232
|
+
along the view direction only; repeat 3 to 5 times.
|
|
233
|
+
- Correct after the creases are set: crisp lines shrink far less than rolls.
|
|
234
|
+
9. **Thin aero parts are sections, not subdivided slabs** (`vehicles.md` section 4).
|
|
235
|
+
|
|
236
|
+
### Game finishing
|
|
237
|
+
|
|
238
|
+
- **Judge at subdivision level 2, and ship level 2** on rolled panels. The chord error across a 12 mm roll is
|
|
239
|
+
about 0.9 mm at level 1 and 0.23 mm at level 2. Level 1 is acceptable only when its zebra shows no kinks at
|
|
240
|
+
play size.
|
|
241
|
+
- **Apply, then dissolve the flat zones only**: `bmesh.ops.dissolve_limit(angle_limit=math.radians(0.5),
|
|
242
|
+
delimit={'SHARP', 'MATERIAL', 'SEAM'})` on the faces of socket floors, bulkheads and flat faces, never on a
|
|
243
|
+
rolled panel.
|
|
244
|
+
- **Remove hidden faces**: the back of a panel resting on another part, an underside the camera never sees.
|
|
245
|
+
On a pod and nose prototype they were the biggest saving found, an estimated 1,200 of 10,500 triangles.
|
|
246
|
+
- **Triangulate with Keep Normals** (Beauty), and export the normals: FBX with Unity Normals = Import, glTF
|
|
247
|
+
with `NORMAL` present.
|
|
248
|
+
- **No weighted normals on rounded panels** (section 5): "there is no need for weighted normals, it keeps the
|
|
249
|
+
original shape of the model" (Filipp Sparak). Sharp edges only on the crisp lines.
|
|
250
|
+
- **Density by faces per circle diameter**, as studios optimise a subdivision body for games: a roll needs
|
|
251
|
+
about six spans per circle (OpenSubdiv), and the sagitta rule (§8.4d) gives the segments for its radius at
|
|
252
|
+
the closest game view. Spend the triangles on the rolls; flat zones get almost none.
|
|
253
|
+
|
|
254
|
+
### Checks
|
|
255
|
+
|
|
256
|
+
- **Zebra in both directions** before applying (recipe step 4): Workbench with Blender's bundled
|
|
257
|
+
`check_reflection_horizontal.exr` and `check_reflection_vertical.exr` matcaps works in `--background`. Read
|
|
258
|
+
the stripes at every junction (Rhino's zebra rules): stripes that jump sideways mean a position break,
|
|
259
|
+
stripes that line up but turn sharply mean a tangent break, and stripes that continue smoothly mean
|
|
260
|
+
curvature continuity. Kinks are allowed only on the crisp lines; bunching or waving mid-panel means uneven
|
|
261
|
+
spacing or a pole on a roll. Render at 1600 px or more: finer stripes alias into false waves. If it fails,
|
|
262
|
+
edit the cage only and run it again.
|
|
263
|
+
- **Lit clay**: `review-render` clay sheet. Soft light shows the form that zebra cannot.
|
|
264
|
+
- **The holding check**: `holding_check["clamped"]` false and `folds` 0.
|
|
265
|
+
- **The shading ramp at the in-game camera**: the light-to-dark ramp across each roll is at least 15 px in the
|
|
266
|
+
game's own frame. A ramp of 2 to 3 px reads as a facet however smooth the mesh is.
|
|
267
|
+
- **Stations for both size and form**: the shrink report converges and `measure-stations` shows no WRONG
|
|
268
|
+
station; ortho and play views read as one sculpted surface.
|
|
269
|
+
|
|
270
|
+
### Pitfalls
|
|
271
|
+
|
|
272
|
+
| Pitfall | Fix |
|
|
273
|
+
|---|---|
|
|
274
|
+
| A fan cap on a cage | Quad caps (`cap_style="quad"`, the default) |
|
|
275
|
+
| A cage with no design lines (a blob), or only design lines (a block) | Every line gets a sharpness |
|
|
276
|
+
| One holding-loop width for every roll | Bevel weight per line; creases for small rims |
|
|
277
|
+
| Creases written on the cage but ignored | `subdivision_cage` honours every `crease_edge` above 0 and reports `creased_edges` |
|
|
278
|
+
| Fairing across a crisp line rounds it away | Fair along lines only; `design_line_cage` leaves crease-1.0 lines as traced |
|
|
279
|
+
| Cutting before the zebra passes bakes the waves in | Zebra on the uncut skin first, then cut |
|
|
280
|
+
| Mirror after subdivision leaves a crease at the centre line | Mirror first in the stack, with clipping |
|
|
281
|
+
| Weighted normals on a rolled panel turn it back into facets | None on rolled panels |
|
|
282
|
+
| Bevel or Solidify outward on a thin part adds bulk | Sections at absolute thickness, edges rounded inward |
|
|
283
|
+
| Knife-thin edges and bevels under 2 px alias and sparkle | A 2 to 3 mm trailing edge; bevels of at least 2 px in the game |
|
|
284
|
+
| Stripes finer than about 4 px alias into false waves | Render the zebra at 1600 px or more, or frame tighter |
|
|
285
|
+
| Shrink targets on a mirrored part given as half widths | Whole widths |
|
|
286
|
+
| A weld before export merges the mirror seam's split normals | `kit.weld(keep_normals=True)` |
|
|
287
|
+
|
|
288
|
+
### Recipe: a rolled panel from design lines, checked by zebra
|
|
289
|
+
|
|
290
|
+
```python
|
|
291
|
+
"""Rounded surfacing: half a nose panel traced as named design lines, skinned as a sparse quad cage with a
|
|
292
|
+
sharpness per line, audited, mirrored, subdivided twice with its stations corrected, zebra-checked in two
|
|
293
|
+
directions, then applied and shaded for the game. Saves nose_panel.blend and two zebra renders."""
|
|
294
|
+
import json
|
|
295
|
+
import os
|
|
296
|
+
import sys
|
|
297
|
+
|
|
298
|
+
import bpy
|
|
299
|
+
import numpy as np
|
|
300
|
+
from mathutils import Vector
|
|
301
|
+
|
|
302
|
+
import construction_kit as kit
|
|
303
|
+
|
|
304
|
+
out_folder = sys.argv[sys.argv.index("--") + 1]
|
|
305
|
+
SHOULDER_RADIUS = 0.008 # the reference rolls the outer shoulder over 8 mm
|
|
306
|
+
ZEBRA_PIXELS = (1600, 1000) # stripes finer than about 4 px alias into false waves
|
|
307
|
+
CAMERA = (0.55, -0.75, 0.45)
|
|
308
|
+
LOOK_AT = (0.0, -0.05, 0.05)
|
|
309
|
+
|
|
310
|
+
kit.clear_default_scene()
|
|
311
|
+
# 1. Lines first. Stations run front (-Y) to rear, one at every change of the traced outlines; each line is
|
|
312
|
+
# traced as a share of the plan half-width (top view) and of the crown height (side view).
|
|
313
|
+
stations = np.linspace(-0.30, 0.20, 9)
|
|
314
|
+
bulge = np.sin(np.pi * (stations + 0.36) / 0.62)
|
|
315
|
+
half_width = 0.06 + 0.06 * bulge
|
|
316
|
+
crown_height = 0.05 + 0.06 * bulge
|
|
317
|
+
shares = {"centre": (0.00, 1.00), # the mirror seam
|
|
318
|
+
"crown": (0.40, 0.97), # the highlight crest
|
|
319
|
+
"fold": (0.72, 0.86), # the top turns into the flank: shaped by the cage, no crease
|
|
320
|
+
"shoulder": (0.95, 0.58), # the rolled outer shoulder: a set radius
|
|
321
|
+
"flank": (1.00, 0.28),
|
|
322
|
+
"foot": (0.97, 0.00)} # open edge resting on the part below
|
|
323
|
+
lines = {name: np.column_stack((half_width * across, stations, crown_height * up))
|
|
324
|
+
for name, (across, up) in shares.items()}
|
|
325
|
+
|
|
326
|
+
# 2. The skin: one quad row between neighbouring lines and a sharpness per line; soft lines are faired.
|
|
327
|
+
panel, groups = kit.design_line_cage(
|
|
328
|
+
"NosePanel", lines, row_names=["lip"] + [f"station_{index}" for index in range(1, len(stations))],
|
|
329
|
+
creases={"lip": 1.0}, # the crisp front lip
|
|
330
|
+
holding={"shoulder": 1.0}, # holding loops sized from the measured radius
|
|
331
|
+
fair_passes=1)
|
|
332
|
+
audit = groups["audit"] # before subdividing: all quads, no pole on a roll
|
|
333
|
+
assert audit["non_quads"] == 0 and not audit["poles"] and audit["max_edge_ratio"] < 1.5, audit
|
|
334
|
+
|
|
335
|
+
# 3. Mirror first, then loops, creases and subdivision; the stations are corrected on the limit surface
|
|
336
|
+
# (the targets are whole mirrored widths, never half widths).
|
|
337
|
+
kit.mirror(panel, "X")
|
|
338
|
+
report = kit.subdivision_cage(panel, levels=2, holding_corner_radius=SHOULDER_RADIUS,
|
|
339
|
+
shrink_targets=[{"position": float(y), "width": 2.0 * float(w), "height": float(h)}
|
|
340
|
+
for y, w, h in zip(stations[1:-1], half_width[1:-1], crown_height[1:-1])])
|
|
341
|
+
assert not report["holding_check"]["clamped"] and report["shrink"]["converged"], report
|
|
342
|
+
|
|
343
|
+
|
|
344
|
+
# 4. Zebra in both directions: Workbench with Blender's bundled stripe matcaps. Stripes must run on smoothly
|
|
345
|
+
# across every rolled panel and may kink only on the crisp lines.
|
|
346
|
+
def zebra_render(direction, path):
|
|
347
|
+
"""Renders the scene with the check_reflection_<direction>.exr matcap; returns the stripe contrast."""
|
|
348
|
+
scene = bpy.context.scene
|
|
349
|
+
scene.render.engine = "BLENDER_WORKBENCH"
|
|
350
|
+
scene.render.resolution_x, scene.render.resolution_y = ZEBRA_PIXELS
|
|
351
|
+
scene.display.shading.light = "MATCAP"
|
|
352
|
+
scene.display.shading.studio_light = f"check_reflection_{direction}.exr"
|
|
353
|
+
scene.display.shading.color_type = "SINGLE"
|
|
354
|
+
scene.view_settings.view_transform = "Standard"
|
|
355
|
+
if scene.camera is None:
|
|
356
|
+
camera = bpy.data.objects.new("ZebraCamera", bpy.data.cameras.new("ZebraCamera"))
|
|
357
|
+
scene.collection.objects.link(camera)
|
|
358
|
+
camera.location = CAMERA
|
|
359
|
+
camera.rotation_euler = (Vector(LOOK_AT) - camera.location).to_track_quat("-Z", "Y").to_euler()
|
|
360
|
+
scene.camera = camera
|
|
361
|
+
scene.render.filepath = path
|
|
362
|
+
bpy.ops.render.render(write_still=True)
|
|
363
|
+
red = np.array(bpy.data.images.load(path).pixels[:]).reshape(-1, 4)[:, 0]
|
|
364
|
+
return round(float(red.std()), 3)
|
|
365
|
+
|
|
366
|
+
|
|
367
|
+
zebra = {direction: zebra_render(direction, os.path.join(out_folder, f"zebra_{direction}.png"))
|
|
368
|
+
for direction in ("horizontal", "vertical")}
|
|
369
|
+
|
|
370
|
+
# 5. Game finishing: apply level 2, smooth shading with only the crisp lines sharp (sharp_edge survives the
|
|
371
|
+
# subdivision), and no weighted normals on the rolled panel.
|
|
372
|
+
kit.apply_modifiers(panel)
|
|
373
|
+
sharp = panel.data.attributes["sharp_edge"].data
|
|
374
|
+
shading = kit.shade_smooth(panel, design_line_edges=[index for index, item in enumerate(sharp) if item.value])
|
|
375
|
+
panel.data.calc_loop_triangles()
|
|
376
|
+
bpy.ops.wm.save_as_mainfile(filepath=os.path.join(out_folder, "nose_panel.blend"))
|
|
377
|
+
print(json.dumps({"cage_quads": audit["faces"], "poles": len(audit["poles"]), "max_edge_ratio": audit["max_edge_ratio"],
|
|
378
|
+
"creased_edges": report["creased_edges"], "loop_width_m": report["holding_check"]["effective_loop_width"],
|
|
379
|
+
"shrink_error_percent": report["shrink"]["final_max_error_percent"], "zebra_contrast": zebra,
|
|
380
|
+
"sharp_edges": shading["sharp_edges"], "triangles": len(panel.data.loop_triangles)}))
|
|
381
|
+
```
|
|
382
|
+
|
|
383
|
+
The cage is 40 quads with no pole and an edge ratio of 1.25; the stations converge to under 0.01 %, the
|
|
384
|
+
loops keep their full 14 mm width, and both zebra renders show stripes running on across the panel and
|
|
385
|
+
bunching only over the shoulder roll.
|
|
386
|
+
|
|
387
|
+
---
|
|
388
|
+
|
|
389
|
+
## 4. Booleans that stay clean
|
|
390
|
+
|
|
391
|
+
A boolean is an intermediate step, never the finished topology. The route decides what happens after it.
|
|
392
|
+
|
|
393
|
+
| Route | After the boolean | Never |
|
|
394
|
+
|---|---|---|
|
|
395
|
+
| Mid-poly | Merge coplanar slivers (`dissolve_limit` about 1 degree). Bevel the rim edges with 2 to 3 segments, hardened normals and face strength. Weighted normals on the flats only. N-gons on flat faces are fine. | Subdivide it |
|
|
396
|
+
| Subdivision | Cut only into a cage whose segment count matches the cutter (see the table in section 3). Merge the stray vertices into the cut's loops, add the support ring, then holding loops. Better still, skip the boolean: `inset_recess` and `round_hole` build the same cut on clean quads. | Subdivide raw boolean n-gons and triangles |
|
|
397
|
+
| High-to-low | Booleans live on the high poly only (with bevels after them, so the bevel follows the cut), then bake | Cut the low poly to match every high-poly detail |
|
|
398
|
+
|
|
399
|
+
**Mechanics** (`panels.boolean_cut`):
|
|
400
|
+
- All cutters go in **one** boolean (a collection operand). A chain of booleans leaves slivers between cuts.
|
|
401
|
+
- The volume must go down; the helper raises if it does not. MANIFOLD fails silently on a flipped face, so the
|
|
402
|
+
helper recalculates cutter normals and checks the volume whatever the solver.
|
|
403
|
+
- The rim is found **by material**. Each cutter carries a second material into the cut (`material_mode =
|
|
404
|
+
'TRANSFER'`), and the edges between target faces and cutter faces are the rim. The cutter faces then get the
|
|
405
|
+
target material back.
|
|
406
|
+
- The **bevel goes after the boolean** in the stack, so it follows the new edges.
|
|
407
|
+
|
|
408
|
+
**Cut a rounded surface without wrecking its shading** with `panels.transfer_normals`. Keep an uncut copy,
|
|
409
|
+
cut the original, then copy the custom normals from the copy (Data Transfer: face-corner custom normals,
|
|
410
|
+
nearest corner and best matching face normal). The surface around the cut keeps shading as if it were whole.
|
|
411
|
+
|
|
412
|
+
### Recipe: a mid-poly housing with boolean ports, and a cut dome with transferred normals
|
|
413
|
+
|
|
414
|
+
```python
|
|
415
|
+
"""Mid-poly route: one boolean through a housing, rims found and bevelled with hardened normals, face-area
|
|
416
|
+
weighted normals on the flats; then a dome cut and re-shaded from its uncut twin. Saves housing.blend."""
|
|
417
|
+
import json
|
|
418
|
+
import math
|
|
419
|
+
import os
|
|
420
|
+
import sys
|
|
421
|
+
|
|
422
|
+
import bmesh
|
|
423
|
+
import bpy
|
|
424
|
+
from mathutils import Matrix
|
|
425
|
+
|
|
426
|
+
import construction_kit as kit
|
|
427
|
+
import hard_surface_panels as panels
|
|
428
|
+
|
|
429
|
+
out_folder = sys.argv[sys.argv.index("--") + 1]
|
|
430
|
+
kit.clear_default_scene()
|
|
431
|
+
|
|
432
|
+
|
|
433
|
+
def mesh_object(name, edit_mesh, location):
|
|
434
|
+
"""Writes a bmesh into a new object at `location` and frees the bmesh."""
|
|
435
|
+
mesh = bpy.data.meshes.new(name)
|
|
436
|
+
edit_mesh.to_mesh(mesh)
|
|
437
|
+
edit_mesh.free()
|
|
438
|
+
obj = bpy.data.objects.new(name, mesh)
|
|
439
|
+
obj.location = location
|
|
440
|
+
bpy.context.scene.collection.objects.link(obj)
|
|
441
|
+
return obj
|
|
442
|
+
|
|
443
|
+
|
|
444
|
+
def port_cutter(name, radius, length, location):
|
|
445
|
+
"""A closed 16-sided cylinder lying along X: a cutter for a port through the housing's sides."""
|
|
446
|
+
edit_mesh = bmesh.new()
|
|
447
|
+
bmesh.ops.create_cone(edit_mesh, cap_ends=True, segments=16, radius1=radius, radius2=radius, depth=length,
|
|
448
|
+
matrix=Matrix.Rotation(math.pi / 2.0, 4, "Y"))
|
|
449
|
+
return mesh_object(name, edit_mesh, location)
|
|
450
|
+
|
|
451
|
+
|
|
452
|
+
def closed_box(name, size, location):
|
|
453
|
+
"""A closed box of the given (x, y, z) size: the housing, or a cutter."""
|
|
454
|
+
edit_mesh = bmesh.new()
|
|
455
|
+
bmesh.ops.create_cube(edit_mesh, size=1.0)
|
|
456
|
+
bmesh.ops.scale(edit_mesh, verts=edit_mesh.verts[:], vec=size)
|
|
457
|
+
return mesh_object(name, edit_mesh, location)
|
|
458
|
+
|
|
459
|
+
|
|
460
|
+
# A faceted housing (rolled corners would make it a cage job) with two ports cut in ONE boolean.
|
|
461
|
+
housing = closed_box("Housing", (0.30, 0.40, 0.20), (0.0, 0.0, 0.10))
|
|
462
|
+
ports = [port_cutter(f"Port_{index}", 0.035, 0.5, (0.0, y, 0.10)) for index, y in enumerate((-0.09, 0.09))]
|
|
463
|
+
bpy.context.view_layer.update()
|
|
464
|
+
cut = panels.boolean_cut(housing, ports) # volume-checked, rim edges found by material
|
|
465
|
+
panels.mid_poly_finish(housing, bevel_width=0.003, segments=2) # one bevel width for the whole asset
|
|
466
|
+
kit.apply_modifiers(housing)
|
|
467
|
+
|
|
468
|
+
# A rounded dome cut by a slot, re-shaded from its uncut twin so the shading flows around the slot.
|
|
469
|
+
sphere = bmesh.new()
|
|
470
|
+
bmesh.ops.create_uvsphere(sphere, u_segments=32, v_segments=16, radius=0.15)
|
|
471
|
+
dome = mesh_object("Dome", sphere, (0.6, 0.0, 0.15))
|
|
472
|
+
dome.data.materials.append(bpy.data.materials.new("Dome_Paint"))
|
|
473
|
+
dome.data.polygons.foreach_set("use_smooth", [True] * len(dome.data.polygons))
|
|
474
|
+
twin = dome.copy()
|
|
475
|
+
twin.data = dome.data.copy()
|
|
476
|
+
twin.name = "_DomeUncut"
|
|
477
|
+
bpy.context.scene.collection.objects.link(twin)
|
|
478
|
+
slot = closed_box("Slot", (0.12, 0.06, 0.03), (0.6, -0.15, 0.15))
|
|
479
|
+
bpy.context.view_layer.update()
|
|
480
|
+
dome_cut = panels.boolean_cut(dome, [slot])
|
|
481
|
+
panels.transfer_normals(dome, twin)
|
|
482
|
+
bpy.data.objects.remove(twin)
|
|
483
|
+
|
|
484
|
+
for part in (housing, dome):
|
|
485
|
+
kit.smart_unwrap(part)
|
|
486
|
+
bpy.ops.wm.save_as_mainfile(filepath=os.path.join(out_folder, "housing.blend"))
|
|
487
|
+
print(json.dumps({"housing_rim_edges": len(cut["rim_edges"]), "housing_volume": [cut["volume_before"], cut["volume_after"]],
|
|
488
|
+
"dome_rim_edges": len(dome_cut["rim_edges"]), "dome_custom_normals": dome.data.has_custom_normals}))
|
|
489
|
+
```
|
|
490
|
+
|
|
491
|
+
---
|
|
492
|
+
|
|
493
|
+
## 5. Edges and normals: bevels, weighted normals, hardened normals
|
|
494
|
+
|
|
495
|
+
| Situation | Use | Settings | Why |
|
|
496
|
+
|---|---|---|---|
|
|
497
|
+
| Flat panels meeting at hard edges, seen up close | Geometric bevel + **face-area weighted normals** | Bevel: limit ANGLE 30 degrees or WEIGHT, 2 to 3 segments, harden normals, face strength *Affected*, outer miter Arc, clamp overlap. Then Weighted Normal: FACE_AREA, weight 50, keep sharp, face influence. | The big faces dominate each vertex normal, so they shade flat and the gradient lives inside the bevel. This allows low-segment bevels. |
|
|
498
|
+
| A rolled shoulder or any curved surface | **No** weighted normals. Smooth shading, real segments sized by the sagitta (§8.4d), or a subdivision cage | Smooth faces; sharp only on design lines | There is no flat face to dominate, so FWN turns every facet into a flat-lit plane |
|
|
499
|
+
| A part with both | FWN limited to the flat panels | `flat_vertex_group` in `mid_poly_finish`, or Corner Angle mode | Keeps the roll smooth and the panels flat |
|
|
500
|
+
| The engine ignores custom normals (some FBX paths, old viewers) | More bevel segments (about 4) | Watch for long thin triangles | Shading must come from geometry alone |
|
|
501
|
+
| Far-seen or tiny parts | Nothing, or one hard edge | — | Bevels under about 1 to 2 pixels alias and flicker on shiny materials |
|
|
502
|
+
|
|
503
|
+
**Rules that hold across the asset:**
|
|
504
|
+
- **One absolute bevel width per asset or kit**, not a fraction, so small and large parts get the same
|
|
505
|
+
highlight. As a start, 0.5 to 2 % of the part's size (§8.4d). A rolled form is sized from its measured
|
|
506
|
+
radius instead.
|
|
507
|
+
- **The stack order is Mirror, Boolean, Bevel, Weighted Normal, Triangulate.** Triangulate only for the bake
|
|
508
|
+
or export copy, with keep custom normals on. Bake and export the same triangulation, or the normal map
|
|
509
|
+
shows X-shaped smoothing errors.
|
|
510
|
+
- **Hard edge = UV seam on anything baked.** A hard edge inside a UV island gives a baked seam artefact. A UV
|
|
511
|
+
seam already splits the vertex, so the hard edge costs nothing there.
|
|
512
|
+
- **Smooth by angle at about 30 degrees on a coarse faceted mesh** splits every facet hard. Use it only on
|
|
513
|
+
genuinely faceted parts with enough segments.
|
|
514
|
+
- **Re-check the shading after decimation or welding** (`kit.weld` keeps split normals).
|
|
515
|
+
- **Don't over-bevel.** Bevelling every edge with 3 segments took one prop from about 3.5k to about 11k faces.
|
|
516
|
+
|
|
517
|
+
---
|
|
518
|
+
|
|
519
|
+
## 6. Panel lines, seams, trims and decals
|
|
520
|
+
|
|
521
|
+
### Panel lines and seams: geometry or texture?
|
|
522
|
+
|
|
523
|
+
The width a groove covers on screen decides it. Pixels per metre at distance d, with vertical field of view f
|
|
524
|
+
on a screen H pixels tall, is H / (2 d tan(f / 2)).
|
|
525
|
+
|
|
526
|
+
| On-screen width of the gap | Technique |
|
|
527
|
+
|---|---|
|
|
528
|
+
| 3 px or more, at the closest common view | **Geometry**: `panel_groove` (V groove from two insets) or an inset-and-extrude step, with holding loops on the lips if subdivided |
|
|
529
|
+
| 1 to 3 px | **Normal map** from a trim strip or a bake. The silhouette does not change, and the lighting carries the line |
|
|
530
|
+
| Under 1 px | **Texture only** (a dark line in base colour or AO), or nothing |
|
|
531
|
+
| Labels, warning stripes, vents, bolts, scuffs | **Mesh decals** from a decal atlas, floating just above the surface |
|
|
532
|
+
|
|
533
|
+
Example: at 1080 px, 60 degrees and 5 m, the density is 1080 / (2 x 5 x 0.577) = 187 px/m. A 6 mm gap is then
|
|
534
|
+
1.1 px wide, so it goes into the normal map. Wider gaps read as heavy armour plates; narrow ones as sheet
|
|
535
|
+
metal.
|
|
536
|
+
|
|
537
|
+
### Trim sheets
|
|
538
|
+
|
|
539
|
+
A trim sheet is one texture of horizontal strips, each tiling along U only: bevelled edges, seams, bolt rows,
|
|
540
|
+
rubber seals, vents. One trim material can serve a whole kit, and texel density stays constant.
|
|
541
|
+
|
|
542
|
+
| Decision | Professional practice |
|
|
543
|
+
|---|---|
|
|
544
|
+
| Layout | Horizontal strips. Heights in powers of two (16, 32, 64, 128, 256 px on a 1024 sheet), roughly doubling, with a miscellaneous row at the bottom. Strips that share grid lines let you swap materials (metal for wood) without touching UVs. |
|
|
545
|
+
| Padding | Keep a few pixels between strips (`trim_strips(padding_pixels=4)`) so mip levels do not bleed one strip into the next. Snapping UVs exactly to the pixel grid can still bleed. |
|
|
546
|
+
| Mapping | Model the bevel or edge as a quad row. V spans the strip exactly, and U runs along at the kit's texel density, so it may pass 1 (`map_quad_strip`). Straighten borders so the bevel width stays constant. |
|
|
547
|
+
| "45-degree bevel" strips | A normal map of a 45-degree bevel only works on 90-degree corners with hard-edge shading. Do not put a bevel trim on an edge that is already bevelled in geometry: the shading doubles. |
|
|
548
|
+
| Large areas | Pair the trim with a tiling material, and don't over-trim. |
|
|
549
|
+
| Density | Keep strips within about ±25 % of the kit's texel density. |
|
|
550
|
+
|
|
551
|
+
### Mesh decals
|
|
552
|
+
|
|
553
|
+
A decal is a separate quad, or a strip with feathered edges, hugging the surface and lifted along its normal
|
|
554
|
+
(`mesh_decal`). It never cuts topology.
|
|
555
|
+
- **Lift it** just enough that it never z-fights at the far end of the camera range. Depth precision falls
|
|
556
|
+
with distance. 1 to 2 mm holds for props seen within about 20 m with a 0.1 m near plane. Too much lift and
|
|
557
|
+
the decal visibly floats and "swims". Check it in the game camera.
|
|
558
|
+
- Decals cast no shadow and have no sort order of their own. They also misalign across LOD changes, so drop
|
|
559
|
+
them from the lower LODs.
|
|
560
|
+
- **On the web, a decal is a draw.** Put all of an asset's decals in one decal atlas material and merge them
|
|
561
|
+
into one mesh per asset. That costs one draw per asset, not one per decal. BabylonJS renders forward, so
|
|
562
|
+
deferred-only decal techniques do not apply; use trims, bakes and mesh decals.
|
|
563
|
+
- Run qa-check with `--allow-floating <decal names>`. Decals float by design.
|
|
564
|
+
|
|
565
|
+
### Recipe: trim strips on a rail and a decal on a housing
|
|
566
|
+
|
|
567
|
+
```python
|
|
568
|
+
"""Trim sheet mapping: strips laid out on a 1024 sheet, one quad row of a rail mapped onto a strip at
|
|
569
|
+
512 px/m, and a mesh decal lifted 1.5 mm off a housing face. Saves trims.blend."""
|
|
570
|
+
import json
|
|
571
|
+
import os
|
|
572
|
+
import sys
|
|
573
|
+
|
|
574
|
+
import bpy
|
|
575
|
+
|
|
576
|
+
import construction_kit as kit
|
|
577
|
+
import hard_surface_trims as trims
|
|
578
|
+
|
|
579
|
+
out_folder = sys.argv[sys.argv.index("--") + 1]
|
|
580
|
+
TEXEL_DENSITY = 512.0 # the kit's density, px/m
|
|
581
|
+
TRIM_PIXELS = 1024
|
|
582
|
+
|
|
583
|
+
kit.clear_default_scene()
|
|
584
|
+
strips = trims.trim_strips([32, 64, 128, 256], texture_pixels=TRIM_PIXELS, padding_pixels=4)
|
|
585
|
+
|
|
586
|
+
rail = kit.loft("Rail", [(y, kit.rounded_section(0.20, 0.10, 0.02, 0.02, segments=2)) for y in (0.0, 0.5, 1.0)])
|
|
587
|
+
kit.smart_unwrap(rail)
|
|
588
|
+
side_row = [polygon.index for polygon in rail.data.polygons if polygon.normal.x > 0.99] # one quad row, end to end
|
|
589
|
+
mapped = trims.map_quad_strip(rail, side_row, strips[1], pixels_per_metre=TEXEL_DENSITY, texture_pixels=TRIM_PIXELS)
|
|
590
|
+
|
|
591
|
+
rail.data.materials.append(bpy.data.materials.new("Kit_Trim")) # the one trim material of the kit
|
|
592
|
+
|
|
593
|
+
housing = kit.loft("Housing", [(y, kit.rounded_section(0.30, 0.20, 0.03, 0.03, segments=3)) for y in (-0.2, 0.2)])
|
|
594
|
+
housing.location = (0.6, 0.0, 0.0)
|
|
595
|
+
housing.data.materials.append(bpy.data.materials.new("Housing_Paint"))
|
|
596
|
+
kit.smart_unwrap(housing)
|
|
597
|
+
bpy.context.view_layer.update()
|
|
598
|
+
top_face = max(housing.data.polygons, key=lambda polygon: polygon.normal.z * polygon.area).index
|
|
599
|
+
decal = trims.mesh_decal("Decal_Label", housing, top_face, 0.12, 0.05, offset=0.0015, uv_rect=(0.0, 0.75, 0.25, 1.0),
|
|
600
|
+
material=bpy.data.materials.new("Kit_Decals")) # one atlas for every decal
|
|
601
|
+
|
|
602
|
+
bpy.ops.wm.save_as_mainfile(filepath=os.path.join(out_folder, "trims.blend"))
|
|
603
|
+
print(json.dumps({"strips": strips, "mapped": mapped,
|
|
604
|
+
"decal_lift_m": round(min(vertex.co.z for vertex in decal.data.vertices) - 0.20, 5)}))
|
|
605
|
+
```
|
|
606
|
+
|
|
607
|
+
---
|
|
608
|
+
|
|
609
|
+
## 7. Lessons from production reviews
|
|
610
|
+
|
|
611
|
+
These come from a hard-surface vehicle part judged against locked reference views over many review rounds.
|
|
612
|
+
They apply to any manufactured asset.
|
|
613
|
+
|
|
614
|
+
| Symptom in review | Real cause | Fix |
|
|
615
|
+
|---|---|---|
|
|
616
|
+
| "Blocky" although every station is MATCH | Rolled form built as facets: too few section vertices, FWN on curves, smooth-by-angle splitting the facets | Measure the corner radius, rebuild as a rounded loft or a cage with loops sized from it |
|
|
617
|
+
| Soft, crumpled facets on a faceted part | Non-planar quads triangulated arbitrarily; on the mirrored side the diagonal flips | Planar strips, deliberate triangulation along the creases |
|
|
618
|
+
| A crisp housing set into a rounded panel pinches the panel | The housing was cut into the panel's topology | A separate insert, sunk 1 to 2 mm, with its own crisp rim |
|
|
619
|
+
| A recess reads flat, with no depth | Same material and value as the face around it; a shallow socket | Deeper socket (several times the feature's height), a darker material inside, a brow that overhangs and catches a 2 mm bevel highlight |
|
|
620
|
+
| A highlight-width target cannot be reached | The game's lighting, not the geometry: a test at 1.5x the reference radius still lit the same narrow band | Prove the geometry by its section radius, record the check as lighting-limited, and don't keep inflating the radius |
|
|
621
|
+
| Parts bolted on to fix a failing silhouette ("primitive soup") | The underlying mass was the wrong size | Re-measure the stations and fix the mass; no new primitives after the blockout |
|
|
622
|
+
|
|
623
|
+
---
|
|
624
|
+
|
|
625
|
+
## 8. Budgets (web and BabylonJS first)
|
|
626
|
+
|
|
627
|
+
The figures marked *starting point* are working defaults, not studio-published numbers. Adjust them to the
|
|
628
|
+
asset's pixel height in the game.
|
|
629
|
+
|
|
630
|
+
| Item | Web / mobile | Desktop | Source or reason |
|
|
631
|
+
|---|---|---|---|
|
|
632
|
+
| Small prop (crate, lamp, valve) | 300-1,500 tris | 1-5k | *Starting point*; Arm's mobile demo ran 360-tri units and 3k-tri towers |
|
|
633
|
+
| Hero prop / large machine | 5-15k | 15-40k | *Starting point*; Arm's 11k-tri hero robot was alone on screen |
|
|
634
|
+
| Whole asset per glTF file (commerce guideline) | ≤ 150k tris, < 20 draws, 2K textures | ≤ 250k, < 100 draws | Khronos 3D Commerce publishing targets (per item, not per scene) |
|
|
635
|
+
| Triangle size | Keep triangles above about 10 px in area at play size | same | Arm: 1-10 px micro-triangles waste the GPU |
|
|
636
|
+
| Vertices per mesh | < 65,535 for 16-bit indices | same | Arm |
|
|
637
|
+
| Materials per asset | 1-2 (one atlas or trim material, plus glass or decal) | 2-4 | Each material is a draw per mesh per pass |
|
|
638
|
+
| Texel density | 256-512 px/m | 512-1024 px/m (first person 1024) | Maxon presets 2.56 / 5.12 / 10.24 px/cm; CryEngine aims at 512 px/m |
|
|
639
|
+
| Bevel | One absolute width per asset; 1-2 segments far, 2-3 near | 3-4 for visible rounds | Section 5 |
|
|
640
|
+
|
|
641
|
+
---
|
|
642
|
+
|
|
643
|
+
## 9. Verification checklist
|
|
644
|
+
|
|
645
|
+
```bash
|
|
646
|
+
node <skill>/scripts/bt-blender.mjs measure-stations --spec refs/spec.json --model asset.blend # sizes, corner radii, shading continuity
|
|
647
|
+
node <skill>/scripts/bt-blender.mjs world-gate --spec refs/spec.json --model asset.blend # IoU per view at world scale
|
|
648
|
+
node <skill>/scripts/bt-blender.mjs review-render --model asset.blend --out review --pixel-height 180
|
|
649
|
+
node <skill>/scripts/bt-blender.mjs qa-check --model asset.blend --allow-floating Decal_Label # web profile
|
|
650
|
+
node <skill>/scripts/bt-blender.mjs assembly-check --model asset.blend --spec assembly.json # inserts seated, no gaps
|
|
651
|
+
```
|
|
652
|
+
|
|
653
|
+
- [ ] The brief names each part's form language from the highlights (rolled, faceted, bevelled), with radii.
|
|
654
|
+
- [ ] The route (section 2) is written down, and the stack order is Mirror, Boolean, Bevel, Weighted Normal.
|
|
655
|
+
- [ ] The edge radii are measured on sections (`corner_radius_in_section`) and within 15 % of the reference.
|
|
656
|
+
- [ ] Rolled panels: the cage follows the named design lines, each with its sharpness; `cage_audit` shows all
|
|
657
|
+
quads and no pole on a roll; the zebra runs on in both directions, kinking only on the crisp lines.
|
|
658
|
+
- [ ] measure-stations shows no station WRONG, and the dihedral across smooth edges is under 20 degrees on the
|
|
659
|
+
rolled zones (`--max-dihedral`). Design lines only are sharp (`shade_smooth` returns the count).
|
|
660
|
+
- [ ] No weighted normals on curved surfaces. Hard edges sit on UV seams.
|
|
661
|
+
- [ ] Panel lines: geometry only where at least 3 px wide in the game; otherwise trim, normal map or texture.
|
|
662
|
+
- [ ] Decals lifted, on one atlas material, merged per asset, allowed to float in qa-check, and dropped from
|
|
663
|
+
the low LODs.
|
|
664
|
+
- [ ] qa-check passes (z-fighting, floating, normals, UVs, materials). assembly-check shows inserts seated with
|
|
665
|
+
no gaps.
|
|
666
|
+
- [ ] The review render at the in-game pixel height shows the cuts reading. Detail that doesn't read there is
|
|
667
|
+
in the texture.
|
|
668
|
+
|
|
669
|
+
---
|
|
670
|
+
|
|
671
|
+
## Sources
|
|
672
|
+
|
|
673
|
+
- Blender Manual: Weighted Normal, Bevel, Boolean and Subdivision Surface modifiers —
|
|
674
|
+
https://docs.blender.org/manual/en/latest/modeling/modifiers/normals/weighted_normal.html ,
|
|
675
|
+
https://docs.blender.org/manual/en/latest/modeling/modifiers/generate/bevel.html ,
|
|
676
|
+
https://docs.blender.org/manual/en/latest/modeling/modifiers/generate/booleans.html ,
|
|
677
|
+
https://docs.blender.org/manual/en/latest/modeling/modifiers/generate/subdivision_surface.html
|
|
678
|
+
- Pixar OpenSubdiv, "Modeling Tips" (quads, valence, spans per circle, crease sharpness) —
|
|
679
|
+
https://graphics.pixar.com/opensubdiv/docs/mod_notes.html
|
|
680
|
+
- Marmoset, "Toolbag Baking Tutorial" (hard edges and UV splits, triangulation, cages, skew) —
|
|
681
|
+
https://marmoset.co/posts/toolbag-baking-tutorial/
|
|
682
|
+
- 80.lv, Simon Péloquin, "Best Practices for Hard Surface Normal Map Baking" —
|
|
683
|
+
https://80.lv/articles/best-practices-for-hard-surface-normal-map-baking
|
|
684
|
+
- 80.lv, Malte Resenberger-Loosmann, "Creating Assets Within the Mid Poly Workflow in UE5" —
|
|
685
|
+
https://80.lv/articles/creating-assets-within-the-mid-poly-workflow-in-ue5/
|
|
686
|
+
- 80.lv, Ron Frölich, "Hard Surface Modeling Tips & Tricks" (weight-limited bevel, face strength, weighted
|
|
687
|
+
normals stack) — https://80.lv/articles/hard-surface-modeling-tips-tricks-for-creating-a-vintage-quirky-looking-gun
|
|
688
|
+
- 80.lv, Trevor Crandall, "Hard Surface Modeling Tips and Tricks" —
|
|
689
|
+
https://80.lv/articles/hard-surface-modeling-tips-and-tricks
|
|
690
|
+
- 80.lv, "James Brady: Tracker from Alien: Isolation" (face-weighted normals, second UV for unique detail) —
|
|
691
|
+
https://80.lv/articles/james-brady-tracker-from-alien-isolation
|
|
692
|
+
- GDC Vault, Morten Olsen, "The Ultimate Trim: Texturing Techniques of Sunset Overdrive" (2015) —
|
|
693
|
+
https://gdcvault.com/play/1022323/ ; layout study: https://80.lv/articles/001agt-ultimate-trim-animated-forcefield-material-study
|
|
694
|
+
- Epic Games, "Using Mesh Decals in Unreal Engine" — https://dev.epicgames.com/documentation/en-us/unreal-engine/using-mesh-decals-in-unreal-engine
|
|
695
|
+
- BeamNG documentation, "Making Edges Straight for Normal Bevels" —
|
|
696
|
+
https://documentation.beamng.com/modding/vehicle/vehicle-art/uv-unwrapping/making-edges-straight/
|
|
697
|
+
- Roblox DevForum, "Trim Textures: 3D Modeling and Unwrapping Trim Sheets" — https://devforum.roblox.com/t/3171223
|
|
698
|
+
- Blender Artists, "Bevel best practice" — https://blenderartists.org/t/bevel-best-practice/1529225
|
|
699
|
+
- Polycount forum threads on subdivision support loops and segment matching (FrankPolygon) —
|
|
700
|
+
https://polycount.com/discussion/221392/sketchbook-frank-polygon
|
|
701
|
+
- Android Developers / Arm, "Optimize geometry" — https://developer.android.com/games/optimize/geometry
|
|
702
|
+
- Khronos 3D Commerce, Realtime Asset Creation Guidelines, publishing targets —
|
|
703
|
+
https://github.com/KhronosGroup/3DC-Asset-Creation
|
|
704
|
+
- Maxon Cinema 4D Help, "Texel Density" — https://help.maxon.net/c4d/en-us/Content/html/Texel_Density.html
|
|
705
|
+
- Khronos glTF 2.0 specification (normals, tangents) — https://registry.khronos.org/glTF/specs/2.0/glTF-2.0.html
|
|
706
|
+
- Ali Ismail (Ebal Studios), "Modeling Cars in Polygons" — https://www.carbodydesign.com/article/59531-modeling-cars-in-polygons/
|
|
707
|
+
- Sunstrike Studios, "3D Car Models for Games: Modeling Workflow, Topology & PBR Guide" —
|
|
708
|
+
https://sunstrikestudios.com/en/blog/car_modeling_for_games/
|
|
709
|
+
- note, Roman Nesuko, "Car in Blender: Eunos Cosmo" — https://note.com/romannesuko/n/n9e507262bba6
|
|
710
|
+
- 80.lv, "Vehicle Production for Games" (Karol Miklas) — https://80.lv/articles/vehicle-production-for-games/
|
|
711
|
+
- BlenderNation, "Behind the Scenes: F1 Concept Car" (Volodymyr Borovkov) —
|
|
712
|
+
https://www.blendernation.com/2020/11/02/behind-the-scenes-f1-2020-car/
|
|
713
|
+
- F1 Scratchbuild blog, "F1 car design in Catia V5 III" (guide curves before lofts) —
|
|
714
|
+
http://f1scratchbuild.blogspot.com/2011/10/f1-car-design-in-catia-v5-iii.html
|
|
715
|
+
- 80.lv, "Creating a Sedan-Like 3D Car Using Unreal Engine 5" (Filipp Sparak) —
|
|
716
|
+
https://80.lv/articles/creating-a-sedan-like-3d-car-using-unreal-engine-5
|
|
717
|
+
- Rhino 8 Help, "Zebra" — https://docs.mcneel.com/rhino/8/help/en-us/commands/zebra.htm
|
|
718
|
+
- Wikipedia, "Catmull–Clark subdivision surface" (continuity at extraordinary vertices) —
|
|
719
|
+
https://en.wikipedia.org/wiki/Catmull%E2%80%93Clark_subdivision_surface
|
|
720
|
+
- Measurements marked "Blender 5.3.0" were made for this skill.
|