From 643a085d8e5d893e6c4a0cb048de93c9be66ac87 Mon Sep 17 00:00:00 2001 From: bflatastic Date: Mon, 2 Nov 2026 14:49:14 +0700 Subject: [PATCH 1/3] Fill projection: UV rotation and offset, sharpness, axis and offset A fill's properties showed only its projection and scale, and layer.fill.projection rebuilt the projection from its params, so changing the scale reset a rotation set before and no offset could be set at all. The command now changes only the fields it is given (scale, also per axis; rotation; offset; sharpness; axis) and keeps the rest while the kind stays the same. Properties show the UV rotation and offset, the tri-planar blend sharpness, and the axis and world offset of planar and cylindrical projections. --- crates/engine/src/layer_cmds.rs | 74 ++++++++++++++++++++++++----- crates/engine/src/mask_cmds.rs | 2 +- crates/engine/src/resource_cmds.rs | 2 +- crates/engine/tests/painter_gaps.rs | 41 +++++++++++++++- crates/ui-egui/src/dock.rs | 74 +++++++++++++++++++++++++---- crates/ui-egui/src/i18n/ar.rs | 3 ++ crates/ui-egui/src/i18n/de.rs | 3 ++ crates/ui-egui/src/i18n/es.rs | 3 ++ crates/ui-egui/src/i18n/fr.rs | 3 ++ crates/ui-egui/src/i18n/it.rs | 3 ++ crates/ui-egui/src/i18n/ja.rs | 3 ++ crates/ui-egui/src/i18n/ko.rs | 3 ++ crates/ui-egui/src/i18n/pt_br.rs | 3 ++ crates/ui-egui/src/i18n/zh_hans.rs | 3 ++ docs/features.md | 5 +- 15 files changed, 198 insertions(+), 27 deletions(-) diff --git a/crates/engine/src/layer_cmds.rs b/crates/engine/src/layer_cmds.rs index e7575baf..b992e255 100644 --- a/crates/engine/src/layer_cmds.rs +++ b/crates/engine/src/layer_cmds.rs @@ -34,7 +34,7 @@ pub fn specs() -> Vec { "Set fill projection", [], None, - "{layer? | effect?: content fill effect id, projection: uv|triplanar|planar|spherical|cylindrical, scale?, rotation?, sharpness?, axis?}", + "{layer? | effect?: content fill effect id, projection?: uv|triplanar|planar|spherical|cylindrical (default: the current one), scale?: number | [u, v] (uv), rotation?: degrees (uv), offset?: [u, v] (uv) | [x, y, z] (triplanar, planar), sharpness?: 1..64 (triplanar), axis?: 0|1|2 (planar, cylindrical)} — what is not given keeps its value", has_layer, fill_projection ), @@ -374,23 +374,71 @@ fn fill_set(s: &mut Session, p: &Value) -> Result { Ok(Value::Null) } -pub(crate) fn projection_from(p: &Value, cmd: &str) -> Result { - let scale = f32p(p, "scale").unwrap_or(1.0).clamp(0.001, 1000.0); - Ok(match strp(p, "projection").unwrap_or("uv") { - "uv" => Projection::Uv { scale: [scale, scale], rotation: f32p(p, "rotation").unwrap_or(0.0), offset: [0.0, 0.0] }, - "triplanar" | "tri-planar" => Projection::Triplanar { scale, sharpness: f32p(p, "sharpness").unwrap_or(8.0).clamp(1.0, 64.0), offset: [0.0; 3] }, - "planar" => Projection::Planar { scale, axis: u64p(p, "axis").unwrap_or(2).min(2) as u8, offset: [0.0; 3] }, - "spherical" => Projection::Spherical { scale }, - "cylindrical" => Projection::Cylindrical { scale, axis: u64p(p, "axis").unwrap_or(1).min(2) as u8 }, - other => return Err(bad(cmd, format!("unknown projection `{other}`"))), - }) +/// The projection `p` asks for. Fields it does not give keep their values from `current` when +/// that is of the same kind (or `p` names no kind), and the kind's defaults otherwise. +pub(crate) fn projection_from(p: &Value, cmd: &str, current: Option<&Projection>) -> Result { + let named = match strp(p, "projection") { + None => None, + Some("uv") => Some(Projection::default()), + Some("triplanar" | "tri-planar") => Some(Projection::Triplanar { scale: 1.0, sharpness: 8.0, offset: [0.0; 3] }), + Some("planar") => Some(Projection::Planar { scale: 1.0, axis: 2, offset: [0.0; 3] }), + Some("spherical") => Some(Projection::Spherical { scale: 1.0 }), + Some("cylindrical") => Some(Projection::Cylindrical { scale: 1.0, axis: 1 }), + Some(other) => return Err(bad(cmd, format!("unknown projection `{other}`"))), + }; + let mut proj = match (named, current) { + (Some(n), Some(c)) if std::mem::discriminant(&n) == std::mem::discriminant(c) => c.clone(), + (Some(n), _) => n, + (None, c) => c.cloned().unwrap_or_default(), + }; + let scale = floats::<2>(p, "scale", 0.001, 1000.0); + let axis = u64p(p, "axis").map(|a| a.min(2) as u8); + match &mut proj { + Projection::Uv { scale: s, rotation, offset } => { + *s = scale.unwrap_or(*s); + *rotation = f32p(p, "rotation").map_or(*rotation, |r| r.rem_euclid(360.0)); + *offset = floats(p, "offset", -1000.0, 1000.0).unwrap_or(*offset); + } + Projection::Triplanar { scale: s, sharpness, offset } => { + *s = scale.map_or(*s, |v| v[0]); + *sharpness = f32p(p, "sharpness").map_or(*sharpness, |v| v.clamp(1.0, 64.0)); + *offset = floats(p, "offset", -1000.0, 1000.0).unwrap_or(*offset); + } + Projection::Planar { scale: s, axis: a, offset } => { + *s = scale.map_or(*s, |v| v[0]); + *a = axis.unwrap_or(*a); + *offset = floats(p, "offset", -1000.0, 1000.0).unwrap_or(*offset); + } + Projection::Spherical { scale: s } => *s = scale.map_or(*s, |v| v[0]), + Projection::Cylindrical { scale: s, axis: a } => { + *s = scale.map_or(*s, |v| v[0]); + *a = axis.unwrap_or(*a); + } + Projection::Decal(_) => {} + } + Ok(proj) +} + +/// `key` as `N` finite numbers clamped to `lo..=hi`: an array of `N`, or one number for all. +fn floats(p: &Value, key: &str, lo: f32, hi: f32) -> Option<[f32; N]> { + let one = |x: &Value| x.as_f64().map(|f| f as f32).filter(|f| f.is_finite()).map(|f| f.clamp(lo, hi)); + match p.get(key)? { + Value::Array(a) if a.len() == N => { + let mut out = [0.0; N]; + for (o, x) in out.iter_mut().zip(a) { + *o = one(x)?; + } + Some(out) + } + v => one(v).map(|f| [f; N]), + } } fn fill_projection(s: &mut Session, p: &Value) -> Result { let target = fill_target(s, p, "layer.fill.projection")?; - let proj = projection_from(p, "layer.fill.projection")?; s.edit("Fill projection", |s| { - fill_mut(s, target)?.projection = proj; + let fill = fill_mut(s, target)?; + fill.projection = projection_from(p, "layer.fill.projection", Some(&fill.projection))?; Ok(()) })?; Ok(Value::Null) diff --git a/crates/engine/src/mask_cmds.rs b/crates/engine/src/mask_cmds.rs index 784755c2..2656bd15 100644 --- a/crates/engine/src/mask_cmds.rs +++ b/crates/engine/src/mask_cmds.rs @@ -281,7 +281,7 @@ pub(crate) fn anchor_source(s: &Session, cmd: &str, reader: LayerId, anchor: Lay } fn add_fill(s: &mut Session, p: &Value) -> Result { - let projection = projection_from(p, "effect.add.fill")?; + let projection = projection_from(p, "effect.add.fill", None)?; let blend = blend_param("effect.add.fill", p, "blend")?.unwrap_or(BlendMode::Normal); let id = layer_param(s, "effect.add.fill", p)?; if content_target(p, "effect.add.fill")? { diff --git a/crates/engine/src/resource_cmds.rs b/crates/engine/src/resource_cmds.rs index 3f1d098a..384d3017 100644 --- a/crates/engine/src/resource_cmds.rs +++ b/crates/engine/src/resource_cmds.rs @@ -147,7 +147,7 @@ fn add_image_fill(s: &mut Session, p: &Value) -> Result { return Err(bad("layer.add.image", format!("no resource `{name}`"))); } let ch = channel_param("layer.add.image", p, "channel")?.unwrap_or(Channel::BaseColor); - let projection = if p.get("projection").is_some() { crate::layer_cmds::projection_from(p, "layer.add.image")? } else { Projection::default() }; + let projection = if p.get("projection").is_some() { crate::layer_cmds::projection_from(p, "layer.add.image", None)? } else { Projection::default() }; let ts = s.ts(); let label = std::path::Path::new(&name).file_stem().and_then(|n| n.to_str()).unwrap_or("Image").to_string(); let layer_name = s.doc.project.next_layer_name(ts, &label); diff --git a/crates/engine/tests/painter_gaps.rs b/crates/engine/tests/painter_gaps.rs index f6fbfdc2..428a3666 100644 --- a/crates/engine/tests/painter_gaps.rs +++ b/crates/engine/tests/painter_gaps.rs @@ -1,6 +1,6 @@ //! The filter library, geometry decals, cloning from the selected layer, placing saved smart -//! materials, anchors inside a content stack, instances across texture set resolutions and mesh -//! maps from images, through engine commands. +//! materials, anchors inside a content stack, instances across texture set resolutions, mesh +//! maps from images and fill projection transforms, through engine commands. use serde_json::{Value, json}; use texturecraft_engine::core::{Channel, EffectKind, Filter, LayerId, LayerKind, Projection}; @@ -409,3 +409,40 @@ fn images_fill_mesh_map_slots() { let back = Session::from_project_bytes(&s.to_project_bytes().unwrap()).unwrap(); assert_eq!(back.doc.baked, s.doc.baked); } + +#[test] +fn fill_projection_edits_keep_what_they_do_not_change() { + let mut s = session(); + let layer = id(execute(&mut s, "layer.add.fill", &json!({"color": [0.5, 0.2, 0.1]})).unwrap(), "layer"); + let proj = |s: &Session| match &s.doc.project.layer(layer).unwrap().kind { + LayerKind::Fill(f) => f.projection.clone(), + _ => panic!("a fill layer"), + }; + let set = |s: &mut Session, mut p: Value| { + p["layer"] = json!(layer.0); + execute(s, "layer.fill.projection", &p) + }; + set(&mut s, json!({"rotation": 390, "offset": [0.25, 0.5]})).unwrap(); + set(&mut s, json!({"scale": 2})).unwrap(); + assert_eq!(proj(&s), Projection::Uv { scale: [2.0, 2.0], rotation: 30.0, offset: [0.25, 0.5] }, "a scale keeps the rotation and offset"); + set(&mut s, json!({"projection": "uv", "scale": [2, 3], "offset": "far"})).unwrap(); + assert_eq!(proj(&s), Projection::Uv { scale: [2.0, 3.0], rotation: 30.0, offset: [0.25, 0.5] }, "the same kind keeps its fields; a bad offset is ignored"); + set(&mut s, json!({"projection": "triplanar", "offset": [1, 2, 3]})).unwrap(); + set(&mut s, json!({"sharpness": 100})).unwrap(); + assert_eq!(proj(&s), Projection::Triplanar { scale: 1.0, sharpness: 64.0, offset: [1.0, 2.0, 3.0] }, "a new kind starts from its defaults"); + set(&mut s, json!({"projection": "planar", "axis": 7, "offset": [1e9, 0, 0]})).unwrap(); + assert_eq!(proj(&s), Projection::Planar { scale: 1.0, axis: 2, offset: [1000.0, 0.0, 0.0] }, "hostile values are clamped"); + assert!(set(&mut s, json!({"projection": "hexagonal"})).is_err()); + // The offset moves the pattern: a UV offset changes what the composite shows. + set(&mut s, json!({"projection": "uv", "scale": 1})).unwrap(); + execute( + &mut s, + "layer.fill.set", + &json!({"layer": layer.0, "channel": "baseColor", "procedural": "Checker", "scale": 8, "low": [0, 0, 0], "high": [1, 1, 1]}), + ) + .unwrap(); + let before = at(&mut s, Channel::BaseColor, 200.0, 200.0); + set(&mut s, json!({"offset": [0.125, 0.0]})).unwrap(); + let after = at(&mut s, Channel::BaseColor, 200.0, 200.0); + assert!((before[0] - after[0]).abs() > 0.5, "one checker cell over: {before:?} -> {after:?}"); +} diff --git a/crates/ui-egui/src/dock.rs b/crates/ui-egui/src/dock.rs index 0220bae3..6e8c60c6 100644 --- a/crates/ui-egui/src/dock.rs +++ b/crates/ui-egui/src/dock.rs @@ -1467,7 +1467,9 @@ fn fill_editor(app: &mut TextureCraftApp, ui: &mut Ui, fill: &Fill, base: &Value } } -/// The projection of a fill (other than a decal): kind and scale. +/// The projection of a fill (other than a decal): kind, scale, and what the kind adds (UV +/// rotation and offset, tri-planar sharpness, an axis, a world offset). Each edit sends only the +/// field it changed; the command keeps the others. fn projection_editor(app: &mut TextureCraftApp, ui: &mut Ui, fill: &Fill, base: &Value) { use texturecraft_engine::core::Projection; let proj_label = fill.projection.label(); @@ -1484,17 +1486,73 @@ fn projection_editor(app: &mut TextureCraftApp, ui: &mut Ui, fill: &Fill, base: } } }); - let (mut scale, proj_id) = match &fill.projection { - Projection::Uv { scale, .. } => (scale[0], "uv"), - Projection::Triplanar { scale, .. } => (*scale, "triplanar"), - Projection::Planar { scale, .. } => (*scale, "planar"), - Projection::Spherical { scale } => (*scale, "spherical"), - Projection::Cylindrical { scale, .. } => (*scale, "cylindrical"), + let mut scale = match &fill.projection { + Projection::Uv { scale, .. } => scale[0], + Projection::Triplanar { scale, .. } | Projection::Planar { scale, .. } | Projection::Spherical { scale } | Projection::Cylindrical { scale, .. } => { + *scale + } Projection::Decal(_) => return, }; + let mut edit = |extra: Value| app.run("layer.fill.projection", with(base, extra)); if slider_edit(ui, tr("Scale / tiling"), &mut scale, 0.01..=20.0, 2) { - app.run("layer.fill.projection", with(base, json!({"projection": proj_id, "scale": scale}))); + edit(json!({"scale": scale})); } + match &fill.projection { + Projection::Uv { rotation, offset, .. } => { + let mut r = *rotation; + if slider_edit(ui, tr("Rotation"), &mut r, 0.0..=360.0, 0) { + edit(json!({"rotation": r})); + } + if let Some(o) = offset_sliders(ui, ["U", "V"], *offset) { + edit(json!({"offset": o})); + } + } + Projection::Triplanar { sharpness, offset, .. } => { + let mut s = *sharpness; + if slider_edit(ui, tr("Blend sharpness"), &mut s, 1.0..=64.0, 1) { + edit(json!({"sharpness": s})); + } + if let Some(o) = offset_sliders(ui, ["X", "Y", "Z"], *offset) { + edit(json!({"offset": o})); + } + } + Projection::Planar { axis, offset, .. } => { + if let Some(a) = axis_combo(ui, *axis) { + edit(json!({"axis": a})); + } + if let Some(o) = offset_sliders(ui, ["X", "Y", "Z"], *offset) { + edit(json!({"offset": o})); + } + } + Projection::Cylindrical { axis, .. } => { + if let Some(a) = axis_combo(ui, *axis) { + edit(json!({"axis": a})); + } + } + Projection::Spherical { .. } | Projection::Decal(_) => {} + } +} + +/// A slider per offset component ("Offset U", …): the whole offset once one is edited. +fn offset_sliders(ui: &mut Ui, axes: [&str; N], mut v: [f32; N]) -> Option<[f32; N]> { + let mut done = false; + for (axis, x) in axes.iter().zip(v.iter_mut()) { + done |= slider_edit(ui, &trf("Offset {axis}", &[("axis", axis)]), x, -1.0..=1.0, 2); + } + done.then_some(v) +} + +/// The axis a planar or cylindrical projection runs along: the one picked, if any. +fn axis_combo(ui: &mut Ui, axis: u8) -> Option { + let mut picked = None; + combo(ui, tr("Axis"), ["X", "Y", "Z"].get(usize::from(axis)).copied().unwrap_or("Z"), |ui| { + for (i, name) in (0u8..).zip(["X", "Y", "Z"]) { + if ui.selectable_label(i == axis, name).clicked() && i != axis { + picked = Some(i); + } + } + }); + picked } /// A decal's frame: place it with a click in the 3D view, then size, turn and shift it. diff --git a/crates/ui-egui/src/i18n/ar.rs b/crates/ui-egui/src/i18n/ar.rs index 3b92df48..4a6b740c 100644 --- a/crates/ui-egui/src/i18n/ar.rs +++ b/crates/ui-egui/src/i18n/ar.rs @@ -106,6 +106,7 @@ pub const TABLE: &[(&str, &str)] = &[ "تُحفظ النسخ التلقائية والمواد الذكية والإعدادات المسبقة والقوالب وتخطيطات الواجهة في مجلد البيانات. يُطبَّق المجلد الجديد عند إعادة التشغيل، وتبقى الملفات المحفوظة في مكانها.", ), ("Average normals", "توسيط النواظم"), + ("Axis", "المحور"), ("Back to painting", "العودة إلى الرسم"), ("Backface culling", "استبعاد الوجوه الخلفية"), ("Bake Mesh Maps", "خبز خرائط المجسم"), @@ -129,6 +130,7 @@ pub const TABLE: &[(&str, &str)] = &[ ("Bent normals", "النواظم المنحنية"), ("Bevel", "شطف الحواف"), ("Black", "أسود"), + ("Blend sharpness", "حدة المزج"), ("Blending", "الدمج"), ("Blending mode of the displayed channel", "نمط الدمج للقناة المعروضة"), ("Blur", "تمويه"), @@ -561,6 +563,7 @@ pub const TABLE: &[(&str, &str)] = &[ ("Offset", "إزاحة"), ("Offset right", "إزاحة لليمين"), ("Offset up", "إزاحة لأعلى"), + ("Offset {axis}", "إزاحة {axis}"), ("Offsets the textures by the height channel, at the height to normal strength", "يزيح الخامات وفق قناة الارتفاع، بقوة تحويل الارتفاع إلى ناظم"), ("On", "مفعل"), ("One color per mesh part.", "لون واحد لكل جزء من المجسم."), diff --git a/crates/ui-egui/src/i18n/de.rs b/crates/ui-egui/src/i18n/de.rs index 226b1add..e721489a 100644 --- a/crates/ui-egui/src/i18n/de.rs +++ b/crates/ui-egui/src/i18n/de.rs @@ -109,6 +109,7 @@ pub const TABLE: &[(&str, &str)] = &[ "Automatische Sicherungen, Smart-Materialien, Vorgaben, Vorlagen und UI-Layouts werden im Datenordner gespeichert. Ein neuer Ordner gilt nach einem Neustart; bereits gespeicherte Dateien bleiben, wo sie sind.", ), ("Average normals", "Normalen mitteln"), + ("Axis", "Achse"), ("Back to painting", "Zurück zum Malen"), ("Backface culling", "Rückseiten-Culling"), ("Bake Mesh Maps", "Mesh-Maps backen"), @@ -129,6 +130,7 @@ pub const TABLE: &[(&str, &str)] = &[ ("Bent normals", "Gebogene Normalen"), ("Bevel", "Abschrägung"), ("Black", "Schwarz"), + ("Blend sharpness", "Übergangsschärfe"), ("Blending", "Überblendung"), ("Blending mode of the displayed channel", "Füllmethode des angezeigten Kanals"), ("Blur", "Weichzeichnen"), @@ -591,6 +593,7 @@ pub const TABLE: &[(&str, &str)] = &[ ("Offset", "Versatz"), ("Offset right", "Versatz rechts"), ("Offset up", "Versatz oben"), + ("Offset {axis}", "Versatz {axis}"), ( "Offsets the textures by the height channel, at the height to normal strength", "Verschiebt die Texturen anhand des Höhenkanals, mit der Stärke Höhe zu Normale", diff --git a/crates/ui-egui/src/i18n/es.rs b/crates/ui-egui/src/i18n/es.rs index 228f4b01..f6a60c3a 100644 --- a/crates/ui-egui/src/i18n/es.rs +++ b/crates/ui-egui/src/i18n/es.rs @@ -106,6 +106,7 @@ pub const TABLE: &[(&str, &str)] = &[ "Las copias automáticas, los materiales inteligentes, los ajustes preestablecidos, las plantillas y los diseños de la interfaz se guardan en la carpeta de datos. Una carpeta nueva se aplica al reiniciar; los archivos ya guardados se quedan donde están.", ), ("Average normals", "Promediar normales"), + ("Axis", "Eje"), ("Back to painting", "Volver a pintar"), ("Backface culling", "Descarte de caras traseras"), ("Bake Mesh Maps", "Hornear mapas de malla"), @@ -129,6 +130,7 @@ pub const TABLE: &[(&str, &str)] = &[ ("Bent normals", "Normales curvadas"), ("Bevel", "Bisel"), ("Black", "Negro"), + ("Blend sharpness", "Nitidez de la mezcla"), ("Blending", "Fusión"), ("Blending mode of the displayed channel", "Modo de fusión del canal mostrado"), ("Blur", "Desenfoque"), @@ -582,6 +584,7 @@ pub const TABLE: &[(&str, &str)] = &[ ("Offset", "Desplazamiento"), ("Offset right", "Desplazamiento a la derecha"), ("Offset up", "Desplazamiento hacia arriba"), + ("Offset {axis}", "Desplazamiento {axis}"), ( "Offsets the textures by the height channel, at the height to normal strength", "Desplaza las texturas según el canal de altura, con la intensidad de altura a normal", diff --git a/crates/ui-egui/src/i18n/fr.rs b/crates/ui-egui/src/i18n/fr.rs index 62f6b0a4..627c7797 100644 --- a/crates/ui-egui/src/i18n/fr.rs +++ b/crates/ui-egui/src/i18n/fr.rs @@ -112,6 +112,7 @@ pub const TABLE: &[(&str, &str)] = &[ "Les sauvegardes automatiques, matériaux intelligents, préréglages, modèles et dispositions de l'interface vont dans le dossier de données. Un nouveau dossier s'applique au redémarrage ; les fichiers déjà enregistrés restent où ils sont.", ), ("Average normals", "Moyenne des normales"), + ("Axis", "Axe"), ("Back to painting", "Retour à la peinture"), ("Backface culling", "Élimination des faces arrière"), ("Bake Mesh Maps", "Précalculer les cartes de maillage"), @@ -135,6 +136,7 @@ pub const TABLE: &[(&str, &str)] = &[ ("Bent normals", "Normales déviées"), ("Bevel", "Biseau"), ("Black", "Noir"), + ("Blend sharpness", "Netteté du fondu"), ("Blending", "Fusion"), ("Blending mode of the displayed channel", "Mode de fusion du canal affiché"), ("Blur", "Flou"), @@ -597,6 +599,7 @@ pub const TABLE: &[(&str, &str)] = &[ ("Offset", "Décalage"), ("Offset right", "Décalage vers la droite"), ("Offset up", "Décalage vers le haut"), + ("Offset {axis}", "Décalage {axis}"), ( "Offsets the textures by the height channel, at the height to normal strength", "Décale les textures selon le canal de hauteur, avec l'intensité hauteur vers normale", diff --git a/crates/ui-egui/src/i18n/it.rs b/crates/ui-egui/src/i18n/it.rs index b066abe9..a70525ed 100644 --- a/crates/ui-egui/src/i18n/it.rs +++ b/crates/ui-egui/src/i18n/it.rs @@ -109,6 +109,7 @@ pub const TABLE: &[(&str, &str)] = &[ "Salvataggi automatici, materiali smart, preset, modelli e layout dell'interfaccia vanno nella cartella dei dati. Una nuova cartella si applica al riavvio; i file già salvati restano dove sono.", ), ("Average normals", "Normali medie"), + ("Axis", "Asse"), ("Back to painting", "Torna alla pittura"), ("Backface culling", "Culling facce posteriori"), ("Bake Mesh Maps", "Bake mappe mesh"), @@ -132,6 +133,7 @@ pub const TABLE: &[(&str, &str)] = &[ ("Bent normals", "Bent normal"), ("Bevel", "Smusso"), ("Black", "Nero"), + ("Blend sharpness", "Nitidezza della fusione"), ("Blending", "Fusione"), ("Blending mode of the displayed channel", "Metodo di fusione del canale visualizzato"), ("Blur", "Sfocatura"), @@ -588,6 +590,7 @@ pub const TABLE: &[(&str, &str)] = &[ ("Offset", "Scostamento"), ("Offset right", "Offset a destra"), ("Offset up", "Offset in alto"), + ("Offset {axis}", "Scostamento {axis}"), ( "Offsets the textures by the height channel, at the height to normal strength", "Sposta le texture in base al canale altezza, con l'intensità altezza in normale", diff --git a/crates/ui-egui/src/i18n/ja.rs b/crates/ui-egui/src/i18n/ja.rs index 25f8d534..2691ac1b 100644 --- a/crates/ui-egui/src/i18n/ja.rs +++ b/crates/ui-egui/src/i18n/ja.rs @@ -112,6 +112,7 @@ pub const TABLE: &[(&str, &str)] = &[ "自動保存、スマートマテリアル、プリセット、テンプレート、UI レイアウトはデータフォルダーに保存されます。新しいフォルダーは再起動後に適用され、保存済みのファイルはそのまま残ります。", ), ("Average normals", "法線を平均化"), + ("Axis", "軸"), ("Back to painting", "ペイントに戻る"), ("Backface culling", "背面カリング"), ("Bake Mesh Maps", "メッシュマップのベイク"), @@ -135,6 +136,7 @@ pub const TABLE: &[(&str, &str)] = &[ ("Bent normals", "ベントノーマル"), ("Bevel", "ベベル"), ("Black", "黒"), + ("Blend sharpness", "ブレンドのシャープさ"), ("Blending", "ブレンド"), ("Blending mode of the displayed channel", "表示中のチャンネルのブレンドモード"), ("Blur", "ぼかし"), @@ -576,6 +578,7 @@ pub const TABLE: &[(&str, &str)] = &[ ("Offset", "オフセット"), ("Offset right", "右オフセット"), ("Offset up", "上オフセット"), + ("Offset {axis}", "オフセット {axis}"), ( "Offsets the textures by the height channel, at the height to normal strength", "ハイトチャンネルに応じてテクスチャをオフセットします (強度はハイト→ノーマル強度)", diff --git a/crates/ui-egui/src/i18n/ko.rs b/crates/ui-egui/src/i18n/ko.rs index 8ab4a653..1dc8477d 100644 --- a/crates/ui-egui/src/i18n/ko.rs +++ b/crates/ui-egui/src/i18n/ko.rs @@ -109,6 +109,7 @@ pub const TABLE: &[(&str, &str)] = &[ "자동 저장, 스마트 머티리얼, 프리셋, 템플릿과 UI 레이아웃은 데이터 폴더에 저장됩니다. 새 폴더는 다시 시작하면 적용되며, 이미 저장된 파일은 그대로 남습니다.", ), ("Average normals", "노멀 평균화"), + ("Axis", "축"), ("Back to painting", "페인팅으로 돌아가기"), ("Backface culling", "후면 컬링"), ("Bake Mesh Maps", "메시 맵 베이크"), @@ -129,6 +130,7 @@ pub const TABLE: &[(&str, &str)] = &[ ("Bent normals", "벤트 노멀"), ("Bevel", "베벨"), ("Black", "검은색"), + ("Blend sharpness", "블렌드 선명도"), ("Blending", "블렌딩"), ("Blending mode of the displayed channel", "표시된 채널의 블렌딩 모드"), ("Blur", "블러"), @@ -570,6 +572,7 @@ pub const TABLE: &[(&str, &str)] = &[ ("Offset", "오프셋"), ("Offset right", "오른쪽 오프셋"), ("Offset up", "위쪽 오프셋"), + ("Offset {axis}", "오프셋 {axis}"), ("Offsets the textures by the height channel, at the height to normal strength", "높이-노멀 변환 강도로 높이 채널에 따라 텍스처를 오프셋합니다"), ("On", "켜기"), ("One color per mesh part.", "메시 파트마다 하나의 색상을 사용합니다."), diff --git a/crates/ui-egui/src/i18n/pt_br.rs b/crates/ui-egui/src/i18n/pt_br.rs index 66165a4e..43606323 100644 --- a/crates/ui-egui/src/i18n/pt_br.rs +++ b/crates/ui-egui/src/i18n/pt_br.rs @@ -109,6 +109,7 @@ pub const TABLE: &[(&str, &str)] = &[ "Salvamentos automáticos, materiais inteligentes, predefinições, modelos e layouts da interface vão para a pasta de dados. Uma nova pasta vale após reiniciar; os arquivos já salvos ficam onde estão.", ), ("Average normals", "Normais médias"), + ("Axis", "Eixo"), ("Back to painting", "Voltar à pintura"), ("Backface culling", "Descarte de faces traseiras"), ("Bake Mesh Maps", "Bake de mapas de malha"), @@ -132,6 +133,7 @@ pub const TABLE: &[(&str, &str)] = &[ ("Bent normals", "Normais curvadas"), ("Bevel", "Chanfro"), ("Black", "Preto"), + ("Blend sharpness", "Nitidez da mistura"), ("Blending", "Mesclagem"), ("Blending mode of the displayed channel", "Modo de mesclagem do canal exibido"), ("Blur", "Desfoque"), @@ -579,6 +581,7 @@ pub const TABLE: &[(&str, &str)] = &[ ("Offset", "Deslocamento"), ("Offset right", "Deslocamento à direita"), ("Offset up", "Deslocamento para cima"), + ("Offset {axis}", "Deslocamento {axis}"), ( "Offsets the textures by the height channel, at the height to normal strength", "Desloca as texturas pelo canal de altura, com a intensidade de altura para normal", diff --git a/crates/ui-egui/src/i18n/zh_hans.rs b/crates/ui-egui/src/i18n/zh_hans.rs index 6c28da1d..5e445e0c 100644 --- a/crates/ui-egui/src/i18n/zh_hans.rs +++ b/crates/ui-egui/src/i18n/zh_hans.rs @@ -91,6 +91,7 @@ pub const TABLE: &[(&str, &str)] = &[ "自动保存、智能材质、预设、模板和界面布局都保存在数据文件夹中。新文件夹在重启后生效;已保存的文件保留在原处。", ), ("Average normals", "平均法线"), + ("Axis", "轴"), ("Back to painting", "返回绘画"), ("Backface culling", "背面剔除"), ("Bake Mesh Maps", "烘焙网格贴图"), @@ -111,6 +112,7 @@ pub const TABLE: &[(&str, &str)] = &[ ("Bent normals", "弯曲法线"), ("Bevel", "斜角"), ("Black", "黑色"), + ("Blend sharpness", "混合锐度"), ("Blending", "混合"), ("Blending mode of the displayed channel", "所显示通道的混合模式"), ("Blur", "模糊"), @@ -522,6 +524,7 @@ pub const TABLE: &[(&str, &str)] = &[ ("Offset", "偏移"), ("Offset right", "向右偏移"), ("Offset up", "向上偏移"), + ("Offset {axis}", "偏移 {axis}"), ("Offsets the textures by the height channel, at the height to normal strength", "按高度通道偏移纹理,偏移量取决于高度转法线强度"), ("On", "开"), ("One color per mesh part.", "每个网格部件一种颜色。"), diff --git a/docs/features.md b/docs/features.md index adc76887..edf5ba36 100644 --- a/docs/features.md +++ b/docs/features.md @@ -49,8 +49,9 @@ Everything TextureCraft does today, by area. What's still missing is in [`ROADMA effect selected, Ctrl+D and Delete duplicate or remove it. - **Fill layers** take uniform values, **23 procedurals** (clouds, cells, grunge, scratches, wood grain, bricks, fabric weave, twill, leather grain, marble veins, Voronoi, paint chips…) or your own - **images**, through UV, tri-planar, planar, spherical, cylindrical or decal projection. Each - channel takes its own image (a normal, roughness or height map, say): pick it in the channel's + **images**, through UV, tri-planar, planar, spherical, cylindrical or decal projection, with + the UV scale, rotation and offset, the tri-planar blend sharpness, and the axis and offset of a + planar or cylindrical projection in the fill's properties. Each channel takes its own image (a normal, roughness or height map, say): pick it in the channel's source menu, which also imports one, or drop it from the Assets panel onto the channel. Alt+click a material channel (of a fill or the brush) to keep that channel alone. - **63 materials** (metals from measured reflectance, car paint, brushed anisotropic steel, From 228d879a1d2ac352c95d7d9bb2ef2d0645cd7739 Mon Sep 17 00:00:00 2001 From: bflatastic Date: Mon, 2 Nov 2026 15:40:00 +0700 Subject: [PATCH 2/3] Fill channel image test: scroll the channel into view The projection rows push the Roughness channel below the Properties panel's edge, where a click on its menu button lands outside the panel. The test scrolls the channel into view and waits for the scroll. --- crates/ui-egui/tests/fill_channel_image.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/crates/ui-egui/tests/fill_channel_image.rs b/crates/ui-egui/tests/fill_channel_image.rs index b87a0052..a57a66f6 100644 --- a/crates/ui-egui/tests/fill_channel_image.rs +++ b/crates/ui-egui/tests/fill_channel_image.rs @@ -6,6 +6,11 @@ use serde_json::json; use texturecraft_engine::core::{Channel, LayerId, LayerKind, Source}; use texturecraft_ui_egui::TextureCraftApp; +/// The Roughness channel's name in Properties (the rightmost "Roughness" label). +fn roughness<'a>(h: &'a Harness<'_, TextureCraftApp>) -> egui_kittest::Node<'a> { + h.get_all_by_label("Roughness").max_by(|a, b| a.rect().right().total_cmp(&b.rect().right())).unwrap() +} + #[test] fn a_fill_channel_takes_an_image_from_its_source_menu() { let mut session = texturecraft_engine::sample_session(256, 64).unwrap(); @@ -19,8 +24,11 @@ fn a_fill_channel_takes_an_image_from_its_source_menu() { h.state_mut().ui.prefs.language = "en".into(); h.run_steps(4); - // The source menu button sits in the row of the channel's name. - let row = h.get_all_by_label("Roughness").map(|n| n.rect()).max_by(|a, b| a.right().total_cmp(&b.right())).unwrap().center().y; + // The source menu button sits in the row of the channel's name, scrolled into view first. + roughness(&h).scroll_to_me(); + // The scroll animates for about twenty frames. + h.run_steps(30); + let row = roughness(&h).rect().center().y; let menu = h.get_all_by_label(egui_phosphor::regular::DOTS_THREE).find(|n| (n.rect().center().y - row).abs() < 6.0).unwrap(); menu.click(); h.run_steps(2); From 8657bfdc310975e135e208ef3869831a52d99983 Mon Sep 17 00:00:00 2001 From: bflatastic Date: Mon, 2 Nov 2026 15:59:26 +0700 Subject: [PATCH 3/3] Image fills take a projection's fields without naming it; docs wording layer.add.image read the projection params only when `projection` was given, so an offset or rotation alone was dropped. The features list no longer promises a cylindrical offset. --- crates/engine/src/resource_cmds.rs | 4 ++-- docs/features.md | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/engine/src/resource_cmds.rs b/crates/engine/src/resource_cmds.rs index 5a00be85..ad1c52ae 100644 --- a/crates/engine/src/resource_cmds.rs +++ b/crates/engine/src/resource_cmds.rs @@ -5,7 +5,7 @@ use std::sync::Arc; use serde_json::{Value, json}; use texturecraft_compose::ImageRes; -use texturecraft_core::{Channel, Fill, Layer, LayerKind, Projection, Source}; +use texturecraft_core::{Channel, Fill, Layer, LayerKind, Source}; use crate::commands::{CommandSpec, always, bad, channel_param, strp}; use crate::{EngineError, Result, Session, cmd}; @@ -153,7 +153,7 @@ fn add_image_fill(s: &mut Session, p: &Value) -> Result { return Err(bad("layer.add.image", format!("no resource `{name}`"))); } let ch = channel_param("layer.add.image", p, "channel")?.unwrap_or(Channel::BaseColor); - let projection = if p.get("projection").is_some() { crate::layer_cmds::projection_from(p, "layer.add.image", None)? } else { Projection::default() }; + let projection = crate::layer_cmds::projection_from(p, "layer.add.image", None)?; let ts = s.ts(); let label = std::path::Path::new(&name).file_stem().and_then(|n| n.to_str()).unwrap_or("Image").to_string(); let layer_name = s.doc.project.next_layer_name(ts, &label); diff --git a/docs/features.md b/docs/features.md index 7bcaf924..dc28038a 100644 --- a/docs/features.md +++ b/docs/features.md @@ -50,8 +50,8 @@ Everything TextureCraft does today, by area. What's still missing is in [`ROADMA - **Fill layers** take uniform values, **23 procedurals** (clouds, cells, grunge, scratches, wood grain, bricks, fabric weave, twill, leather grain, marble veins, Voronoi, paint chips…) or your own **images**, through UV, tri-planar, planar, spherical, cylindrical or decal projection, with - the UV scale, rotation and offset, the tri-planar blend sharpness, and the axis and offset of a - planar or cylindrical projection in the fill's properties. Each channel takes its own image (a normal, roughness or height map, say): pick it in the channel's + the UV scale, rotation and offset, the tri-planar blend sharpness and offset, the planar axis + and offset, and the cylindrical axis in the fill's properties. Each channel takes its own image (a normal, roughness or height map, say): pick it in the channel's source menu, which also imports one, or drop it from the Assets panel onto the channel. Alt+click a material channel (of a fill or the brush) to keep that channel alone. - **63 materials** (metals from measured reflectance, car paint, brushed anisotropic steel,