model/blend: material inputs traced through reroutes, mix, colour adjustments, colour ramps and node groups; unresolved links flagged with neutral values; roughness / metallic image textures with their channel; vertex colours; bump; UDIM images with the <UDIM> token and their tiles

This commit is contained in:
4DBug committed 2026-11-03 02:22:45 -06:00
1 parent 8fd5a4c3f2
commit 3a56a66ac1
13 files changed
+1781 -531

No files matched your search

+20 -1
View File
@@ -956,7 +956,7 @@ cameras, lights, armatures, skins, shape keys and actions. Blender is z-up (`met
|---|---|
| Meshes | every storage generation: MFace (before 2.63 and the 2.7x "legacy mesh format"), MPoly / MLoop (2.63 - 3.x), attribute layers (`position`, `.corner_vert`, ... 3.x - 4.x), AttributeStorage (5.x); a primitive per used material slot, `triangulate = false` keeps the faces (`"polygons"`) |
| Mesh data | UV maps (`TEXCOORD_n`, v flipped to glTF's origin), colour attributes (byte and float, point and corner) as linear `COLOR_n`, corner normals from Blender's smooth fans (sharp edges / faces, auto smooth before 4.1) or the stored custom normals, weights (`JOINTS_0` / `WEIGHTS_0`: the 4 largest deform-bone groups, normalized) |
| Materials | the Principled BSDF (base colour, metallic, roughness, alpha, emission and its strength, image textures on Base Color / Emission, Normal through a Normal Map node, Roughness / Metallic through Separate RGB), else the legacy `r, g, b` colour |
| Materials | the Principled BSDF (base colour, metallic, roughness, alpha, emission and its strength, image textures on Base Color / Emission / Roughness / Metallic, Normal through a Normal Map node, Roughness / Metallic through Separate RGB / Color as `metallicRoughnessTexture`), else the legacy `r, g, b` colour; images are found through pass-through nodes (see [Material graphs](#material-graphs)) |
| Images | packed images as encoded bytes (`texture.data`), external ones as `uri` (relative to the `.blend`, bytes through `files` / `resolve`) |
| Cameras, lights | perspective (`yfov` from the lens, sensor fit and render aspect) / orthographic; point, sun, spot (watts to candela / lux as Blender's glTF exporter does); area lights are skipped (`meta.source.skippedLights`) |
| Armatures | a joint node per bone (rest pose times the saved pose), one skin per deformed mesh; the rig data (bones, collections, colours, custom shapes, constraints) in `extras.blend`, see [Rig data](#rig-data) |
@@ -975,6 +975,25 @@ assert(scene.materials[1].name == "Skin" and scene.materials[1].roughness > 0.69
print(src.modifiers.Tube[1].type) -- Armature (not applied)
```
### Material graphs
Each mapped Principled input follows its link through reroutes, Mix / MixRGB (A, then B), Hue-Saturation,
Bright-Contrast, Gamma, Invert, RGB Curves, Color Ramp (its Factor) and node groups (into the group and back out of
its inputs) to the first Image Texture node. In `material.extras.blend`:
| Field | Meaning |
|---|---|
| `via` | per input (`baseColor`, `roughness`, `metallic`, `normal`, `bump`, `alpha`, `emissive`), the node idnames passed on the way to the image (`{ baseColor = { "ShaderNodeMix" } }`); MixRGB nodes of files before 3.4 are named `ShaderNodeMix`, as Blender's conversion names them |
| `linked` | per input, the node an input is linked to when it reaches no image (`{ baseColor = "ShaderNodeTexNoise" }`); that input then takes a neutral value instead of the socket's unused default: base colour 0.8 grey (Blender's default Principled colour), metallic 0, roughness 0.5, no emission, alpha 1 |
| `vertexColor` | the colour attribute a Vertex Color (or Attribute) node feeding Base Color reads; the base colour is then white, to multiply with that `COLOR_n` |
| `roughnessTexture`, `metallicTexture` | a TextureRef plus `channel` (`"R"` for a grey map's colour, `"A"` for its alpha, or the Separate RGB / Color output used); the factor (`roughness`, `metallic`) is then 1, as glTF multiplies them |
| `bumpTexture`, `bumpStrength`, `bumpDistance` | a Bump node on Normal: the height image and the node's Strength and Distance (not a normal map, so not `normalTexture`) |
Tiled (UDIM) images (`Image.source` TILED) keep the `<UDIM>` token in `texture.uri` (`textures/body.<UDIM>.png`;
older files naming the first tile, `body.1001.png`, get the token as Blender's versioning does), and
`texture.extras.blend.tiles` lists `{ number, label?, filename }` per tile (`filename` = the uri with the number). The
texture's `data` is the first tile, through `files` / `resolve`.
### Rig data
Field names are Blender's Python API names. Spaces: the armature node carries the armature object's transform; each