Repository navigation
Description
NOTE: The original body below is superseded by the
final API comment.
Key change: PBR scalars STAY in.properties.pbr, adapters
takeMaterial(notVis),.visowns textures + source
reference only.
API design (final, see comment for authoritative version)
Namespace
.properties.pbr— PBR scalars from TOML (roughness, metallic, ior). Always available..vis— mat-vis remote data (textures, source_id, fetch). Lazy, nullable.- Adapters — standalone functions in
pymat.vis.adapters:
to_threejs(material),to_gltf(material),export_mtlx(material, path).
Signature takes Material, reads from both.properties.pbrand.vis. - Shim —
pymat.vis.shimfully exposed.
Field name mapping
Canonical mapping between ecosystems:
| Concept | py-mat | mat-vis (index/rowmap/parquet) | Three.js | glTF |
|---|---|---|---|---|
| Metal scalar | metallic |
metalness |
metalness |
metallicFactor |
| Roughness scalar | roughness |
roughness |
roughness |
roughnessFactor |
| Base color | base_color (RGBA tuple) |
color_hex (#RRGGBB) |
color (hex int) |
baseColorFactor |
| Color texture | — | color (channel) |
map |
baseColorTexture |
| Normal texture | — | normal (channel) |
normalMap |
normalTexture |
| Roughness texture | — | roughness (channel) |
roughnessMap |
(packed in metallicRoughnessTexture) |
| Metalness texture | — | metalness (channel) |
metalnessMap |
(packed in metallicRoughnessTexture) |
| AO texture | — | ao (channel) |
aoMap |
occlusionTexture |
Each adapter hardcodes its own translation using this table.
py-mat keeps metallic (established API, matches glTF's root term).
mat-vis keeps metalness (matches Three.js and upstream source naming).
Material → vis source_id mapping
A vis_source_id field in the TOML data files links a py-mat
material to its mat-vis appearance:
[stainless.s316L]
name = "Stainless Steel 316L"
vis_source_id = "ambientcg/Metal_Brushed_001"Nullable — materials without a mat-vis appearance simply have
vis = None. Curated manually as mat-vis publishes data.
resolve() semantics
vis.resolve(channel, pbr) returns a ResolvedChannel:
@dataclass
class ResolvedChannel:
texture: bytes | None # PNG bytes if texture exists
scalar: float | None # scalar fallback
has_texture: boolAdapters use this to decide: texture map or uniform value.
Acceptance
-
Visclass with source_id, tier, textures dict, resolve() -
vis_source_idfield in Material + TOML schema - Field name mapping table in a shared constants module
-
pymat.vis.shim— get_manifest, fetch, rowmap_entry -
pymat.vis.adapters— to_threejs, to_gltf, export_mtlx
(signature: takes Material, reads both namespaces) - Tests for Vis, shim, resolve, each adapter
- Coordinate with @bernhard-42 on ocp_vscode
Related
- MorePET/mat-vis#3 — reference clients
- MorePET/mat-vis#8 — M4: Python client
- MorePET/mat-vis#1 — appearance ↔ physical material mapping
Activity
gerchowl commentedon Apr 16, 2026
Final API decision (2026-04-16)
PBR scalars stay under
.properties.pbr..visowns textures, source reference, fetch mechanism, and a resolve helper for adapters.Rationale: PBR scalars bridge physics → rendering (IOR from refractive_index). "roughness" as scalar (0.3) vs texture map (PNG) are different data — different namespaces is correct. No breaking change.
gerchowl commentedon Apr 16, 2026
Update: search lives in shim, not on Material
Material.visis always aVisobject (never None). Starts withsource_id=Noneand empty textures for custom materials.Populated from TOML
[vis]section for registered materials.No
.vis.search()method on Material — keeps the domain objectclean. Search is
shim.search().Finishes for TOML-registered materials
Shim public API (final)
gerchowl commentedon Apr 16, 2026
Naming fix:
shim→vismodulePublic API is
from pymat import vis, notfrom pymat.vis import shim."shim" is an implementation detail, not a user-facing name.
gerchowl commentedon Apr 17, 2026
Done on
docs/refresh-readme-2.1.0:Material.vis,pymat.vismodule, adapters (to_threejs, to_gltf, export_mtlx) as standalone functions, vendored mat-vis client. Ships in 2.2.0. Follow-up: mat#37 for full migration once mat-vis ships the client as a proper importable.feat: use pymat vis adapters for material rendering
feat: stub pymat.vis module — client, model, adapters
feat!: 3.0 vis cutover — `properties.pbr` removed, `.vis` canonical, …