From 498394a11df40ba1b603736d8babca99537e12f9 Mon Sep 17 00:00:00 2001 From: Rebornim <250083243+Rebornim@users.noreply.github.com> Date: Wed, 25 Nov 2026 01:40:53 +0000 Subject: [PATCH] Export: Redshift Standard Material (separate maps) template, one map per Standard Material input the texture set has, normals in OpenGL as Redshift expects Spec: https://help.maxon.net/r3d/maya/en-us/Content/html/Standard_Material.html and https://help.maxon.net/r3d/maya/en-us/Content/html/Bump+Map.html --- crates/formats/README.md | 1 + crates/formats/src/export/tests.rs | 24 ++++++++++++++++++++++++ crates/formats/src/presets.rs | 20 ++++++++++++++++++++ docs/features.md | 2 +- 4 files changed, 46 insertions(+), 1 deletion(-) diff --git a/crates/formats/README.md b/crates/formats/README.md index 1e7f3bdc..4817d0e8 100644 --- a/crates/formats/README.md +++ b/crates/formats/README.md @@ -139,6 +139,7 @@ Built-in presets (each one lists the public specification its packing follows in | USD Preview Surface (separate maps) | one map per UsdPreviewSurface input the set has, named like it: `diffuseColor`, `emissiveColor`, `metallic`, `roughness`, `normal` (OpenGL), `occlusion`, `opacity`, `clearcoat`, `clearcoatRoughness` | | Unreal Engine Subsurface Profile (Packed) | `BaseColor` (no alpha), `OcclusionRoughnessMetallic`, `Normal` (DirectX), `SubsurfaceMask` (scatter weight, for the Opacity input) | | 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` | | 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 05929b9e..2b6e604e 100644 --- a/crates/formats/src/export/tests.rs +++ b/crates/formats/src/export/tests.rs @@ -1806,3 +1806,27 @@ fn the_gltf_specular_glossiness_template_packs_a_specular_glossiness_sets_own_ch let green = pixel(find(&files, "_Normal.png"))[1]; assert!((green - open_gl_green).abs() <= 1, "OpenGL normal: green {green}"); } + +#[test] +fn the_redshift_template_writes_one_map_per_input_the_set_has() { + let mut channels = default_channels(); + channels.extend([Channel::ScatterWeight, Channel::CoatWeight]); + let mut fx = Fx::new(&channels); + fx.set_all(Channel::Roughness, |_, _| [0.4; 3]); + fx.set_all(Channel::Metallic, |_, _| [0.8; 3]); + fx.set_all(Channel::ScatterWeight, |_, _| [0.7; 3]); + fx.set_all(Channel::CoatWeight, |_, _| [0.2; 3]); + let open_gl_green = tilt_normals(&mut fx); + + let files = fx.render_preset("Redshift Standard Material (separate maps)"); + + let names: Vec<&str> = files.iter().map(|f| f.name.as_str()).collect(); + for (input, expected) in [("Metalness", 0.8), ("ReflectionRoughness", 0.4), ("SubsurfaceWeight", 0.7), ("CoatWeight", 0.2)] { + let file = find(&files, &format!("_{input}.png")); + assert_eq!(decode(file).color(), image::ColorType::L8, "{input} is one 8-bit channel: {names:?}"); + assert_close(pixel(file), [byte(expected), byte(expected), byte(expected), 255], input); + } + let green = pixel(find(&files, "_Normal.png"))[1]; + assert!((green - open_gl_green).abs() <= 1, "OpenGL normal: green {green}"); + assert!(!names.iter().any(|name| name.contains("Sheen") || name.contains("CoatRoughness")), "inputs the set lacks write no maps: {names:?}"); +} diff --git a/crates/formats/src/presets.rs b/crates/formats/src/presets.rs index e1aedf9f..5b870db3 100644 --- a/crates/formats/src/presets.rs +++ b/crates/formats/src/presets.rs @@ -244,6 +244,26 @@ pub fn builtin_presets() -> Vec { map("Emissive", 8, rgb(|k| ch(Channel::Emissive, k))), ], ), + // Spec: https://help.maxon.net/r3d/maya/en-us/Content/html/Standard_Material.html (the Standard Material inputs) + // Spec: https://help.maxon.net/r3d/maya/en-us/Content/html/Bump+Map.html (normal maps in OpenGL format) + preset("Redshift Standard Material (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("BaseColor", Channel::BaseColor), + gray8("Metalness", Channel::Metallic), + gray8("ReflectionRoughness", Channel::Roughness), + map("Normal", 8, normal(VirtualMap::NormalOpenGl)), + rgb8("EmissionColor", Channel::Emissive), + gray8("Opacity", Channel::Opacity), + gray8("SubsurfaceWeight", Channel::ScatterWeight), + gray8("CoatWeight", Channel::CoatWeight), + gray8("CoatRoughness", Channel::CoatRoughness), + gray8("SheenWeight", Channel::SheenWeight), + rgb8("SheenColor", Channel::SheenColor), + gray8("SheenRoughness", Channel::SheenRoughness), + ] + }), 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 fde5812e..facc1ea0 100644 --- a/docs/features.md +++ b/docs/features.md @@ -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), 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, 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.