Export presets: Godot 4 (ORM) and OpenPBR

- Godot 4 (ORM): albedo (A = opacity), orm (R AO, G roughness, B metal), normal (OpenGL),
  emission, as StandardMaterial3D reads them
- OpenPBR (separate maps): one map per OpenPBR Surface input the set has, including the coat,
  fuzz (sheen), anisotropy, transmission and subsurface lobes, geometry normal (OpenGL) and a
  16-bit height; maps of channels a set lacks are skipped
- test: OpenPBR writes the lobe maps of a set that has them and skips them otherwise
This commit is contained in:
bflatastic committed 2026-11-01 14:27:05 +07:00
1 parent f41a3126dd
commit faf3a1acab
4 files changed
+45 -1

No files matched your search

+2
View File
@@ -111,6 +111,8 @@ Built-in presets:
| Unity HDRP (Mask Map) | `BaseMap`, `MaskMap` (R metal, G AO, B detail = 0, A smoothness), `Normal` (OpenGL) |
| Unity Standard (Metallic Smoothness) | `Albedo`, `MetallicSmoothness` (R metal, A smoothness), `Normal` (OpenGL), `Occlusion` |
| Blender (Principled BSDF) | `BaseColor`, `Metallic`, `Roughness`, `Normal` (OpenGL), `Height` (16-bit), `Emission`, `Specular` |
| Godot 4 (ORM) | `albedo` (A = opacity), `orm` (R AO, G roughness, B metal), `normal` (OpenGL), `emission` |
| OpenPBR (separate maps) | one map per OpenPBR Surface input the set has: `base_color`, `base_metalness`, `specular_roughness`, `specular_roughness_anisotropy`, `coat_weight`, `coat_roughness`, `fuzz_weight`, `fuzz_color`, `fuzz_roughness`, `transmission_weight`, `subsurface_weight`, `emission_color`, `geometry_opacity`, `geometry_normal` (OpenGL), `height` (16-bit) |
| Separate maps | one file per channel, gray where scalar, height 16-bit |
| Mesh maps | every baked map (`$channel` = map id), 16-bit |
+10
View File
@@ -327,6 +327,16 @@ fn list_outputs_matches_render_and_presets_round_trip() {
assert_eq!(planned, rendered, "{}", preset.name);
}
assert!(builtin_preset("unity hdrp (mask map)").is_some());
// OpenPBR writes the lobe maps a set has, and skips the rest.
let openpbr = ExportOptions::new(builtin_preset("OpenPBR (separate maps)").unwrap());
let names = |fx: &Fx| list_outputs(&fx.project, 0, "m", &openpbr).unwrap().into_iter().map(|p| p.name).collect::<Vec<String>>();
let plain = names(&fx);
assert!(plain.iter().any(|n| n.ends_with("_base_color.png")) && !plain.iter().any(|n| n.contains("coat_")), "{plain:?}");
let mut lobes = default_channels();
lobes.extend([Channel::CoatWeight, Channel::CoatRoughness, Channel::SheenWeight]);
let coated = names(&Fx::new(&lobes));
assert!(coated.iter().any(|n| n.ends_with("_coat_weight.png")) && coated.iter().any(|n| n.ends_with("_fuzz_weight.png")), "{coated:?}");
assert!(builtin_preset("godot 4 (orm)").is_some());
assert!(preset_from_json("{").is_err());
let dup = r#"{"name":"x","maps":[{"file":"a","format":"Png","bit_depth":8,"channels":[["R",{"Constant":1.0}],["R",{"Constant":0.0}]]}]}"#;
assert!(preset_from_json(dup).is_err());
+31
View File
@@ -145,6 +145,37 @@ pub fn builtin_presets() -> Vec<ExportPreset> {
map("Specular", 8, gray(ch(Channel::SpecularLevel, 0))),
],
),
preset(
"Godot 4 (ORM)",
vec![
map("albedo", 8, base_with_alpha()),
map("orm", 8, orm()),
map("normal", 8, normal(VirtualMap::NormalOpenGl)),
map("emission", 8, rgb(|k| ch(Channel::Emissive, k))),
],
),
// OpenPBR Surface inputs, one map each (maps of channels a set lacks are skipped).
preset("OpenPBR (separate maps)", {
let gray8 = |name: &str, c: Channel| map(name, 8, gray(ch(c, 0)));
let rgb8 = |name: &str, c: Channel| map(name, 8, rgb(|k| ch(c, k)));
vec![
rgb8("base_color", Channel::BaseColor),
gray8("base_metalness", Channel::Metallic),
gray8("specular_roughness", Channel::Roughness),
gray8("specular_roughness_anisotropy", Channel::AnisotropyLevel),
gray8("coat_weight", Channel::CoatWeight),
gray8("coat_roughness", Channel::CoatRoughness),
gray8("fuzz_weight", Channel::SheenWeight),
rgb8("fuzz_color", Channel::SheenColor),
gray8("fuzz_roughness", Channel::SheenRoughness),
gray8("transmission_weight", Channel::Transmission),
gray8("subsurface_weight", Channel::ScatterWeight),
rgb8("emission_color", Channel::Emissive),
gray8("geometry_opacity", Channel::Opacity),
map("geometry_normal", 8, normal(VirtualMap::NormalOpenGl)),
map("height", 16, gray(ch(Channel::Height, 0))),
]
}),
preset("Separate maps", Channel::ALL.into_iter().map(channel_map).collect()),
preset(
"Mesh maps",
+2 -1
View File
@@ -66,7 +66,8 @@ Everything TextureCraft does today, by area. What's still missing is in [`ROADMA
and direction maps, and normal and height maps from high-poly meshes, with a cage, ray distances
and matching by mesh name.
- **Export presets** for glTF PBR Metal Roughness, Unreal Engine (packed), Unity HDRP (mask map),
Unity Standard, Blender (Principled BSDF), separate maps, mesh maps and document channels, in
Unity Standard, Blender (Principled BSDF), Godot 4 (ORM), OpenPBR (with the coat, fuzz,
anisotropy, transmission and subsurface maps), separate maps, mesh maps and document channels, in
PNG, JPEG, TGA, TIFF, BMP, WEBP, EXR or HDR at 8, 16 or 32 bits, with UV padding, size
override and OpenGL or DirectX normals.
- **Output template editor:** build your own presets with per-channel packing and converted maps,