Skip to content

Free, open-source 3D sculpting for Linux, macOS and Windows: dense meshes, remeshing, painting, built-in AI (image/text to 3D), Send to Unreal, game-ready LODs, Gaussian splats and OpenUSD.

Exports: sidecar files without spaces in their names; export check tools

islandmedb08b41e61986
diff --git a/docs/guide/exporting.md b/docs/guide/exporting.md
index 15542089..e37f0ba8 100644
--- a/docs/guide/exporting.md
+++ b/docs/guide/exporting.md
@@ -34,9 +34,17 @@ only hold triangles.
UVs are kept through OBJ, FBX, USD, glTF and GoZ, in and out. A SubTool with a painted
[texture](texture-painting.md) is exported with it: the PNG is written next to the file as
`<name>_color.png` (`<name>_<SubTool>_color.png` with several SubTools) and referenced by the model, or embedded
-in GLB and USDZ files. **Tool > Texture Map > Auto UV** gives any sculpt UVs before export.
-
-> **Not yet:** texture baking (normal and displacement maps) is on the roadmap.
+in GLB and USDZ files. Spaces in the file name become `_` in the names of the files written beside it
+(`my scene.obj` gets `my_scene.mtl` and `my_scene_color.png`), because OBJ and MTL separate file names with
+spaces. **Tool > Texture Map > Auto UV** gives any sculpt UVs before export. Normal, displacement and other maps
+come from [Tool > Bake](baking.md) as separate image files.
+
+Textured exports are checked against other tools, not only read back by SculptForge: GLB files pass the Khronos
+glTF validator with no errors or warnings; USD and USDZ files pass OpenUSD's validators (the USDZ files are
+uncompressed, 64-byte aligned and have the root layer first); FBX files load in ufbx's strict mode with their
+textures connected; and in all four formats plus OBJ, the texture is sampled the right way up (each format's
+UV convention), checked colour by colour against SculptForge's own sampling. The scripts are in
+`tools/export_check/` in the source tree.
### Scale and axes
diff --git a/docs/guide/studios.md b/docs/guide/studios.md
index 6257a398..8d4bb1d0 100644
--- a/docs/guide/studios.md
+++ b/docs/guide/studios.md
@@ -116,10 +116,10 @@ A `--set` variable replaces a whole value, so pass complete paths (with their ex
| Format | Read | Write | Notes |
|---|---|---|---|
-| OpenUSD (`.usda`, `.usdz`) | Yes | Yes | Meshes, xform ops, Z-up stages, UsdSkel blend shapes, ParticleField Gaussian splats; checked with OpenUSD's `usdchecker` |
-| FBX | Yes (any version) | Yes (7.4 binary) | LOD groups, blend shapes, centimetre units |
-| glTF / GLB | Yes | Yes | Morph targets, vertex colours, `KHR_gaussian_splatting`; checked with the Khronos validator |
-| OBJ | Yes | Yes | Objects as SubTools, groups as polygroups, vertex colours |
+| OpenUSD (`.usda`, `.usdz`) | Yes | Yes | Meshes, xform ops, Z-up stages, UsdSkel blend shapes, ParticleField Gaussian splats, textures; checked with OpenUSD's validators |
+| FBX | Yes (any version) | Yes (7.4 binary) | LOD groups, blend shapes, centimetre units, textures; checked with ufbx's strict mode |
+| glTF / GLB | Yes | Yes | Morph targets, vertex colours, `KHR_gaussian_splatting`, embedded textures; checked with the Khronos validator |
+| OBJ | Yes | Yes | Objects as SubTools, groups as polygroups, vertex colours, textures through `.mtl` |
| PLY | Yes | Yes | Meshes with vertex colours, Gaussian splats |
| STL | Yes (binary and ASCII) | Yes (binary) | |
| ZBrush GoZ | Yes | Yes | Polygroups, mask, polypaint, UVs |
diff --git a/src/io/ObjIO.cpp b/src/io/ObjIO.cpp
index fea8e2d6..f25f53e0 100644
--- a/src/io/ObjIO.cpp
+++ b/src/io/ObjIO.cpp
@@ -318,7 +318,7 @@ bool saveObj(const std::string& path, const std::vector<MeshObjectRef>& objects,
mtl += "\nnewmtl " + name + "\nKa 0 0 0\nKd 1 1 1\nKs 0 0 0\nillum 1\nmap_Kd " + pngs[i] + "\n";
}
if (clayUsed) mtl += "\nnewmtl " + clay + "\nKa 0 0 0\nKd 0.8 0.55 0.45\nKs 0 0 0\nillum 1\n";
- const std::filesystem::path mtlPath = utf8Path(path).replace_extension(".mtl");
+ const std::filesystem::path mtlPath = utf8Path(path).parent_path() / utf8Path(sidecarStem(path) + ".mtl");
std::ofstream mtlFile(mtlPath, std::ios::binary);
if (!mtlFile || !mtlFile.write(mtl.data(), std::streamsize(mtl.size()))) {
error = "Cannot write " + textureUtf8(mtlPath);
@@ -331,7 +331,7 @@ bool saveObj(const std::string& path, const std::vector<MeshObjectRef>& objects,
for (const auto& o : objects) reserve += o.mesh->vertexCount() * 40 + o.mesh->triangleCount() * (hasCornerUvs(*o.mesh) ? 90 : 30);
buf.reserve(reserve);
buf += "# Exported by SculptForge\n";
- if (textured) buf += "mtllib " + textureUtf8(utf8Path(path).stem()) + ".mtl\n";
+ if (textured) buf += "mtllib " + sidecarStem(path) + ".mtl\n";
char line[192];
uint32_t first = 1; // OBJ indices are 1-based and global across objects
uint32_t firstVt = 1; // as are texture coordinate indices
diff --git a/src/io/TextureExport.h b/src/io/TextureExport.h
index 1f3962d3..b2242bcb 100644
--- a/src/io/TextureExport.h
+++ b/src/io/TextureExport.h
@@ -74,9 +74,19 @@ inline std::string textureUtf8(const std::filesystem::path& p) {
return std::string(u.begin(), u.end());
}
+// The model file's stem for the files written beside it (<stem>.mtl, <stem>_color.png), with white space
+// replaced by '_': OBJ's `mtllib` and MTL's `map_Kd` separate file names (and options) by spaces, so
+// "my scene.mtl" would be read as two files "my" and "scene.mtl". Other characters (accents...) are kept.
+inline std::string sidecarStem(const std::string& modelPath) {
+ std::string stem = textureUtf8(textureFsPath(modelPath).stem());
+ for (char& c : stem)
+ if (c == ' ' || c == '\t') c = '_';
+ return stem.empty() ? std::string("model") : stem;
+}
+
// PNG file names (no folder) for the objects of an export to `modelPath`, "" for objects without a texture.
inline std::vector<std::string> textureFileNames(const std::string& modelPath, const std::vector<MeshObjectRef>& objects) {
- const std::string stem = textureUtf8(textureFsPath(modelPath).stem());
+ const std::string stem = sidecarStem(modelPath);
std::vector<std::string> names(objects.size());
for (size_t i = 0; i < objects.size(); ++i) {
if (!objects[i].mesh || !hasTexture(*objects[i].mesh)) continue;
diff --git a/tests/test_texture_io.cpp b/tests/test_texture_io.cpp
index b72305ab..3e28a704 100644
--- a/tests/test_texture_io.cpp
+++ b/tests/test_texture_io.cpp
@@ -17,6 +17,7 @@
#include "io/GltfIO.h"
#include "io/GozIO.h"
#include "io/ObjIO.h"
+#include "io/TextureExport.h"
#include "io/UsdIO.h"
#include "io/Zip.h"
@@ -290,6 +291,28 @@ TEST(texture_io_obj_writes_mtl_and_png) {
fs::remove_all(dir);
}
+// OBJ's mtllib and MTL's map_Kd split file names at spaces: a model saved as "my scene.obj" names its
+// .mtl and PNGs without them (the OBJ keeps its name), so other apps find them.
+TEST(texture_io_sidecar_names_without_spaces) {
+ const fs::path dir = testDir("sf_texture_io_spaces");
+ std::string err;
+ Mesh m = quadCube();
+ m.texture = redBottomTexture();
+ CHECK(saveObj(str(dir / "my scene.obj"), m, err));
+ const std::string obj = readText(dir / "my scene.obj");
+ CHECK(obj.find("mtllib my_scene.mtl\n") != std::string::npos);
+ CHECK(fs::exists(dir / "my_scene.mtl") && !fs::exists(dir / "my scene.mtl"));
+ CHECK(readText(dir / "my_scene.mtl").find("map_Kd my_scene_color.png\n") != std::string::npos);
+ CHECK(checkPng(dir / "my_scene_color.png"));
+ Mesh back;
+ CHECK(loadObj(str(dir / "my scene.obj"), back, err) && sameUvs(m, back));
+ // The other formats name their PNGs the same way.
+ CHECK(saveFbx(str(dir / "my scene.fbx"), "Sculpt", {&m}, FbxExportOptions{}, err));
+ CHECK(readText(dir / "my scene.fbx").find("my_scene_color.png") != std::string::npos);
+ CHECK(textureFileNames(str(dir / "a\tb c.usda"), {{"Body", &m}}) == std::vector<std::string>{"a_b_c_color.png"});
+ fs::remove_all(dir);
+}
+
TEST(texture_io_fbx_usd_glb_goz_reference_texture) {
const fs::path dir = testDir("sf_texture_io_refs");
std::string err;
diff --git a/tools/export_check/fbxdump.c b/tools/export_check/fbxdump.c
new file mode 100644
index 00000000..5dd9782b
--- /dev/null
+++ b/tools/export_check/fbxdump.c
@@ -0,0 +1,28 @@
+// Prints every FBX corner (position, UV) and the materials/textures ufbx finds, loading in strict mode.
+// Used by tools/export_check/run.sh.
+#include "ufbx.h"
+#include <stdio.h>
+int main(int argc,char**argv){
+ ufbx_load_opts o={0}; ufbx_error e; o.strict = 1;
+ o.target_axes = ufbx_axes_right_handed_y_up; o.target_unit_meters=0;
+ ufbx_scene*s=ufbx_load_file(argv[1],&o,&e);
+ if(!s){char b[512];ufbx_format_error(b,512,&e);fprintf(stderr,"%s\n",b);return 1;}
+ fprintf(stderr,"creator=%s version=%u exporter=%s\n", s->metadata.creator.data, s->metadata.version, s->metadata.original_application.name.data);
+ for(size_t i=0;i<s->metadata.warnings.count;i++) fprintf(stderr,"WARNING %s (%zu)\n",s->metadata.warnings.data[i].description.data,s->metadata.warnings.data[i].count);
+ for(size_t mi=0;mi<s->meshes.count;mi++){ufbx_mesh*m=s->meshes.data[mi];
+ fprintf(stderr,"mesh %s faces=%zu uvsets=%zu mats=%zu instances=%zu\n",m->name.data,m->num_faces,m->uv_sets.count,m->materials.count,m->instances.count);
+ for(size_t k=0;k<m->materials.count;k++){ufbx_material*mat=m->materials.data[k];
+ fprintf(stderr," material %s diffuse_tex=%s pbr_base_tex=%s\n",mat->name.data,
+ mat->fbx.diffuse_color.texture?mat->fbx.diffuse_color.texture->relative_filename.data:"-",
+ mat->pbr.base_color.texture?mat->pbr.base_color.texture->relative_filename.data:"-");
+ if(mat->fbx.diffuse_color.texture){ufbx_texture*t=mat->fbx.diffuse_color.texture; fprintf(stderr," tex filename=%s abs=%s uvset=%s wrap=%d,%d\n",t->filename.data,t->absolute_filename.data,t->uv_set.data,t->wrap_u,t->wrap_v); fprintf(stderr," video=%s content=%zu\n", t->video? t->video->relative_filename.data:"NONE", t->content.size);}
+ }
+ if(!m->vertex_uv.exists) continue;
+ ufbx_node*n=m->instances.count?m->instances.data[0]:0;
+ for(size_t f=0;f<m->num_faces;f++){ufbx_face fc=m->faces.data[f];
+ for(uint32_t c=0;c<fc.num_indices;c++){size_t ix=fc.index_begin+c;
+ ufbx_vec3 p=ufbx_get_vertex_vec3(&m->vertex_position,ix); if(n) p=ufbx_transform_position(&n->geometry_to_world,p);
+ ufbx_vec2 uv=ufbx_get_vertex_vec2(&m->vertex_uv,ix);
+ printf("%zu %.6f %.6f %.6f %.6f %.6f\n",mi,p.x,p.y,p.z,uv.x,uv.y);}}
+ }
+ ufbx_free_scene(s);return 0;}
diff --git a/tools/export_check/orient.py b/tools/export_check/orient.py
new file mode 100644
index 00000000..2f5f032b
--- /dev/null
+++ b/tools/export_check/orient.py
@@ -0,0 +1,78 @@
+# Texture orientation check for OBJ, glTF, USD and FBX exports. (tools/export_check/run.sh)
+import sys, os, json, struct, subprocess, numpy as np
+from PIL import Image
+D=sys.argv[1]; FBXDUMP=sys.argv[2]
+def ply(path):
+ b=open(path,'rb').read(); h=b.index(b'end_header\n')+11; hdr=b[:h].decode().split('\n')
+ n=int([l for l in hdr if l.startswith('element vertex')][0].split()[2])
+ props=[l.split()[1:] for l in hdr if l.startswith('property') and 'list' not in l]
+ props=props[:len(props)] # vertex props first
+ vp=[];
+ for l in hdr:
+ if l.startswith('element face'): break
+ if l.startswith('property'): vp.append(l.split()[1:])
+ fmt={'float':'f4','uchar':'u1','double':'f8','int':'i4','uint':'u4'}
+ dt=np.dtype([(p[1],'<'+fmt[p[0]]) for p in vp])
+ a=np.frombuffer(b,dtype=dt,count=n,offset=h)
+ P=np.stack([a['x'],a['y'],a['z']],1).astype(np.float64); C=np.stack([a['red'],a['green'],a['blue']],1).astype(np.float64)
+ return P,C
+def norm(P,ref):
+ lo,hi=ref.min(0),ref.max(0); plo,phi=P.min(0),P.max(0)
+ return (P-plo)/(phi-plo).max()*(hi-lo).max()+lo
+def compare(name,P,UV,img,flipv):
+ TP,TC=truth
+ P=norm(P,TP)
+ im=np.asarray(img.convert('RGB')).astype(np.float64); H,W=im.shape[:2]
+ u=UV[:,0]; v=UV[:,1]
+ y=((1-v) if flipv else v)*H; x=u*W
+ xi=np.clip(np.floor(x).astype(int),0,W-1); yi=np.clip(np.floor(y).astype(int),0,H-1)
+ S=im[yi,xi]
+ good=0; dmax=0
+ for i in range(0,len(P),2000):
+ d=((P[i:i+2000,None,:]-TP[None,:,:])**2).sum(-1); j=d.argmin(1); dmax=max(dmax,np.sqrt(d.min(1)).max())
+ good+=(np.abs(S[i:i+2000]-TC[j]).max(1)<48).sum()
+ print(f'{name:5s} corners={len(P)} match={good/len(P)*100:.1f}% (pos match err {dmax:.2e}, image {W}x{H}, convention {"v up (flip)" if flipv else "v down"})')
+truth=ply(os.path.join(D,'truth.ply'))
+# OBJ
+vs=[];vts=[];P=[];UV=[]
+for l in open(os.path.join(D,'s.obj')):
+ t=l.split()
+ if not t: continue
+ if t[0]=='v': vs.append(list(map(float,t[1:4])))
+ elif t[0]=='vt': vts.append(list(map(float,t[1:3])))
+ elif t[0]=='f':
+ for c in t[1:]:
+ a=c.split('/'); P.append(vs[int(a[0])-1]); UV.append(vts[int(a[1])-1])
+mtl=[l.split()[1] for l in open(os.path.join(D,'s.mtl')) if l.startswith('map_Kd')][0]
+compare('OBJ',np.array(P),np.array(UV),Image.open(os.path.join(D,mtl)),True)
+# glTF
+b=open(os.path.join(D,'s.glb'),'rb').read()
+jl=struct.unpack('<I',b[12:16])[0]; J=json.loads(b[20:20+jl]); bin_=b[20+jl+8:]
+def acc(i):
+ a=J['accessors'][i]; bv=J['bufferViews'][a['bufferView']]; n={'SCALAR':1,'VEC2':2,'VEC3':3}[a['type']]
+ dt={5126:'<f4',5125:'<u4',5123:'<u2'}[a['componentType']]
+ return np.frombuffer(bin_,dtype=dt,count=a['count']*n,offset=bv.get('byteOffset',0)+a.get('byteOffset',0)).reshape(-1,n) if n>1 else np.frombuffer(bin_,dtype=dt,count=a['count'],offset=bv.get('byteOffset',0)+a.get('byteOffset',0))
+print('glTF nodes', [ {k:v for k,v in n.items() if k in ('matrix','translation','rotation','scale')} for n in J['nodes']])
+pr=J['meshes'][0]['primitives'][0]; idx=acc(pr['indices']); pos=acc(pr['attributes']['POSITION']); tc=acc(pr['attributes']['TEXCOORD_0'])
+mat=J['materials'][pr['material']]; ti=mat['pbrMetallicRoughness']['baseColorTexture']['index']; img=J['images'][J['textures'][ti]['source']]
+bv=J['bufferViews'][img['bufferView']]; import io
+compare('glTF',pos[idx].astype(np.float64),tc[idx].astype(np.float64),Image.open(io.BytesIO(bin_[bv.get('byteOffset',0):bv.get('byteOffset',0)+bv['byteLength']])),False)
+# USD
+from pxr import Usd, UsdGeom, UsdShade
+st=Usd.Stage.Open(os.path.join(D,'s.usda'))
+for p in st.Traverse():
+ if p.IsA(UsdGeom.Mesh):
+ m=UsdGeom.Mesh(p); pts=np.array(m.GetPointsAttr().Get()); fvi=np.array(m.GetFaceVertexIndicesAttr().Get())
+ xf=np.array(UsdGeom.Xformable(p).ComputeLocalToWorldTransform(0)); pts=np.c_[pts,np.ones(len(pts))]@xf; pts=pts[:,:3]
+ pv=UsdGeom.PrimvarsAPI(p).GetPrimvar('st'); stv=np.array(pv.ComputeFlattened())
+ print('USD up axis',UsdGeom.GetStageUpAxis(st),'metersPerUnit',UsdGeom.GetStageMetersPerUnit(st),'st interp',pv.GetInterpolation(), 'orientation', m.GetOrientationAttr().Get(), 'subdiv', m.GetSubdivisionSchemeAttr().Get())
+ f=[s for s in st.Traverse() if s.IsA(UsdShade.Shader) and UsdShade.Shader(s).GetIdAttr().Get()=='UsdUVTexture'][0]
+ path=UsdShade.Shader(f).GetInput('file').Get().resolvedPath
+ compare('USD',pts[fvi],stv,Image.open(path),True)
+# FBX
+out=subprocess.run([FBXDUMP,os.path.join(D,'s.fbx')],capture_output=True,text=True); print(out.stderr.strip())
+a=np.array([list(map(float,l.split()[1:])) for l in out.stdout.strip().split('\n')])
+tex=[l.split('filename=')[1].split()[0] for l in out.stderr.split('\n') if 'tex filename=' in l]
+compare('FBX',a[:,:3],a[:,3:5],Image.open(tex[0] if os.path.isabs(tex[0]) else os.path.join(D,tex[0])),True)
+print('Expect ~90% or more per format: the rest are corners on UV seams and checker borders, where a vertex\'s one '
+ 'polypaint colour cannot match every corner. A flipped convention gives under 1%.')
diff --git a/tools/export_check/run.sh b/tools/export_check/run.sh
new file mode 100755
index 00000000..8c95b8ba
--- /dev/null
+++ b/tools/export_check/run.sh
@@ -0,0 +1,48 @@
+#!/usr/bin/env bash
+# Checks SculptForge's textured exports with other tools than our own loaders:
+# glTF/GLB Khronos glTF validator (npm gltf-validator)
+# USD/USDZ OpenUSD's validation framework (pip usd-core)
+# FBX ufbx (third_party/ufbx) in strict mode: textures, materials, UVs
+# all the texture is sampled the right way up: a checker texture is sampled through each format's UVs
+# (OBJ/USD/FBX: v up, glTF: v down) and compared with SculptForge's own sampling (a PLY of the
+# polypaint made from the same texture).
+# Usage: tools/export_check/run.sh BUILD_DIR [WORK_DIR] (needs node/npm, cc, and uv or python3 -m venv)
+set -euo pipefail
+here="$(cd "$(dirname "$0")" && pwd)"
+root="$(cd "$here/../.." && pwd)"
+build="$(cd "${1:?usage: run.sh BUILD_DIR [WORK_DIR]}" && pwd)"
+work="${2:-$(mktemp -d)}"
+mkdir -p "$work/tools" "$work/out"
+cli="$build/sculptforge-cli"
+
+cd "$work/tools"
+[ -d node_modules/gltf-validator ] || { npm init -y >/dev/null; npm install --silent gltf-validator >/dev/null; }
+if [ ! -x venv/bin/python ]; then
+ if command -v uv >/dev/null; then uv venv -q venv && uv pip install -q --python venv/bin/python usd-core numpy pillow
+ else python3 -m venv venv && venv/bin/pip install -q usd-core numpy pillow; fi
+fi
+cc -O2 -I "$root/third_party/ufbx" -o fbxdump "$here/fbxdump.c" "$root/third_party/ufbx/ufbx.c" -lm
+py="$work/tools/venv/bin/python"
+
+out="$work/out"
+"$py" - "$out/checker.png" <<'PY'
+import sys, colorsys
+from PIL import Image
+im = Image.new('RGB', (1024, 1024)); px = im.load()
+for y in range(1024):
+ for x in range(1024):
+ i = (y // 256) * 4 + x // 256
+ r, g, b = colorsys.hsv_to_rgb(i / 16.0, 1.0 if i % 2 == 0 else 0.6, 1.0 if i < 8 else 0.55)
+ px[x, y] = (int(r * 255), int(g * 255), int(b * 255))
+im.save(sys.argv[1])
+PY
+"$cli" -q -c "new_sphere subdivisions=4; uv_auto; texture_import path=$out/checker.png; polypaint_from_texture; \
+export_ply path=$out/truth.ply; save_obj path=$out/s.obj; export_glb path=$out/s.glb; export_usd path=$out/s.usda; \
+export_fbx path=$out/s.fbx; layer_add name=Bulge; subtool_append primitive=sphere; uv_auto; texture_create size=1024; \
+export_glb path=$out/scene.glb; export_usd path=$out/scene.usdz; export_fbx path=$out/scene.fbx lods=2"
+
+echo "== glTF validator"; for f in "$out"/s.glb "$out"/scene.glb; do NODE_PATH="$work/tools/node_modules" node "$here/validate_gltf.js" "$f" | head -6; done
+echo "== OpenUSD"; for f in "$out"/s.usda "$out"/scene.usdz; do "$py" "$here/usdcheck.py" "$f" | head -1; done
+echo "== ufbx (strict)"; ./fbxdump "$out/scene.fbx" 2>&1 >/dev/null | grep -E 'WARNING|mesh|video' || true
+echo "== texture orientation (match % per format)"
+"$py" "$here/orient.py" "$out" "$work/tools/fbxdump"
diff --git a/tools/export_check/usdcheck.py b/tools/export_check/usdcheck.py
new file mode 100644
index 00000000..68dcab4b
--- /dev/null
+++ b/tools/export_check/usdcheck.py
@@ -0,0 +1,19 @@
+# Runs OpenUSD validators on a .usda/.usdz and prints its meshes and shaders. (tools/export_check/run.sh)
+import sys
+from pxr import UsdUtils, Usd, UsdShade, UsdGeom
+f=sys.argv[1]
+from pxr import UsdValidation
+st=Usd.Stage.Open(f)
+reg=UsdValidation.ValidationRegistry()
+vals=[v for v in reg.GetOrLoadAllValidators() if not v.GetMetadata().name.startswith('usdPhysics')]
+ctx=UsdValidation.ValidationContext(vals)
+errs=ctx.Validate(st)
+print('validation issues:', len(errs))
+for e in errs: print(' ', e.GetValidator().GetMetadata().name if e.GetValidator() else '?', e.GetType(), e.GetMessage()[:300])
+for p in st.Traverse():
+ if p.IsA(UsdGeom.Mesh):
+ m=UsdGeom.Mesh(p); pv=UsdGeom.PrimvarsAPI(p)
+ print(p.GetPath(), 'pts',len(m.GetPointsAttr().Get()),'faces',len(m.GetFaceVertexCountsAttr().Get()), 'primvars',[ (x.GetName(),x.GetInterpolation(), str(x.GetTypeName())) for x in pv.GetPrimvars()])
+ mat,_=UsdShade.MaterialBindingAPI(p).ComputeBoundMaterial(); print(' material', mat.GetPath() if mat else None)
+ if p.IsA(UsdShade.Shader):
+ s=UsdShade.Shader(p); print(' shader',p.GetPath(), s.GetIdAttr().Get(), {i.GetBaseName(): (i.Get() if not i.HasConnectedSource() else 'conn') for i in s.GetInputs()})
diff --git a/tools/export_check/validate_gltf.js b/tools/export_check/validate_gltf.js
new file mode 100644
index 00000000..327fecb3
--- /dev/null
+++ b/tools/export_check/validate_gltf.js
@@ -0,0 +1,5 @@
+// Validates a glTF/GLB file with the Khronos glTF validator; prints its issue report. (tools/export_check/run.sh)
+const v=require('gltf-validator'),fs=require('fs'),path=require('path');
+const f=process.argv[2];
+v.validateBytes(new Uint8Array(fs.readFileSync(f)),{uri:f,maxIssues:200,externalResourceFunction:(u)=>new Promise((res,rej)=>{try{res(new Uint8Array(fs.readFileSync(path.resolve(path.dirname(f),decodeURIComponent(u)))))}catch(e){rej(e.toString())}})})
+.then(r=>{console.log(JSON.stringify(r.issues,null,1).slice(0,6000));}).catch(e=>console.error('ERR',e));