vibedgames 0.10.0 → 0.10.2
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/assets/rebuild-object/.cache/spec-search/core_3d.json +1 -0
- package/assets/rebuild-object/.cache/spec-search/cs2.json +1 -0
- package/assets/rebuild-object/LICENSE +201 -0
- package/assets/rebuild-object/NOTICE +7 -0
- package/assets/rebuild-object/docs/materials/material-reference.json +2324 -0
- package/assets/rebuild-object/docs/specs/render-profile.v2.example.json +63 -0
- package/assets/rebuild-object/docs/specs/render-profile.v2.schema.json +56 -0
- package/assets/rebuild-object/docs/specs/vocabulary/README.md +86 -0
- package/assets/rebuild-object/docs/specs/vocabulary/core_3d.jsonl +12 -0
- package/assets/rebuild-object/docs/specs/vocabulary/core_3d_reconstruction.jsonl +37 -0
- package/assets/rebuild-object/docs/specs/vocabulary/cs2.jsonl +8 -0
- package/assets/rebuild-object/docs/specs/vocabulary/cs2_reconstruction.jsonl +62 -0
- package/assets/rebuild-object/forge/_shared/artifact_cache.py +54 -0
- package/assets/rebuild-object/forge/_shared/chirality.py +272 -0
- package/assets/rebuild-object/forge/_shared/color_metrics.py +107 -0
- package/assets/rebuild-object/forge/_shared/feature_acceptance_policy.py +113 -0
- package/assets/rebuild-object/forge/_shared/image_hash.py +113 -0
- package/assets/rebuild-object/forge/_shared/jpeg.py +448 -0
- package/assets/rebuild-object/forge/_shared/material_physics.py +253 -0
- package/assets/rebuild-object/forge/_shared/pipeline_routing.py +177 -0
- package/assets/rebuild-object/forge/_shared/scalp_field.py +302 -0
- package/assets/rebuild-object/forge/_shared/sdf_primitives.py +172 -0
- package/assets/rebuild-object/forge/_shared/spec_search.py +1792 -0
- package/assets/rebuild-object/forge/_shared/spec_search_profiles.json +58 -0
- package/assets/rebuild-object/forge/_shared/status_banner.py +35 -0
- package/assets/rebuild-object/forge/_shared/subdivision.py +232 -0
- package/assets/rebuild-object/forge/_shared/vertex_paint.py +236 -0
- package/assets/rebuild-object/forge/_shared/workflow_state.py +406 -0
- package/assets/rebuild-object/forge/materials/__init__.py +17 -0
- package/assets/rebuild-object/forge/materials/compatibility.py +106 -0
- package/assets/rebuild-object/forge/materials/reference.py +240 -0
- package/assets/rebuild-object/forge/next.py +116 -0
- package/assets/rebuild-object/forge/report.py +38 -0
- package/assets/rebuild-object/forge/requirements.txt +6 -0
- package/assets/rebuild-object/forge/stage1_intake/analyze_texture.py +255 -0
- package/assets/rebuild-object/forge/stage1_intake/bind_detail_properties.py +99 -0
- package/assets/rebuild-object/forge/stage1_intake/build_detail_inventory.py +349 -0
- package/assets/rebuild-object/forge/stage1_intake/camera_fitting_math.py +133 -0
- package/assets/rebuild-object/forge/stage1_intake/camera_fitting_solver.py +197 -0
- package/assets/rebuild-object/forge/stage1_intake/camera_fitting_types.py +291 -0
- package/assets/rebuild-object/forge/stage1_intake/camera_image_helpers.py +133 -0
- package/assets/rebuild-object/forge/stage1_intake/check_intake_correctness.py +116 -0
- package/assets/rebuild-object/forge/stage1_intake/check_reference_admission.py +203 -0
- package/assets/rebuild-object/forge/stage1_intake/cs2_foundation.py +139 -0
- package/assets/rebuild-object/forge/stage1_intake/cs2_manifest.py +230 -0
- package/assets/rebuild-object/forge/stage1_intake/cs2_review_contract.py +42 -0
- package/assets/rebuild-object/forge/stage1_intake/delight_albedo.py +352 -0
- package/assets/rebuild-object/forge/stage1_intake/detect_cs2.py +276 -0
- package/assets/rebuild-object/forge/stage1_intake/detect_reference_effects.py +275 -0
- package/assets/rebuild-object/forge/stage1_intake/extract_cs2_textures.py +126 -0
- package/assets/rebuild-object/forge/stage1_intake/extract_gradient_stops.py +149 -0
- package/assets/rebuild-object/forge/stage1_intake/extract_hair_evidence.py +385 -0
- package/assets/rebuild-object/forge/stage1_intake/extract_landmarks.py +456 -0
- package/assets/rebuild-object/forge/stage1_intake/extract_part_color_recipe.py +496 -0
- package/assets/rebuild-object/forge/stage1_intake/extract_pbr_evidence.py +843 -0
- package/assets/rebuild-object/forge/stage1_intake/fetch_cs2_metadata.py +147 -0
- package/assets/rebuild-object/forge/stage1_intake/label_glb_nodes.py +318 -0
- package/assets/rebuild-object/forge/stage1_intake/locate_cs2_vpk.py +73 -0
- package/assets/rebuild-object/forge/stage1_intake/material_region_analysis.py +227 -0
- package/assets/rebuild-object/forge/stage1_intake/probe_glb.py +357 -0
- package/assets/rebuild-object/forge/stage1_intake/probe_image.py +168 -0
- package/assets/rebuild-object/forge/stage1_intake/run_vision_adapter.py +45 -0
- package/assets/rebuild-object/forge/stage1_intake/search_specs.py +258 -0
- package/assets/rebuild-object/forge/stage1_intake/semantic_decomposition.py +119 -0
- package/assets/rebuild-object/forge/stage1_intake/solve_camera_pose.py +254 -0
- package/assets/rebuild-object/forge/stage2_spec/apply_material_analysis.py +192 -0
- package/assets/rebuild-object/forge/stage2_spec/cs2_adapters.py +62 -0
- package/assets/rebuild-object/forge/stage2_spec/derive_geometry.py +118 -0
- package/assets/rebuild-object/forge/stage2_spec/hair_profile.py +306 -0
- package/assets/rebuild-object/forge/stage2_spec/humanoid_proportions.py +214 -0
- package/assets/rebuild-object/forge/stage2_spec/new_pre_spec_assessment.py +343 -0
- package/assets/rebuild-object/forge/stage2_spec/new_sculpt_spec.py +2396 -0
- package/assets/rebuild-object/forge/stage2_spec/validate_sculpt_spec.py +2871 -0
- package/assets/rebuild-object/forge/stage3_build/bake_projected_texture.py +181 -0
- package/assets/rebuild-object/forge/stage3_build/decimate.py +272 -0
- package/assets/rebuild-object/forge/stage3_build/generate_threejs_factory.py +4099 -0
- package/assets/rebuild-object/forge/stage3_build/module_cache.py +155 -0
- package/assets/rebuild-object/forge/stage3_build/morph_targets.py +178 -0
- package/assets/rebuild-object/forge/stage3_build/orchestrate_passes.py +653 -0
- package/assets/rebuild-object/forge/stage3_build/uv_unwrap.py +622 -0
- package/assets/rebuild-object/forge/stage3_build/visual_hull.py +357 -0
- package/assets/rebuild-object/forge/stage4_review/_fit_divine_eye.py +64 -0
- package/assets/rebuild-object/forge/stage4_review/append_review.py +453 -0
- package/assets/rebuild-object/forge/stage4_review/attachment_anchor.py +349 -0
- package/assets/rebuild-object/forge/stage4_review/calibrate_eye.py +131 -0
- package/assets/rebuild-object/forge/stage4_review/check_part_coverage.py +298 -0
- package/assets/rebuild-object/forge/stage4_review/compare_region_passes.py +169 -0
- package/assets/rebuild-object/forge/stage4_review/correction_loop.py +258 -0
- package/assets/rebuild-object/forge/stage4_review/cs2_review.py +224 -0
- package/assets/rebuild-object/forge/stage4_review/diagnose_render.py +356 -0
- package/assets/rebuild-object/forge/stage4_review/diagnose_render_multi_angle.py +143 -0
- package/assets/rebuild-object/forge/stage4_review/divine_eye.py +461 -0
- package/assets/rebuild-object/forge/stage4_review/fit_params.py +381 -0
- package/assets/rebuild-object/forge/stage4_review/geometry_integrity.py +294 -0
- package/assets/rebuild-object/forge/stage4_review/hair_gate.py +216 -0
- package/assets/rebuild-object/forge/stage4_review/interior_difference.py +188 -0
- package/assets/rebuild-object/forge/stage4_review/joint_loops.py +209 -0
- package/assets/rebuild-object/forge/stage4_review/make_comparison_sheet.py +292 -0
- package/assets/rebuild-object/forge/stage4_review/material_comparator.py +181 -0
- package/assets/rebuild-object/forge/stage4_review/material_feedback.py +143 -0
- package/assets/rebuild-object/forge/stage4_review/material_gate.py +126 -0
- package/assets/rebuild-object/forge/stage4_review/material_views.py +184 -0
- package/assets/rebuild-object/forge/stage4_review/mesh_reference_compare.py +362 -0
- package/assets/rebuild-object/forge/stage4_review/multi_pass.py +102 -0
- package/assets/rebuild-object/forge/stage4_review/objectness.py +143 -0
- package/assets/rebuild-object/forge/stage4_review/pairwise_penetration.py +376 -0
- package/assets/rebuild-object/forge/stage4_review/per_feature.py +215 -0
- package/assets/rebuild-object/forge/stage4_review/render_bridge.py +556 -0
- package/assets/rebuild-object/forge/stage4_review/scalp_exposure.py +257 -0
- package/assets/rebuild-object/forge/stage4_review/self_intersection.py +592 -0
- package/assets/rebuild-object/forge/stage4_review/swept_arc_gate.py +336 -0
- package/assets/rebuild-object/forge/stage4_review/turntable_gate.py +415 -0
- package/assets/rebuild-object/forge/stage4_review/validate_render_profile.py +182 -0
- package/assets/rebuild-object/forge/stage4_review/vertex_region_gate.py +456 -0
- package/assets/rebuild-object/forge/stage4_review/vlm_gate.py +196 -0
- package/assets/rebuild-object/forge/stage5_rig/NOTES.md +149 -0
- package/assets/rebuild-object/forge/stage5_rig/__init__.py +6 -0
- package/assets/rebuild-object/forge/stage5_rig/emit_rig.py +420 -0
- package/assets/rebuild-object/forge/stage5_rig/geodesic_skinning.py +508 -0
- package/assets/rebuild-object/forge/stage5_rig/rig_spec.py +174 -0
- package/assets/rebuild-object/forge/stage5_rig/validate_rig_payload.py +195 -0
- package/assets/rebuild-object/forge/state.py +98 -0
- package/assets/rebuild-object/steps.json +381 -0
- package/dist/{chunk-FXXVXDTW.js → chunk-24TITAFS.js} +1 -1
- package/dist/{chunk-OGX4DKIS.js → chunk-2C5PG2QO.js} +1 -1
- package/dist/{chunk-HYOXGNWS.js → chunk-2DEVOKI7.js} +1 -1
- package/dist/{chunk-RRI23NK2.js → chunk-2GHPYT2P.js} +1 -1
- package/dist/{chunk-S7HYWITX.js → chunk-2HXGMXGC.js} +1 -1
- package/dist/{chunk-N2UHAQXC.js → chunk-36FORP7T.js} +0 -1
- package/dist/{chunk-VB4WLJR2.js → chunk-3IXRQTRF.js} +1 -1
- package/dist/{chunk-2KVQJKIZ.js → chunk-4ENHS32B.js} +23 -36
- package/dist/{chunk-SXYQL4GK.js → chunk-4YHA32OE.js} +1 -1
- package/dist/{chunk-4FJXCS3K.js → chunk-4ZGQKPK5.js} +1 -1
- package/dist/{chunk-SBXCK2I2.js → chunk-6CLUPFQA.js} +2 -2
- package/dist/{chunk-TXOE5UY5.js → chunk-7WTF2BA4.js} +1 -1
- package/dist/{chunk-R2WVORGD.js → chunk-AAXZNK4Z.js} +1 -1
- package/dist/{chunk-DOOQUFPG.js → chunk-ALLBT4FB.js} +1 -1
- package/dist/{chunk-HRKVAXNN.js → chunk-BAZDPPIG.js} +5 -5
- package/dist/{chunk-RPJR3S5S.js → chunk-CYDENLZ4.js} +5 -8
- package/dist/{chunk-I5LELJSK.js → chunk-DKSUD44G.js} +1 -1
- package/dist/{chunk-43P4U7CB.js → chunk-DWWSJKTE.js} +1 -1
- package/dist/{chunk-SUSX3QIA.js → chunk-E72TFJZP.js} +1 -1
- package/dist/{chunk-E3FJUPLT.js → chunk-EUAAQMUA.js} +2 -0
- package/dist/{chunk-U6DTE5IX.js → chunk-F7LYJSZE.js} +1 -1
- package/dist/{chunk-MEAO33XW.js → chunk-FMON3C74.js} +8 -8
- package/dist/{chunk-GLEW7VJQ.js → chunk-FPILHRLZ.js} +1 -1
- package/dist/{chunk-OPUCUUID.js → chunk-G63MXDX2.js} +4 -0
- package/dist/{chunk-4UU622RK.js → chunk-GGO6ZYYI.js} +1 -3
- package/dist/{chunk-2ZKS7V72.js → chunk-GZCRYYS6.js} +5 -5
- package/dist/{chunk-E7NDOZ27.js → chunk-LE4GVTYI.js} +8 -8
- package/dist/{chunk-RKS7SI5L.js → chunk-NO6KPV64.js} +1 -1
- package/dist/{chunk-KJK5CB6E.js → chunk-NXW3Z4Y4.js} +1 -1
- package/dist/{chunk-7RPLQWR2.js → chunk-OHOAZGO4.js} +1 -1
- package/dist/chunk-PYJNI5WD.js +83 -0
- package/dist/{chunk-NCX6LYNJ.js → chunk-Q4XAGTFX.js} +1 -1
- package/dist/{chunk-3UGGMFJJ.js → chunk-QMZBSVKF.js} +1 -1
- package/dist/{chunk-ABTUEIRC.js → chunk-QO66UBOS.js} +2 -2
- package/dist/{chunk-LONQWRTR.js → chunk-S4KVGQQO.js} +8 -8
- package/dist/{chunk-HX5Q63UA.js → chunk-T777EXAO.js} +1 -1
- package/dist/{chunk-UQ7VO6B3.js → chunk-TZZNRA3S.js} +1 -1
- package/dist/{chunk-CTY2WZQK.js → chunk-UC3QLWMQ.js} +1 -1
- package/dist/{chunk-MR5KIFI7.js → chunk-UDJH2RED.js} +3 -3
- package/dist/{chunk-ZHLPE6LI.js → chunk-UIKYK7KI.js} +1 -1
- package/dist/{chunk-KAGVI3CE.js → chunk-UJRSQO2B.js} +1 -1
- package/dist/{chunk-Q2QC6KAZ.js → chunk-V7LEYVXB.js} +29 -25
- package/dist/{chunk-DB7WVFS7.js → chunk-WRMQEXUC.js} +1 -1
- package/dist/{chunk-HSMG6U7J.js → chunk-WXSBNC67.js} +3 -9
- package/dist/{chunk-QLCVLCPM.js → chunk-X4QIOXNQ.js} +1 -1
- package/dist/{chunk-5YPLKGY3.js → chunk-Y6WHUK2O.js} +1 -1
- package/dist/{chunk-VZEJ2ZHE.js → chunk-Z3E7ORGQ.js} +5 -5
- package/dist/index.js +20 -20
- package/package.json +32 -22
- package/dist/{chunk-Q3XQPNF6.js → chunk-BN7TR6OR.js} +3 -3
- package/dist/{chunk-LORGE2NB.js → chunk-U2NCN5RO.js} +3 -3
- package/dist/{chunk-UPHB5HWO.js → chunk-VQTTSPA3.js} +3 -3
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""What three.js actually does with a material value, as code rather than as a comment.
|
|
3
|
+
|
|
4
|
+
WHY THIS MODULE EXISTS. A material number can be authored, validated, emitted, rendered -- and still
|
|
5
|
+
never reach a pixel, because the engine gates it behind another value, clamps it, adds to it, or folds
|
|
6
|
+
it into a different uniform. None of that is on the docs page. All of it is in the source, and every
|
|
7
|
+
constant below cites the file:line in `three@0.169.0` it came from.
|
|
8
|
+
|
|
9
|
+
The two failure modes this prevents:
|
|
10
|
+
|
|
11
|
+
AUTHORING A VALUE THE ENGINE IGNORES. `sheen: 0.65` with three's default `sheenColor` of
|
|
12
|
+
0x000000 contributes exactly zero, because the sheen term
|
|
13
|
+
is `sheenColor * (D * V)` -- a multiply by black.
|
|
14
|
+
|
|
15
|
+
EXPOSING ONE DEGREE OF FREEDOM TWICE. `sheen` and `sheenColor` are multiplied together before
|
|
16
|
+
upload, so `sheen 1.0 / #808080` is bit-identical to
|
|
17
|
+
`sheen 0.5 / #ffffff`. Extracting both from a reference as
|
|
18
|
+
independent evidence extracts the same number twice and
|
|
19
|
+
produces priors that contradict each other on paper while
|
|
20
|
+
rendering identically.
|
|
21
|
+
|
|
22
|
+
Full derivation, with every citation: `grimoire/build/threejs_skin_and_cloth_materials.md`.
|
|
23
|
+
|
|
24
|
+
Pure Python 3.10+ standard library.
|
|
25
|
+
"""
|
|
26
|
+
from __future__ import annotations
|
|
27
|
+
|
|
28
|
+
from typing import Any, Final
|
|
29
|
+
|
|
30
|
+
# ---------------------------------------------------------------------------------------------
|
|
31
|
+
# Engine constants. Each is a measured property of three@0.169.0, not a policy choice.
|
|
32
|
+
# ---------------------------------------------------------------------------------------------
|
|
33
|
+
|
|
34
|
+
THREE_VERSION: Final = "0.169.0"
|
|
35
|
+
|
|
36
|
+
# `material.clearcoatRoughness = max( clearcoatRoughness, 0.0525 )`
|
|
37
|
+
# ShaderChunk/lights_physical_fragment.glsl.js:72
|
|
38
|
+
# Anything below this renders identically to it, so accepting a smaller number as meaningful is
|
|
39
|
+
# accepting a value the engine will not honour.
|
|
40
|
+
CLEARCOAT_ROUGHNESS_FLOOR: Final = 0.0525
|
|
41
|
+
|
|
42
|
+
# `float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );`
|
|
43
|
+
# `outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;`
|
|
44
|
+
# ShaderLib/meshphysical.glsl.js:205,207
|
|
45
|
+
# Turning sheen on DARKENS the diffuse base by this coefficient times the effective sheen strength.
|
|
46
|
+
SHEEN_ENERGY_COMPENSATION_COEFFICIENT: Final = 0.157
|
|
47
|
+
|
|
48
|
+
# `clearcoatF0 = vec3( 0.04 )` -- fixed, not authorable.
|
|
49
|
+
# ShaderChunk/lights_physical_fragment.glsl.js:56
|
|
50
|
+
CLEARCOAT_F0: Final = 0.04
|
|
51
|
+
|
|
52
|
+
# three's own defaults, needed to know when an omitted value is a silent no-op rather than a
|
|
53
|
+
# reasonable fallback. MeshPhysicalMaterial.js:52,54 / Material.js:24,25
|
|
54
|
+
THREE_DEFAULT_SHEEN_COLOR: Final = "#000000"
|
|
55
|
+
THREE_DEFAULT_SHEEN_ROUGHNESS: Final = 1.0
|
|
56
|
+
THREE_DEFAULT_SIDE: Final = "FrontSide"
|
|
57
|
+
|
|
58
|
+
# Properties whose entire uniform block is gated behind the scalar being > 0, and whose crossing of
|
|
59
|
+
# zero bumps `material.version` and forces a shader recompile.
|
|
60
|
+
# WebGLMaterials.js:406 (sheen); MeshPhysicalMaterial.js getters for the rest.
|
|
61
|
+
ZERO_GATED_FEATURES: Final = frozenset({
|
|
62
|
+
"sheen", "clearcoat", "transmission", "iridescence", "anisotropy", "dispersion",
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
# Pairs the engine collapses into a single degree of freedom. Authoring both as independent
|
|
66
|
+
# reference-derived evidence is authoring one number twice.
|
|
67
|
+
# sheen x sheenColor: WebGLMaterials.js:408
|
|
68
|
+
# ior <-> reflectivity: MeshPhysicalMaterial.js:34-44
|
|
69
|
+
COLLAPSED_DEGREES_OF_FREEDOM: Final = (
|
|
70
|
+
("sheen", "sheenColor", "multiplied into one uniform before upload"),
|
|
71
|
+
("ior", "reflectivity", "reflectivity is a derived accessor over ior"),
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
# Skin's real signature at this fidelity is a broad soft dielectric highlight over a warm diffuse
|
|
75
|
+
# base, which is a low-strength mid-roughness clearcoat. `transmission` is a SCREEN-SPACE REFRACTION
|
|
76
|
+
# model -- glass, not subsurface -- and on a closed opaque body mesh it produces a glassy figure at
|
|
77
|
+
# the cost of an extra render target. The registry states the same limit for skin.human.
|
|
78
|
+
SKIN_FORBIDDEN_PROPERTIES: Final = frozenset({"transmission", "thickness", "attenuationDistance"})
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def effective_sheen_strength(sheen: float, sheen_color: str | None) -> float:
|
|
82
|
+
"""What the engine actually applies, after folding the scalar into the colour.
|
|
83
|
+
|
|
84
|
+
`uniforms.sheenColor = sheenColor x sheen` (WebGLMaterials.js:408), and the BRDF multiplies by
|
|
85
|
+
that colour, so the strength that matters is the scalar times the colour's largest channel --
|
|
86
|
+
`max3` is exactly what the energy term reads.
|
|
87
|
+
"""
|
|
88
|
+
if sheen <= 0.0:
|
|
89
|
+
return 0.0
|
|
90
|
+
channel = _max_channel(sheen_color if sheen_color is not None else THREE_DEFAULT_SHEEN_COLOR)
|
|
91
|
+
return sheen * channel
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
def sheen_base_darkening(sheen: float, sheen_color: str | None) -> float:
|
|
95
|
+
"""How much the diffuse base is scaled DOWN by enabling sheen, in [0, 0.157].
|
|
96
|
+
|
|
97
|
+
This is the number that makes "the garment came out too dark" diagnosable rather than a matter of
|
|
98
|
+
opinion: given the authored sheen, the darkening is known before the render exists.
|
|
99
|
+
"""
|
|
100
|
+
return SHEEN_ENERGY_COMPENSATION_COEFFICIENT * effective_sheen_strength(sheen, sheen_color)
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
def compensated_base_luminance(target: float, sheen: float, sheen_color: str | None) -> float:
|
|
104
|
+
"""The base luminance to author so the RENDER matches `target` once sheen has darkened it.
|
|
105
|
+
|
|
106
|
+
Returns `target` unchanged when sheen is off, so it is safe to apply unconditionally.
|
|
107
|
+
"""
|
|
108
|
+
darkening = sheen_base_darkening(sheen, sheen_color)
|
|
109
|
+
if darkening <= 0.0:
|
|
110
|
+
return target
|
|
111
|
+
return min(1.0, target / (1.0 - darkening))
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
def _max_channel(color: str) -> float:
|
|
115
|
+
"""Largest of r, g, b in [0, 1] for a `#rgb` or `#rrggbb` string. Unparseable -> 0.0.
|
|
116
|
+
|
|
117
|
+
Returning 0 rather than raising is deliberate: an unparseable colour cannot be shown to carry
|
|
118
|
+
sheen, and the caller's job here is to detect a no-op, not to validate colour syntax.
|
|
119
|
+
"""
|
|
120
|
+
text = str(color).strip().lstrip("#")
|
|
121
|
+
if len(text) == 3:
|
|
122
|
+
text = "".join(ch * 2 for ch in text)
|
|
123
|
+
if len(text) != 6:
|
|
124
|
+
return 0.0
|
|
125
|
+
try:
|
|
126
|
+
channels = [int(text[i:i + 2], 16) / 255.0 for i in (0, 2, 4)]
|
|
127
|
+
except ValueError:
|
|
128
|
+
return 0.0
|
|
129
|
+
return max(channels)
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
def check_material_physics(
|
|
133
|
+
material_id: str,
|
|
134
|
+
material: dict[str, Any],
|
|
135
|
+
*,
|
|
136
|
+
family: str | None = None,
|
|
137
|
+
) -> tuple[list[str], list[str]]:
|
|
138
|
+
"""`(errors, warnings)` for one material, judged against what the engine will do with it.
|
|
139
|
+
|
|
140
|
+
`family` routes the family-specific rules -- `skin` forbids transmission, and a `fabric` or
|
|
141
|
+
`hair` family that ships no sheen tint has no woven cue at all.
|
|
142
|
+
"""
|
|
143
|
+
errors: list[str] = []
|
|
144
|
+
warnings: list[str] = []
|
|
145
|
+
|
|
146
|
+
sheen = _number(material.get("sheen"))
|
|
147
|
+
sheen_color = material.get("sheenColor")
|
|
148
|
+
|
|
149
|
+
# A no-op, not a subtle mis-tune: the term is a multiply by colour and the default colour is black.
|
|
150
|
+
if sheen is not None and sheen > 0.0:
|
|
151
|
+
if sheen_color is None:
|
|
152
|
+
errors.append(
|
|
153
|
+
f"material {material_id!r} sets sheen {sheen} but no sheenColor. three's default "
|
|
154
|
+
f"sheenColor is {THREE_DEFAULT_SHEEN_COLOR} and the sheen term is a multiply by that "
|
|
155
|
+
f"colour, so this contributes exactly zero. Declare sheenColor."
|
|
156
|
+
)
|
|
157
|
+
elif _max_channel(str(sheen_color)) == 0.0:
|
|
158
|
+
errors.append(
|
|
159
|
+
f"material {material_id!r} sets sheen {sheen} with sheenColor {sheen_color!r}, whose "
|
|
160
|
+
f"channels are all zero, so the sheen term evaluates to zero."
|
|
161
|
+
)
|
|
162
|
+
else:
|
|
163
|
+
darkening = sheen_base_darkening(sheen, str(sheen_color))
|
|
164
|
+
if darkening > 0.0:
|
|
165
|
+
warnings.append(
|
|
166
|
+
f"quality: material {material_id!r} sheen darkens its own diffuse base by "
|
|
167
|
+
f"{darkening * 100:.1f}% (sheenEnergyComp). Author the base colour "
|
|
168
|
+
f"{1.0 / (1.0 - darkening):.3f}x brighter than the reference sample, or the "
|
|
169
|
+
f"render lands darker than the reference at every non-grazing angle."
|
|
170
|
+
)
|
|
171
|
+
|
|
172
|
+
# A value below the clamp is indistinguishable from the clamp, so reporting it as authored is
|
|
173
|
+
# reporting a precision the engine does not have.
|
|
174
|
+
clearcoat_roughness = _number(material.get("clearcoatRoughness"))
|
|
175
|
+
if clearcoat_roughness is not None and 0.0 < clearcoat_roughness < CLEARCOAT_ROUGHNESS_FLOOR:
|
|
176
|
+
warnings.append(
|
|
177
|
+
f"quality: material {material_id!r} clearcoatRoughness {clearcoat_roughness} is below "
|
|
178
|
+
f"three's floor of {CLEARCOAT_ROUGHNESS_FLOOR} and will render as exactly that. Author "
|
|
179
|
+
f"{CLEARCOAT_ROUGHNESS_FLOOR} so the spec says what ships."
|
|
180
|
+
)
|
|
181
|
+
|
|
182
|
+
# Both halves of a collapsed pair authored at once: the spec looks richer than it is, and the two
|
|
183
|
+
# numbers can disagree while rendering identically.
|
|
184
|
+
for first, second, why in COLLAPSED_DEGREES_OF_FREEDOM:
|
|
185
|
+
if material.get(first) is not None and material.get(second) is not None:
|
|
186
|
+
if (first, second) == ("ior", "reflectivity"):
|
|
187
|
+
errors.append(
|
|
188
|
+
f"material {material_id!r} sets both {first} and {second}: {why}. Author {first} "
|
|
189
|
+
f"only -- it is the physical quantity."
|
|
190
|
+
)
|
|
191
|
+
else:
|
|
192
|
+
warnings.append(
|
|
193
|
+
f"quality: material {material_id!r} sets both {first} and {second}: {why}. They "
|
|
194
|
+
f"are one control, so these are not independent evidence."
|
|
195
|
+
)
|
|
196
|
+
|
|
197
|
+
normalized_family = (family or material.get("family") or "").lower()
|
|
198
|
+
|
|
199
|
+
if normalized_family == "skin":
|
|
200
|
+
for forbidden in sorted(SKIN_FORBIDDEN_PROPERTIES):
|
|
201
|
+
if material.get(forbidden) is not None:
|
|
202
|
+
errors.append(
|
|
203
|
+
f"material {material_id!r} is family 'skin' and sets {forbidden!r}. transmission "
|
|
204
|
+
f"is a screen-space refraction (glass) model, not subsurface scattering; on a "
|
|
205
|
+
f"closed body mesh it renders a glassy figure and costs an extra render target. "
|
|
206
|
+
f"Use clearcoat over a warm base instead. A thin translucent membrane is a "
|
|
207
|
+
f"separate component with a separate material, declared as an approximation."
|
|
208
|
+
)
|
|
209
|
+
|
|
210
|
+
if normalized_family in {"fabric", "hair"} and (sheen is None or sheen <= 0.0):
|
|
211
|
+
warnings.append(
|
|
212
|
+
f"quality: material {material_id!r} is family {normalized_family!r} but carries no sheen. "
|
|
213
|
+
f"With no textures available, sheen is the whole of the woven or fibre cue this pipeline "
|
|
214
|
+
f"can emit."
|
|
215
|
+
)
|
|
216
|
+
|
|
217
|
+
return errors, warnings
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
def check_open_boundary_sides(component_id: str, component: dict[str, Any]) -> list[str]:
|
|
221
|
+
"""A garment shell with an open boundary must render both sides.
|
|
222
|
+
|
|
223
|
+
`Material.side` defaults to `FrontSide` (Material.js:24), which culls backfaces. A sleeve, hem or
|
|
224
|
+
collar opening therefore shows a HOLE rather than the inside of the garment: the geometry is
|
|
225
|
+
there, the engine simply does not draw the faces pointing away. Reported as an error because a
|
|
226
|
+
hole at a hem is indistinguishable at a glance from a garment that is too short, and the two want
|
|
227
|
+
completely different fixes.
|
|
228
|
+
"""
|
|
229
|
+
garment = component.get("garment")
|
|
230
|
+
if not isinstance(garment, dict):
|
|
231
|
+
return []
|
|
232
|
+
boundaries = garment.get("boundaries")
|
|
233
|
+
if not isinstance(boundaries, list) or not boundaries:
|
|
234
|
+
return []
|
|
235
|
+
has_open = any(
|
|
236
|
+
isinstance(entry, dict) and entry.get("closed") is not True for entry in boundaries
|
|
237
|
+
)
|
|
238
|
+
if not has_open:
|
|
239
|
+
return []
|
|
240
|
+
if str(component.get("side") or THREE_DEFAULT_SIDE) == "FrontSide":
|
|
241
|
+
return [
|
|
242
|
+
f"component {component_id!r} is a garment with an open boundary but leaves side at "
|
|
243
|
+
f"'FrontSide', so backfaces are culled and the opening renders as a hole rather than as "
|
|
244
|
+
f"the inside of the garment. Set side to 'DoubleSide', or author the garment as a closed "
|
|
245
|
+
f"offset volume and mark its boundaries closed."
|
|
246
|
+
]
|
|
247
|
+
return []
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
def _number(value: Any) -> float | None:
|
|
251
|
+
if isinstance(value, bool) or not isinstance(value, (int, float)):
|
|
252
|
+
return None
|
|
253
|
+
return float(value)
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
"""Fail-closed routing for the weapon and character authoring tracks."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Any, Final
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
CONFIDENCE_THRESHOLD: Final[float] = 0.82
|
|
9
|
+
TRACK_BY_KIND: Final[dict[str, str]] = {
|
|
10
|
+
"weapon": "weapon-v1.4",
|
|
11
|
+
"character": "character-v1.5",
|
|
12
|
+
}
|
|
13
|
+
VALID_TRACKS: Final[frozenset[str]] = frozenset(TRACK_BY_KIND.values())
|
|
14
|
+
VALID_KINDS: Final[frozenset[str]] = frozenset({"weapon", "character", "hybrid", "unknown"})
|
|
15
|
+
VALID_SOURCES: Final[frozenset[str]] = frozenset({"explicit", "classification", "legacy"})
|
|
16
|
+
VALID_STATUSES: Final[frozenset[str]] = frozenset({"resolved", "request-input"})
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def _fallback_classification(reason: str) -> dict[str, Any]:
|
|
20
|
+
return {
|
|
21
|
+
"kind": "unknown",
|
|
22
|
+
"confidence": 0.0,
|
|
23
|
+
"evidenceRefs": [f"pipeline-routing:{reason}"],
|
|
24
|
+
"provider": "pipeline-routing",
|
|
25
|
+
"version": "1",
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def _explicit_classification(track: str) -> dict[str, Any]:
|
|
30
|
+
kind = "weapon" if track == "weapon-v1.4" else "character"
|
|
31
|
+
return {
|
|
32
|
+
"kind": kind,
|
|
33
|
+
"confidence": 1.0,
|
|
34
|
+
"evidenceRefs": [f"pipeline-routing:explicit:{track}"],
|
|
35
|
+
"provider": "pipeline-routing-cli",
|
|
36
|
+
"version": "1",
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def _normalize_classification(classification: Any) -> tuple[dict[str, Any], list[str]]:
|
|
41
|
+
if classification is None:
|
|
42
|
+
return _fallback_classification("missing-classification"), []
|
|
43
|
+
if not isinstance(classification, dict):
|
|
44
|
+
return _fallback_classification("malformed-classification"), ["classification is malformed"]
|
|
45
|
+
kind = classification.get("kind")
|
|
46
|
+
confidence = classification.get("confidence")
|
|
47
|
+
refs = classification.get("evidenceRefs")
|
|
48
|
+
provider = classification.get("provider")
|
|
49
|
+
version = classification.get("version")
|
|
50
|
+
malformed = (
|
|
51
|
+
kind not in VALID_KINDS
|
|
52
|
+
or not isinstance(confidence, (int, float))
|
|
53
|
+
or isinstance(confidence, bool)
|
|
54
|
+
or not 0.0 <= confidence <= 1.0
|
|
55
|
+
or not isinstance(refs, list)
|
|
56
|
+
or not refs
|
|
57
|
+
or not all(isinstance(ref, str) and ref for ref in refs)
|
|
58
|
+
or not isinstance(provider, str)
|
|
59
|
+
or not provider
|
|
60
|
+
or not isinstance(version, str)
|
|
61
|
+
or not version
|
|
62
|
+
)
|
|
63
|
+
if malformed:
|
|
64
|
+
return _fallback_classification("malformed-classification"), ["classification is malformed"]
|
|
65
|
+
return {
|
|
66
|
+
"kind": kind,
|
|
67
|
+
"confidence": float(confidence),
|
|
68
|
+
"evidenceRefs": list(refs),
|
|
69
|
+
"provider": provider,
|
|
70
|
+
"version": version,
|
|
71
|
+
}, []
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def classification_from_cs2_manifest(manifest: dict[str, Any]) -> dict[str, Any]:
|
|
75
|
+
"""Translate the CS2 authoritative record into the shared routing classification."""
|
|
76
|
+
record = manifest.get("classification")
|
|
77
|
+
if not isinstance(record, dict):
|
|
78
|
+
return _fallback_classification("cs2-manifest-missing-classification")
|
|
79
|
+
return {
|
|
80
|
+
"kind": "weapon",
|
|
81
|
+
"confidence": record.get("confidence"),
|
|
82
|
+
"evidenceRefs": record.get("evidenceRefs"),
|
|
83
|
+
"provider": record.get("provider"),
|
|
84
|
+
"version": record.get("version"),
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
def resolve_pipeline_routing(
|
|
89
|
+
*,
|
|
90
|
+
explicit_track: str | None = None,
|
|
91
|
+
classification: Any = None,
|
|
92
|
+
legacy_cs2: bool = False,
|
|
93
|
+
) -> dict[str, Any]:
|
|
94
|
+
"""Resolve one supported track or return request-input without guessing a template."""
|
|
95
|
+
if legacy_cs2:
|
|
96
|
+
resolved_classification = {
|
|
97
|
+
"kind": "weapon",
|
|
98
|
+
"confidence": 1.0,
|
|
99
|
+
"evidenceRefs": ["legacy:cs2Intake"],
|
|
100
|
+
"provider": "legacy-cs2-intake",
|
|
101
|
+
"version": "1",
|
|
102
|
+
}
|
|
103
|
+
if explicit_track is not None and explicit_track != "weapon-v1.4":
|
|
104
|
+
return {
|
|
105
|
+
"version": 1,
|
|
106
|
+
"track": explicit_track,
|
|
107
|
+
"source": "explicit",
|
|
108
|
+
"status": "request-input",
|
|
109
|
+
"classification": resolved_classification,
|
|
110
|
+
"conflicts": [
|
|
111
|
+
f"explicit track {explicit_track!r} contradicts legacy CS2 weapon routing"
|
|
112
|
+
],
|
|
113
|
+
}
|
|
114
|
+
return {
|
|
115
|
+
"version": 1,
|
|
116
|
+
"track": "weapon-v1.4",
|
|
117
|
+
"source": "legacy",
|
|
118
|
+
"status": "resolved",
|
|
119
|
+
"classification": resolved_classification,
|
|
120
|
+
"conflicts": [],
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
normalized, conflicts = _normalize_classification(classification)
|
|
124
|
+
if explicit_track is not None and explicit_track not in VALID_TRACKS:
|
|
125
|
+
conflicts.append("explicit track is invalid")
|
|
126
|
+
explicit_track = None
|
|
127
|
+
if explicit_track is not None and classification is None:
|
|
128
|
+
normalized = _explicit_classification(explicit_track)
|
|
129
|
+
|
|
130
|
+
kind = normalized["kind"]
|
|
131
|
+
confidence = normalized["confidence"]
|
|
132
|
+
reliable_kind = kind in TRACK_BY_KIND and confidence >= CONFIDENCE_THRESHOLD
|
|
133
|
+
requested_track = explicit_track or TRACK_BY_KIND.get(kind, "weapon-v1.4")
|
|
134
|
+
if kind in {"hybrid", "unknown"}:
|
|
135
|
+
conflicts.append(f"classification kind {kind!r} requires input")
|
|
136
|
+
elif confidence < CONFIDENCE_THRESHOLD:
|
|
137
|
+
conflicts.append(f"classification confidence {confidence:.2f} is below {CONFIDENCE_THRESHOLD:.2f}")
|
|
138
|
+
elif explicit_track is not None and reliable_kind and TRACK_BY_KIND[kind] != explicit_track:
|
|
139
|
+
conflicts.append(f"explicit track {explicit_track!r} contradicts reliable classification {kind!r}")
|
|
140
|
+
|
|
141
|
+
status = "resolved" if reliable_kind and not conflicts else "request-input"
|
|
142
|
+
source = "explicit" if explicit_track is not None else "classification"
|
|
143
|
+
return {
|
|
144
|
+
"version": 1,
|
|
145
|
+
"track": requested_track,
|
|
146
|
+
"source": source,
|
|
147
|
+
"status": status,
|
|
148
|
+
"classification": normalized,
|
|
149
|
+
"conflicts": conflicts,
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
def validate_pipeline_routing(routing: Any) -> list[str]:
|
|
154
|
+
"""Return contract errors for a persisted routing record."""
|
|
155
|
+
if not isinstance(routing, dict):
|
|
156
|
+
return ["pipelineRouting must be an object"]
|
|
157
|
+
errors: list[str] = []
|
|
158
|
+
if routing.get("version") != 1:
|
|
159
|
+
errors.append("pipelineRouting.version must be 1")
|
|
160
|
+
if routing.get("track") not in VALID_TRACKS:
|
|
161
|
+
errors.append("pipelineRouting.track must be weapon-v1.4 or character-v1.5")
|
|
162
|
+
if routing.get("source") not in VALID_SOURCES:
|
|
163
|
+
errors.append("pipelineRouting.source must be explicit, classification, or legacy")
|
|
164
|
+
if routing.get("status") not in VALID_STATUSES:
|
|
165
|
+
errors.append("pipelineRouting.status must be resolved or request-input")
|
|
166
|
+
classification = routing.get("classification")
|
|
167
|
+
normalized, classification_errors = _normalize_classification(classification)
|
|
168
|
+
if classification_errors:
|
|
169
|
+
errors.append("pipelineRouting.classification is malformed")
|
|
170
|
+
if not isinstance(classification, dict) or classification != normalized:
|
|
171
|
+
errors.append("pipelineRouting.classification must use the shared classification contract")
|
|
172
|
+
conflicts = routing.get("conflicts")
|
|
173
|
+
if not isinstance(conflicts, list) or not all(isinstance(conflict, str) for conflict in conflicts):
|
|
174
|
+
errors.append("pipelineRouting.conflicts must be a list")
|
|
175
|
+
elif routing.get("status") == "resolved" and conflicts:
|
|
176
|
+
errors.append("resolved pipelineRouting cannot contain conflicts")
|
|
177
|
+
return errors
|