From faf3a1acab69cb5d66e51d80ee4330752e8262aa Mon Sep 17 00:00:00 2001 From: bflatastic Date: Sun, 1 Nov 2026 13:00:12 +0700 Subject: [PATCH] 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 --- crates/formats/README.md | 2 ++ crates/formats/src/export/tests.rs | 10 ++++++++++ crates/formats/src/presets.rs | 31 ++++++++++++++++++++++++++++++ docs/features.md | 3 ++- 4 files changed, 45 insertions(+), 1 deletion(-) diff --git a/crates/formats/README.md b/crates/formats/README.md index e0f2d569..70f8429b 100644 --- a/crates/formats/README.md +++ b/crates/formats/README.md @@ -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 | diff --git a/crates/formats/src/export/tests.rs b/crates/formats/src/export/tests.rs index cbf73dbf..c8c53407 100644 --- a/crates/formats/src/export/tests.rs +++ b/crates/formats/src/export/tests.rs @@ -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::>(); + 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()); diff --git a/crates/formats/src/presets.rs b/crates/formats/src/presets.rs index bb7f8390..c77e665a 100644 --- a/crates/formats/src/presets.rs +++ b/crates/formats/src/presets.rs @@ -145,6 +145,37 @@ pub fn builtin_presets() -> Vec { 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", diff --git a/docs/features.md b/docs/features.md index 013fa9e7..c2511a45 100644 --- a/docs/features.md +++ b/docs/features.md @@ -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,