Export: Sketchfab Metalness (separate maps) template, one map per Sketchfab metalness channel with DirectX normals, Sketchfab's default

Based on #258 by Aalzard.
Spec: https://help.sketchfab.com/en/articles/16152630-pbr-maps, https://help.sketchfab.com/en/articles/16152634-materials-pbr and https://help.sketchfab.com/en/articles/16152621-normal-map-bump-map
The base color has no alpha: Sketchfab's docs don't say its opacity reads it.
This commit is contained in:
Rebornim committed 2026-11-25 05:49:03 +00:00
1 parent ba6dcf5240
commit 3b56a8e6b3
4 files changed
+33 -1

No files matched your search

+1
View File
@@ -141,6 +141,7 @@ Built-in presets (each one lists the public specification its packing follows in
| glTF Specular Glossiness (archived extension) | `Diffuse` (A = opacity), `SpecularGlossiness` (RGB specular, A glossiness, from the set's own channels), `Normal` (OpenGL), `Occlusion`, `Emissive` |
| Redshift Standard Material (separate maps) | one map per Standard Material input the set has: `BaseColor`, `Metalness`, `ReflectionRoughness`, `Normal` (OpenGL), `EmissionColor`, `Opacity`, `SubsurfaceWeight`, `CoatWeight`, `CoatRoughness`, `SheenWeight`, `SheenColor`, `SheenRoughness` |
| Roblox SurfaceAppearance (separate maps) | `Color` (A = opacity), `Normal` (OpenGL), `Metalness`, `Roughness` |
| Sketchfab Metalness (separate maps) | `BaseColor` (no alpha), `Metalness`, `Roughness`, `Normal` (DirectX), `AmbientOcclusion`, `Emission` |
| Separate maps | one file per channel, gray where scalar, height 16-bit |
| Mesh maps | every baked map (`$channel` = map id), 16-bit |
+17
View File
@@ -1835,3 +1835,20 @@ fn the_roblox_template_writes_opacity_in_the_colour_alpha_and_opengl_normals() {
let green = pixel(find(&files, "_Normal.png"))[1];
assert!((green - open_gl_green).abs() <= 1, "OpenGL normal: green {green}");
}
#[test]
fn the_sketchfab_template_writes_directx_normals_and_one_map_per_channel() {
let mut fx = packing_fixture();
let open_gl_green = tilt_normals(&mut fx);
let files = fx.render_preset("Sketchfab Metalness (separate maps)");
assert_eq!(decode(find(&files, "_BaseColor.png")).color(), image::ColorType::Rgb8, "no alpha on the base color");
for (input, expected) in [("Metalness", 0.8), ("Roughness", 0.4), ("AmbientOcclusion", 0.6)] {
let file = find(&files, &format!("_{input}.png"));
assert_eq!(decode(file).color(), image::ColorType::L8, "{input} is linear grayscale");
assert_close(pixel(file), [byte(expected), byte(expected), byte(expected), 255], input);
}
let green = pixel(find(&files, "_Normal.png"))[1];
assert!((green - (255 - open_gl_green)).abs() <= 1, "DirectX normal: green {green}");
}
+14
View File
@@ -276,6 +276,20 @@ pub fn builtin_presets() -> Vec<ExportPreset> {
map("Roughness", 8, gray(ch(Channel::Roughness, 0))),
],
),
// Spec: https://help.sketchfab.com/en/articles/16152630-pbr-maps (sRGB base color, linear grayscale metalness; no alpha, the docs don't say opacity reads it)
// Spec: https://help.sketchfab.com/en/articles/16152634-materials-pbr (roughness, AO and emission channels)
// Spec: https://help.sketchfab.com/en/articles/16152621-normal-map-bump-map (DirectX normals by default)
preset(
"Sketchfab Metalness (separate maps)",
vec![
map("BaseColor", 8, rgb(|k| ch(Channel::BaseColor, k))),
map("Metalness", 8, gray(ch(Channel::Metallic, 0))),
map("Roughness", 8, gray(ch(Channel::Roughness, 0))),
map("Normal", 8, normal(VirtualMap::NormalDirectX)),
map("AmbientOcclusion", 8, gray(virt(VirtualMap::AoMixed, 0))),
map("Emission", 8, rgb(|k| ch(Channel::Emissive, k))),
],
),
preset("Separate maps", Channel::ALL.into_iter().map(channel_map).collect()),
preset(
"Mesh maps",
+1 -1
View File
@@ -163,7 +163,7 @@ Everything TextureCraft does today, by area. What's still missing is in [`ROADMA
finished; the bake bar follows the newest map, pins a finished one or shows the material.
- **Export presets** for glTF PBR Metal Roughness, Unreal Engine (packed), Unity HDRP (mask map),
Unity Standard, Unity URP Lit, USD Preview Surface, Blender (Principled BSDF), Godot 4 (ORM), OpenPBR (with the coat, fuzz,
anisotropy, transmission and subsurface maps), Unreal Engine (subsurface profile), glTF specular/glossiness (archived extension), Redshift Standard Material, Roblox SurfaceAppearance, separate maps, mesh maps and document channels, in
anisotropy, transmission and subsurface maps), Unreal Engine (subsurface profile), glTF specular/glossiness (archived extension), Redshift Standard Material, Roblox SurfaceAppearance, Sketchfab (metalness), separate maps, mesh maps and document channels, in
PNG, JPEG, JPEG 2000, JNG, PGM, TGA, TIFF, BMP, WEBP, PSD, EXR or HDR at 8 bits (optionally dithered), 16
bits or 32-bit float (TIFF, EXR, HDR; 16-bit half float for EXR), with UV padding (dilation,
infinite, or dilation + diffusion), size override and OpenGL or DirectX normals.