Free, open-source 3D sculpting for Linux, macOS and Windows: dense meshes, remeshing, painting, built-in AI (image/text to 3D), Send to Unreal, game-ready LODs, Gaussian splats and OpenUSD.
C++ 3d3d-sculptingcppdear-imguidigital-sculptingfbxgame-developmentgaussian-splattinggltfimage-to-3dmcpopenglopenusdsculptingtext-to-3dunreal-engine
A flat viewport background (#21); Extract TCorne and TBorder
islandmed76a9f8457bc4
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 136025cc..d8d5142d 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -7,8 +7,9 @@ All notable changes to SculptForge are listed here. The format follows## [Unreleased]### Added-- Extract (Tool > SubTool > Extract), as in ZBrush: the masked, visible part of a SubTool becomes a shell with Thick (a share of the SubTool's size; negative grows inward, 0 makes a single-sided surface), E Smt (smooths the stepped edge) and Double (both ways). Extract shows a preview below the source that follows the settings; Accept keeps it as a new SubTool with outer, inner and rim polygroups and the source's polypaint, as one undo step (undo removes the SubTool, redo puts it back). An unaccepted preview goes when the source changes and is never saved. Commands: extract, extract_accept, extract_cancel.+- Extract (Tool > SubTool > Extract), as in ZBrush: the masked, visible part of a SubTool becomes a shell with Thick (a share of the SubTool's size; negative grows inward, 0 makes a single-sided surface), E Smt (smooths the stepped edge) and Double (both ways). Extract shows a preview below the source that follows the settings; Accept keeps it as a new SubTool with outer, inner and rim polygroups and the source's polypaint, as one undo step (undo removes the SubTool, redo puts it back). TCorne and TBorder make the rim triangles instead of quads at sharp corners or all along it. An unaccepted preview goes when the source changes and is never saved. Commands: extract, extract_accept, extract_cancel.- Mirror And Weld (Tool > Geometry > Modify Topology, X / Y / Z): keeps the + side of the plane through the origin, cuts polygons crossing it, mirrors the half and welds the seam into one watertight mesh, keeping polygroups, polypaint, mask, UVs, quads and sculpt layers (`mirror_and_weld`, with `side=negative` for the other half). Undoable.+- A flat viewport background (#21): Preferences > Display > Background (also in the Render palette) switches between the gradient (the default) and Flat Colour with a colour picker. Store Config keeps it, projects keep their own, and `set_background` (mode, color) scripts it.- Mirror (Tool > Deformation, X / Y / Z): flips the SubTool across the plane through the origin, or in place with `pivot=center` (`mirror`). Undoable.## [0.9.5] - 2026-10-31diff --git a/docs/guide/interface.md b/docs/guide/interface.mdindex 44fb0ed9..7e6643c4 100644--- a/docs/guide/interface.md+++ b/docs/guide/interface.md@@ -63,8 +63,8 @@ Interface > Palettes strictly A-Z (ZBrush order)**.| **Draw** | Draw Size, Z Intensity, RGB Intensity, Focal Shift, Sculpt/Paint, Zadd/Zsub, Rgb, Front, and the tablet options (Pressure > strength, Pressure > size) with a pen readout || **Generate** | Generate 3D (image or text to 3D), Relief, Inflate and Stamp from an image, and the AI brush provider settings || **Material** | The MatCap materials (Soft Clay, the default, first), your own (**Load MatCap...**) and Studio, Base colour, Smooth / Flat shading for the scene and the active SubTool |-| **Preferences** | Config, Interface, Input, Hotkeys, LightBox, Tablet, Performance, Updates and Autosave sub-palettes (see [Customizing the interface](#customizing-the-interface)) |-| **Render** | Wireframe, Show Mesh, Show Polypaint, Show Mask, Show Polygroups, Show Splats, Frame, Fullscreen |+| **Preferences** | Config, Interface, Input, Hotkeys, Display, LightBox, Tablet, Performance, Updates and Autosave sub-palettes (see [Customizing the interface](#customizing-the-interface)) |+| **Render** | Wireframe, Show Mesh, Show Polypaint, Show Mask, Show Polygroups, Show Splats, Background, Frame, Fullscreen || **Script** | Console, Run script file, Copy session as script, Clear console || **Splats** | Gaussian splat tools: show, flip, turn, fit, clean floaters, Make sculptable, sculpt to splats, save, clear || **Stroke** | The stroke types (Dots, DragRect, Spray, LazyMouse) and their settings |@@ -440,6 +440,17 @@ style, **Emulate Numpad** makes the number row work as the numpad, and **Importfrom a keymap you exported in Blender. **Rotation** chooses free rotation (ZBrush) or a turntable. See[Coming from ZBrush](coming-from-zbrush.md).+### The background++**Preferences > Display** (and the **Render** palette) sets the view's **Background**: **Gradient**, the+charcoal radial gradient (the default), or **Flat Colour**, one solid colour without the gradient. Click the+**Background colour** swatch to pick the colour; picking one switches to Flat Colour. **Store Config** keeps the+choice for the next session, and each project keeps the background it was saved with. From a script:+`set_background mode=flat`, `set_background color=60,70,80` or `set_background mode=gradient`.++> **ZBrush:** like turning the gradient off in the Document palette (**Range** 0) and choosing the **Back**+> colour.+**Preferences > LightBox** has **Show at startup** (on by default), the number of **Rows**, **Placement**(along the top of the canvas, or at the bottom above the bottom shelf) and the **Library folder**.**Preferences > Autosave** sets how often a recovery copy is saved (see [Projects, autosave anddiff --git a/docs/guide/polypaint.md b/docs/guide/polypaint.mdindex 20f19b28..1e23f1a8 100644--- a/docs/guide/polypaint.md+++ b/docs/guide/polypaint.md@@ -250,6 +250,7 @@ ZBrush key changes meaning; assign one under **Preferences > Hotkeys** if you sw| `set_material name=Chrome` | Viewport material: a MatCap name (`Soft Clay` is the default, your own MatCaps included) or `studio` (desktop app only) || `load_matcap path=gold.png` | Load a MatCap image and use it; `keep=false` doesn't copy it into the MatCaps folder (desktop app only) || `remove_matcap name=Gold` | Remove one of your MatCaps; its image in the MatCaps folder goes to the trash (desktop app only) |+| `set_background mode=flat color=60,70,80` | The view's background: `gradient` (the default) or `flat` with a colour (`#rrggbb`, `r,g,b` or a name); see [The background](interface.md#the-background) (desktop app only) || `set_shading mode=flat` | The scene's shading: `smooth` (the default) or `flat` (desktop app only) || `subtool_shading mode=smooth name=Eyes` | A SubTool's own shading: `default` (follow the scene), `smooth` or `flat`; `index` or `name` picks the SubTool (default: the active one) |diff --git a/docs/guide/subtools.md b/docs/guide/subtools.mdindex ba84021e..8487e1b3 100644--- a/docs/guide/subtools.md+++ b/docs/guide/subtools.md@@ -119,13 +119,15 @@ top of a head, a strap, a sleeve, a piece of armour that fits the surface exactl1. Mask the part (hold <kbd>Ctrl</kbd> and paint, or use **MaskRect** / **MaskLasso**; see [Masking](masking.md)).2. Click **Extract**. The shell appears as a preview, a SubTool just below the active one.-3. Change **Thick**, **E Smt** or **Double** and the preview follows. Click **Accept** to keep it.+3. Change **Thick**, **E Smt**, **Double**, **TCorne** or **TBorder** and the preview follows. Click **Accept** to keep it.| Setting | What it does ||---|---|| **Thick** | The shell's thickness as a share of the SubTool's size: 0.015 (the default) is 1.5%. Negative grows it inward; 0 makes a single-sided surface || **E Smt** | Smooths the extracted edge, which otherwise follows the mask's triangles in steps. 0 keeps it as masked || **Double** | Grows the shell both inward and outward from the surface |+| **TCorne** | Triangles instead of quads in the rim where the edge turns sharply (over 50 degrees), so tight corners don't get twisted quads |+| **TBorder** | The whole rim is triangles instead of quads |@@ -135,8 +137,7 @@ Accept is one undo step: <kbd>Ctrl</kbd>+<kbd>Z</kbd> on the source SubTool takeand redo brings it back. A preview you don't accept goes away as soon as you change the source SubTool or pickanother one, and it is never saved.-> **ZBrush:** the same Extract, E Smt, Thick, Double and Accept. ZBrush's TCorne and TBorder options are not-> there yet.+> **ZBrush:** the same Extract, E Smt, Thick, Double, TCorne, TBorder and Accept.## Delete a SubTool@@ -177,7 +178,7 @@ used.| `subtool_move direction=up` | Move a SubTool up or down the list || `subtool_merge_down` / `subtool_merge_visible` | Merge || `subtool_split_groups` / `subtool_split_parts` | Split |-| `extract thickness=0.02 smooth=5 double=false` | Preview an Extract shell from the mask; `accept=true` keeps it at once |+| `extract thickness=0.02 smooth=5 double=false` | Preview an Extract shell from the mask; `tcorne` / `tborder` for a triangle rim; `accept=true` keeps it at once || `extract_accept` / `extract_cancel` | Keep or remove the Extract preview |```textdiff --git a/docs/guide/whats-new.md b/docs/guide/whats-new.mdindex d2e7fb73..e8bfc54f 100644--- a/docs/guide/whats-new.md+++ b/docs/guide/whats-new.md@@ -11,8 +11,8 @@ chapter opens by itself the first time you start a new version; you can always fMask part of a SubTool and **Tool > SubTool > Extract** turns it into a shell that fits the surface exactly: ahelmet, a strap, a piece of armour. Set **Thick**, **E Smt** and **Double** while the preview shows, then-**Accept** keeps it as a new SubTool (and <kbd>Ctrl</kbd>+<kbd>Z</kbd> takes it away again). See-[Extract a shell](subtools.md#extract-a-shell).+**Accept** keeps it as a new SubTool (and <kbd>Ctrl</kbd>+<kbd>Z</kbd> takes it away again). **TCorne** and+**TBorder** give the rim triangles instead of quads. See [Extract a shell](subtools.md#extract-a-shell).### Mirror And Weld@@ -20,6 +20,12 @@ helmet, a strap, a piece of armour. Set **Thick**, **E Smt** and **Double** whilor Z and welds the seam into one watertight mesh, keeping polygroups and polypaint. **Tool > Deformation >Mirror** flips a SubTool. See [Mirror And Weld](geometry.md#mirror-and-weld).+### A flat background++**Preferences > Display > Background** (also in the Render palette) switches the view from the gradient to a+flat colour you pick. Store Config keeps it, and projects keep their own. See+[The background](interface.md#the-background).+## Version 0.9.5### ZSpheresdiff --git a/src/app/App.h b/src/app/App.hindex 96508499..98f53952 100644--- a/src/app/App.h+++ b/src/app/App.h@@ -456,6 +456,9 @@ private:std::set<std::string> hiddenMatcapFiles_; // removed MatCaps whose file couldn't go to the trashint materialListFrame_ = -10;void setFlatShading(bool flat); // the scene's shading, and the preference for the next session+ // The view's background (#21): gradient or a flat display colour; also the preference for the next session.+ void setBackground(bool gradient, const glm::vec3& color);+ void drawBackgroundControls(const char* idSuffix); // Preferences > Display and the Render palettevoid drawShadingControls(); // Material palette and Tool > Display: Smooth | Flat, and the SubTool's ownvoid paintAt(const DabParams& p);void pickColorUnderCursor();@@ -877,6 +880,8 @@ private:float extractThick_ = 0.015f; // Thick: fraction of the SubTool's sizeint extractSmooth_ = 5; // E Smtbool extractDouble_ = false; // Double+ bool extractTCorne_ = false; // TCorne+ bool extractTBorder_ = false; // TBorderbool mirrorWeldAxes_[3] = {true, false, false}; // Mirror And Weld's X Y Zbool mirrorAxes_[3] = {true, false, false}; // Deformation > Mirror's X Y Zvoid pollAlphaFile();diff --git a/src/app/Config.cpp b/src/app/Config.cppindex a379facb..a23cc527 100644--- a/src/app/Config.cpp+++ b/src/app/Config.cpp@@ -56,6 +56,10 @@ Json toJson(const UiPrefs& p) {j.set("multithreading", p.multithreading);j.set("dyntopoConstantDetail", p.dyntopoConstantDetail);j.set("flatShading", p.flatShading);+ j.set("background", std::string(p.gradientBackground ? "gradient" : "flat"));+ Json bg = Json::array();+ for (int i = 0; i < 3; ++i) bg.push(double(p.backgroundColor[i]));+ j.set("backgroundColor", std::move(bg));return j;}@@ -86,6 +90,9 @@ void fromJson(const Json& j, UiPrefs& p) {p.multithreading = j["multithreading"].asBool(p.multithreading);p.dyntopoConstantDetail = j["dyntopoConstantDetail"].asBool(p.dyntopoConstantDetail);p.flatShading = j["flatShading"].asBool(p.flatShading);+ if (j["background"].isString()) p.gradientBackground = j["background"].asString() != "flat";+ if (const Json& bg = j["backgroundColor"]; bg.size() == 3)+ for (int i = 0; i < 3; ++i) p.backgroundColor[i] = std::clamp(float(bg[size_t(i)].asNumber(p.backgroundColor[i])), 0.0f, 1.0f);}namespace {@@ -276,6 +283,20 @@ void App::initActions() {},nullptr, nullptr, [this] { return extractDouble_; }, nullptr,"Grow the extracted shell both inward and outward from the surface, instead of outward only.");+ add("subtool.extract_tcorne", "TCorne", "Tool > SubTool", nullptr,+ [this] {+ extractTCorne_ = !extractTCorne_;+ if (doc_.extractPreviewCurrent()) runExtract();+ },+ nullptr, nullptr, [this] { return extractTCorne_; }, nullptr,+ "Triangle corners: where the extracted edge turns sharply, the rim is made of triangles instead of quads.");+ add("subtool.extract_tborder", "TBorder", "Tool > SubTool", nullptr,+ [this] {+ extractTBorder_ = !extractTBorder_;+ if (doc_.extractPreviewCurrent()) runExtract();+ },+ nullptr, nullptr, [this] { return extractTBorder_; }, nullptr,+ "Triangle border: the whole rim of the extracted shell is made of triangles instead of quads.");add("geometry.mirror_weld", "Mirror And Weld", "Tool > Geometry", nullptr,[this] { runCommand("mirror_and_weld", {{"axis", axesText(mirrorWeldAxes_)}}); }, nullptr, "mirror_and_weld",nullptr, [this] { return !axesText(mirrorWeldAxes_).empty() && doc_.mesh.triangleCount() > 0; },@@ -515,6 +536,8 @@ bool App::readUiConfig(const std::string& path, std::string& err) {applyInputStyle();doc_.sculptor.dyntopo.constantDetail = uiPrefs_.dyntopoConstantDetail;renderSettings_.flatShading = uiPrefs_.flatShading;+ renderSettings_.gradientBackground = uiPrefs_.gradientBackground;+ renderSettings_.backgroundColor = uiPrefs_.backgroundColor;return true;}diff --git a/src/app/Config.h b/src/app/Config.hindex 636b4983..f9b184da 100644--- a/src/app/Config.h+++ b/src/app/Config.h@@ -43,6 +43,9 @@ struct UiPrefs {// true = one detail size for the whole mesh.bool dyntopoConstantDetail = false;bool flatShading = false; // Material palette: the scene's shading at startup (false = Smooth, the default)+ // Preferences > Display: the view's background (#21), a gradient or a flat display (sRGB) colour.+ bool gradientBackground = true;+ glm::vec3 backgroundColor{0.165f, 0.165f, 0.173f};};Json toJson(const UiPrefs& prefs);diff --git a/src/app/Palettes.cpp b/src/app/Palettes.cppindex f7a7df36..d7e6bb18 100644--- a/src/app/Palettes.cpp+++ b/src/app/Palettes.cpp@@ -414,6 +414,10 @@ void App::drawPalette_Preferences() {tray::Section section;config::drawHotkeysSection(*this);}+ if (subpalette("preferences.display", "Display")) {+ tray::Section section;+ drawBackgroundControls("prefs");+ }if (subpalette("preferences.lightbox", "LightBox")) {tray::Section section;config::drawLightBoxSection(*this);@@ -456,6 +460,7 @@ void App::drawPalette_Render() {ImGui::Checkbox("Show Splats", &renderSettings_.showSplats);ImGui::EndDisabled();ui::HelpAction(*this, "view.splats");+ drawBackgroundControls("render");actionRow(*this, {"view.frame", "view.fullscreen"});}diff --git a/src/app/PanelExtract.cpp b/src/app/PanelExtract.cppindex da92039d..9864e256 100644--- a/src/app/PanelExtract.cpp+++ b/src/app/PanelExtract.cpp@@ -20,7 +20,11 @@ std::string App::axesText(const bool axes[3]) {}void App::runExtract() {- runCommand("extract", {{"thickness", double(extractThick_)}, {"smooth", double(extractSmooth_)}, {"double", extractDouble_}});+ runCommand("extract", {{"thickness", double(extractThick_)},+ {"smooth", double(extractSmooth_)},+ {"double", extractDouble_},+ {"tcorne", extractTCorne_},+ {"tborder", extractTBorder_}});}void App::drawExtractContents() {@@ -51,6 +55,8 @@ void App::drawExtractContents() {"Tool > SubTool > Extract");ui::ActionButton(*this, "subtool.extract_double", ImVec2(half, 0));ui::HelpAction(*this, "subtool.extract_double");+ ImGui::SameLine();+ ui::Segmented(*this, {"subtool.extract_tcorne", "subtool.extract_tborder"}, -1.0f);if (changed && doc_.extractPreviewCurrent()) runExtract();Demo::popScope();}diff --git a/src/app/PanelPolypaint.cpp b/src/app/PanelPolypaint.cppindex 3a48a5e0..ca1b12f0 100644--- a/src/app/PanelPolypaint.cpp+++ b/src/app/PanelPolypaint.cpp@@ -165,6 +165,29 @@ void App::registerPaintUiCommands() {return {true, "Removed " + shown + " for this session; delete " + path +" to remove it for good (" + err + ")"};}});+ // The view's background (#21). Also the preference for new sessions.+ commands_.add({"set_background",+ "The viewport background: gradient (the default charcoal radial gradient) or flat, one solid "+ "colour.",+ {{"mode", ParamSpec::Type::String, "gradient or flat (default: flat when a color is given).", false},+ {"color", ParamSpec::Type::String,+ "The flat colour: #rrggbb, r,g,b (0-1 or 0-255) or a name such as black or gray.", false}},+ [this](Document&, const Args& a) -> CommandResult {+ if (!a.contains("mode") && !a.contains("color")) return {false, "Give mode= or color="};+ glm::vec3 color = renderSettings_.backgroundColor;+ if (a.contains("color")) {+ glm::vec3 linear;+ if (!parseColor(argString(a, "color"), linear))+ return {false, "Bad colour '" + argString(a, "color") + "'"};+ color = linearToSrgb(linear); // the background is drawn in display values+ }+ const std::string mode = argString(a, "mode", a.contains("color") ? "flat" : "");+ if (mode != "gradient" && mode != "flat")+ return {false, "Unknown background '" + mode + "' (gradient, flat)"};+ setBackground(mode == "gradient", color);+ return {true, mode == "gradient" ? std::string("Background: Gradient")+ : "Background: Flat Colour " + colorToHex(srgbToLinear(color))};+ }});// The scene's shading; SubTools can override it (subtool_shading). Also the preference for new sessions.commands_.add({"set_shading","Viewport shading for every SubTool that doesn't set its own (subtool_shading): smooth (the "@@ -179,6 +202,24 @@ void App::registerPaintUiCommands() {}});}+void App::setBackground(bool gradient, const glm::vec3& color) {+ renderSettings_.gradientBackground = uiPrefs_.gradientBackground = gradient;+ renderSettings_.backgroundColor = uiPrefs_.backgroundColor = glm::clamp(color, 0.0f, 1.0f);+}++void App::drawBackgroundControls(const char* idSuffix) {+ ImGui::TextDisabled("Background");+ ui::Segmented(*this, {"view.background_gradient", "view.background_flat"});+ // The picker edits the flat colour as shown (display values); picking one switches to Flat Colour.+ glm::vec3 c = renderSettings_.backgroundColor;+ const std::string label = std::string("Background colour##") + idSuffix;+ if (ImGui::ColorEdit3(label.c_str(), &c.x, ImGuiColorEditFlags_NoInputs)) setBackground(false, c);+ ui::HelpText("Background colour", nullptr,+ "The view's flat background colour. Choosing one switches the background to Flat Colour. Store "+ "Config keeps it for the next session; projects keep their own.",+ "Preferences > Display");+}+void App::setFlatShading(bool flat) {renderSettings_.flatShading = flat;uiPrefs_.flatShading = flat; // the default for the next session (Store Config keeps it)diff --git a/src/app/PanelProject.cpp b/src/app/PanelProject.cppindex 129a6ea8..4da83293 100644--- a/src/app/PanelProject.cpp+++ b/src/app/PanelProject.cpp@@ -226,6 +226,8 @@ void App::storeProjectSettings() {render.set("show_splats", renderSettings_.showSplats);render.set("splat_opacity", double(renderSettings_.splatOpacity));render.set("flat_shading", renderSettings_.flatShading);+ render.set("background", std::string(renderSettings_.gradientBackground ? "gradient" : "flat"));+ render.set("background_color", vec3Json(renderSettings_.backgroundColor));render.set("matcap", renderSettings_.matcap < 0 ? std::string() : std::string(matcapName(renderSettings_.matcap)));// A custom MatCap travels inside the project (a PNG attachment), so the project opens with it on any machine.for (auto it = doc_.projectFiles.begin(); it != doc_.projectFiles.end();)@@ -297,6 +299,12 @@ void App::applyProjectSettings() {readFloat(r, "splat_opacity", renderSettings_.splatOpacity);// Projects from before the setting: the preferred shading.renderSettings_.flatShading = r["flat_shading"].asBool(uiPrefs_.flatShading);+ // The background (#21); projects from before it: the preferred one.+ renderSettings_.gradientBackground =+ r["background"].isString() ? r["background"].asString() != "flat" : uiPrefs_.gradientBackground;+ renderSettings_.backgroundColor = uiPrefs_.backgroundColor;+ readVec3(r["background_color"], renderSettings_.backgroundColor);+ renderSettings_.backgroundColor = glm::clamp(renderSettings_.backgroundColor, 0.0f, 1.0f);// Unknown, empty or missing (projects from before MatCaps): studio lighting, as they were saved.renderSettings_.matcap = -1;const std::string name = r["matcap"].isString() ? r["matcap"].asString() : std::string();diff --git a/src/app/Shell.cpp b/src/app/Shell.cppindex 1a81b2e3..fe5049e8 100644--- a/src/app/Shell.cpp+++ b/src/app/Shell.cpp@@ -377,6 +377,17 @@ void App::registerShellActions() {"clearly (as in ZBrush). SubTools set to Smooth or Flat keep their own. A preference: Store Config keeps it.","Material", "", "", [this] { runCommand("set_shading", {{"mode", std::string("flat")}}); },[this] { return renderSettings_.flatShading; }, nullptr});+ // The view's background (#21; Preferences > Display, Render palette).+ add({"view.background_gradient", "Gradient", nullptr,+ "The view's background is the charcoal radial gradient (the default).", "Preferences > Display", "",+ "set_background", [this] { runCommand("set_background", {{"mode", std::string("gradient")}}); },+ [this] { return renderSettings_.gradientBackground; }, nullptr});+ add({"view.background_flat", "Flat Colour", nullptr,+ "The view's background is one solid colour (pick it below), without the gradient. A preference: Store "+ "Config keeps it; projects keep their own.",+ "Preferences > Display", "", "set_background",+ [this] { runCommand("set_background", {{"mode", std::string("flat")}}); },+ [this] { return !renderSettings_.gradientBackground; }, nullptr});auto subtoolShading = [this, &add](const char* id, const char* label, Shading mode, const char* description) {add({id, label, nullptr, description, "Material > This SubTool", "", "subtool_shading",[this, mode] { runCommand("subtool_shading", {{"mode", std::string(shadingName(mode))}}); },diff --git a/src/app/Ui.cpp b/src/app/Ui.cppindex aacc2383..31bf5e6a 100644--- a/src/app/Ui.cpp+++ b/src/app/Ui.cpp@@ -117,6 +117,7 @@ bool IsModeAction(std::string_view id) {bool IsChoiceAction(std::string_view id) {return id == "draw.zadd" || id == "draw.zsub" || id == "material.smooth" || id == "material.flat" ||+ id == "view.background_gradient" || id == "view.background_flat" ||id.substr(0, 16) == "subtool.shading_";}diff --git a/src/app/UiTest.cpp b/src/app/UiTest.cppindex 43dc15e6..956aeae7 100644--- a/src/app/UiTest.cpp+++ b/src/app/UiTest.cpp@@ -51,7 +51,8 @@// hold alt to select it); U V: fractions of its on-screen bounds// expect_value NAME OP N triangles, vertices, layers, brushes, masked, hidden, groups, colored,// can_undo, dirty, splats, show_polygroups, show_mask, show_mesh, wireframe,-// flat_shading (the scene's: 1 Flat), subtool_shading (0 Scene, 1 Smooth, 2 Flat),+// flat_shading (the scene's: 1 Flat), gradient_background (1 Gradient, 0 Flat Colour),+// background_r / background_g / background_b (the flat colour, 0-255), subtool_shading (0 Scene, 1 Smooth, 2 Flat),// custom_matcaps (MatCaps loaded from images), material_custom (1 when the view uses// one), matcap_files (images in the library's MatCaps folder),// subtools (count), active_subtool (index, 0 = top), visible_subtools,@@ -463,6 +464,9 @@ double Demo::query(const std::string& name, bool& known) const {return double(n);}if (name == "flat_shading") return app_.renderSettings_.flatShading ? 1.0 : 0.0;+ if (name == "gradient_background") return app_.renderSettings_.gradientBackground ? 1.0 : 0.0;+ if (name == "background_r" || name == "background_g" || name == "background_b") // 0-255, display values+ return std::round(app_.renderSettings_.backgroundColor[name.back() == 'r' ? 0 : name.back() == 'g' ? 1 : 2] * 255.0f);if (name == "subtool_shading") return double(int(app_.doc_.activeSubtoolInfo().shading));if (name == "shelves") return app_.layout_.shelvesVisible ? 1.0 : 0.0;if (name == "left_tray") return app_.layout_.leftTrayOpen ? double(app_.layout_.leftTray.size()) : -1.0;diff --git a/src/core/ExtractMirror.cpp b/src/core/ExtractMirror.cppindex 24c89bd5..ff1b3342 100644--- a/src/core/ExtractMirror.cpp+++ b/src/core/ExtractMirror.cpp@@ -153,13 +153,31 @@ Mesh extractShell(const Mesh& mesh, const ExtractOptions& o, std::string& error)// The inner surface faces the other way; the rim joins the two along the patch's edge, one quad per edge.for (const glm::uvec3& c : tris) out.triangles.push_back(glm::uvec3(c.x + np, c.z + np, c.y + np));out.polygroups.resize(out.triangles.size(), 2u);+ // TCorne: where the edge turns sharply (over 50 degrees) the rim keeps triangles; TBorder: all along it.+ std::vector<uint8_t> corner(o.triangleCorners && !o.triangleBorder ? np : 0, 0);+ if (!corner.empty()) {+ std::vector<uint32_t> next(np, kNone), prev(np, kNone);+ std::vector<uint8_t> uses(np, 0);+ for (const auto& [u, v] : boundary) {+ next[u] = v;+ prev[v] = u;+ ++uses[u];+ }+ const float cosLimit = std::cos(glm::radians(50.0f));+ for (uint32_t v = 0; v < np; ++v) {+ if (next[v] == kNone || prev[v] == kNone) continue;+ const glm::vec3 a = p[v] - p[prev[v]], b = p[next[v]] - p[v];+ const float la = glm::length(a), lb = glm::length(b);+ corner[v] = uses[v] > 1 || (la > 0.0f && lb > 0.0f && glm::dot(a, b) < cosLimit * la * lb);+ }+ }for (const auto& [u, v] : boundary) {const uint32_t first = uint32_t(out.triangles.size());out.triangles.push_back(glm::uvec3(v, u, u + np));out.triangles.push_back(glm::uvec3(v, u + np, v + np));out.polygroups.push_back(3u);out.polygroups.push_back(3u);- out.pairQuad(first, first + 1);+ if (!o.triangleBorder && (corner.empty() || (!corner[u] && !corner[v]))) out.pairQuad(first, first + 1);}}// Quads of the source stay quads on both surfaces.@@ -402,6 +420,8 @@ CommandResult runExtract(Document& doc, const Args& a) {o.thickness = std::clamp(float(argNumber(a, "thickness", o.thickness)), -1.0f, 1.0f);o.smooth = std::clamp(int(std::lround(argNumber(a, "smooth", o.smooth))), 0, 50);o.doubleSided = argBool(a, "double", false);+ o.triangleCorners = argBool(a, "tcorne", false);+ o.triangleBorder = argBool(a, "tborder", false);std::string error;Mesh shell = extractShell(doc.mesh, o, error);if (shell.triangleCount() == 0) {@@ -437,6 +457,8 @@ void registerExtractMirrorCommands(CommandRegistry& reg) {false},{"smooth", T::Number, "E Smt: smoothing passes along the extracted edge (0-50, default 5).", false},{"double", T::Bool, "Double: grow the shell both inward and outward (default false).", false},+ {"tcorne", T::Bool, "TCorne: triangles instead of quads in the rim's sharp corners (default false).", false},+ {"tborder", T::Bool, "TBorder: the whole rim is triangles instead of quads (default false).", false},{"accept", T::Bool, "Accept at once instead of leaving a preview (default false).", false}},runExtract});reg.add({"extract_accept", "Keep the Extract preview as a new SubTool (undo removes it again).", {},diff --git a/src/core/ExtractMirror.h b/src/core/ExtractMirror.hindex 5decbd60..2653826d 100644--- a/src/core/ExtractMirror.h+++ b/src/core/ExtractMirror.h@@ -5,7 +5,8 @@// - Extract (Tool > SubTool > Extract): the masked part of a SubTool becomes a new SubTool, a shell with a// thickness (a helmet, a strap, a piece of clothing). Extract shows it as a preview; Accept keeps it as an// undoable step. Thick is a fraction of the SubTool's size (negative = inward), E Smt smooths the jagged edge-// the mask's triangles leave, Double grows the shell both ways; Thick 0 gives a single-sided surface.+// the mask's triangles leave, Double grows the shell both ways; Thick 0 gives a single-sided surface. The rim+// is quads, except at sharp corners with TCorne and all along it with TBorder.// - Mirror And Weld (Tool > Geometry > Modify Topology): the half on the + side of a plane through the origin// is kept and mirrored onto the - side, and the seam welded into one watertight mesh. Triangles crossing the// plane are cut on it; polygroups, polypaint, mask, UVs and sculpt layers are carried over.@@ -24,6 +25,8 @@ struct ExtractOptions {float thickness = 0.015f; // fraction of the SubTool's largest side; < 0 grows inward, 0 = a single surfaceint smooth = 5; // E Smt: smoothing passes along the edge of the extracted part (0-50)bool doubleSided = false; // Double: the shell grows both ways from the surface by the thickness+ bool triangleCorners = false; // TCorne: the rim keeps triangles (not quads) where the edge turns sharply+ bool triangleBorder = false; // TBorder: the whole rim is trianglesfloat threshold = 0.5f; // a triangle is extracted when its corners' mean mask reaches this};diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cppindex 3553b5e7..b265dfcf 100644--- a/src/render/Renderer.cpp+++ b/src/render/Renderer.cpp@@ -2036,6 +2036,8 @@ void Renderer::draw(const Camera& camera, int targetWidth, int targetHeight, con}const int fbWidth = inset ? viewport.w : targetWidth, fbHeight = inset ? viewport.h : targetHeight;if (thumbnailPass_) gl::ClearColor(0.0f, 0.0f, 0.0f, 0.0f); // renderMeshThumbnail: transparent background+ else if (!settings.gradientBackground)+ gl::ClearColor(settings.backgroundColor.x, settings.backgroundColor.y, settings.backgroundColor.z, 1.0f);else gl::ClearColor(0.075f, 0.075f, 0.08f, 1.0f);gl::Clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);gl::Enable(GL_MULTISAMPLE);@@ -2046,11 +2048,11 @@ void Renderer::draw(const Camera& camera, int targetWidth, int targetHeight, con}} scissorOff{inset};- // Background: charcoal with a radial vignette.+ // Background: charcoal with a radial vignette (or the flat colour cleared above).gl::Disable(GL_DEPTH_TEST);gl::UseProgram(bgProgram_);gl::BindVertexArray(emptyVao_);- if (!thumbnailPass_) gl::DrawArrays(GL_TRIANGLES, 0, 3);+ if (!thumbnailPass_ && settings.gradientBackground) gl::DrawArrays(GL_TRIANGLES, 0, 3);const glm::mat4 view = camera.view(), proj = camera.projection();frameView_ = view;diff --git a/src/render/Renderer.h b/src/render/Renderer.hindex b07e375b..db74e32e 100644--- a/src/render/Renderer.h+++ b/src/render/Renderer.h@@ -30,6 +30,9 @@ struct RenderSettings {bool dimInactive = true; // SubTools other than the active one render slightly darker (ZBrush style)bool motionProxy = false; // the view is moving (Fast Navigation): draw big meshes' lighter proxy (render/Clusters.h)bool flatShading = false; // the scene's shading (Material palette): faceted; SubTools can override (core/Document.h)+ // The view's background: the charcoal radial gradient (default) or one flat display (sRGB) colour (#21).+ bool gradientBackground = true;+ glm::vec3 backgroundColor{0.165f, 0.165f, 0.173f};};// A baked tangent-space normal map to preview on a mesh (core/Bake.h): RGB8 rows bottom-up, with thediff --git a/tests/test_extract_mirror.cpp b/tests/test_extract_mirror.cppindex 6d40b0c9..f3b10edf 100644--- a/tests/test_extract_mirror.cpp+++ b/tests/test_extract_mirror.cpp@@ -250,3 +250,31 @@ TEST(mirror_flip) {CHECK(std::abs(doc.mesh.bounds().min.x - before.min.x) < 1e-6f);CHECK(!reg.execute(doc, "mirror", {{"pivot", std::string("somewhere")}}).ok);}++TEST(extract_tcorne_tborder) {+ // The top face of a cube: a square edge with four sharp corners. The rim is quads, without the corners'+ // with TCorne, and triangles all along with TBorder.+ Mesh cube = makeCube(4, 2.0f);+ cube.ensureMask();+ for (uint32_t v = 0; v < cube.vertexCount(); ++v) cube.mask[v] = cube.positions[v].y > 0.99f ? 1.0f : 0.0f;+ auto rimQuads = [](const Mesh& m) {+ size_t n = 0;+ for (uint32_t t = 0; t < m.triangleCount(); ++t)+ n += m.polygroupAt(t) == 3 && m.quadPartnerAt(t) != Mesh::kNoQuad;+ return n / 2;+ };+ std::string error;+ ExtractOptions o;+ o.smooth = 0;+ o.threshold = 1.0f; // only triangles with every corner masked: the top face exactly+ const Mesh plain = extractShell(cube, o, error);+ CHECK(watertight(plain));+ CHECK(rimQuads(plain) == 16); // 4 edges of 4 segments+ o.triangleCorners = true;+ const Mesh corners = extractShell(cube, o, error);+ CHECK(watertight(corners) && rimQuads(corners) == 8); // each corner takes the quad on both sides of it+ o.triangleBorder = true;+ const Mesh border = extractShell(cube, o, error);+ CHECK(watertight(border) && rimQuads(border) == 0);+ CHECK(border.triangleCount() == plain.triangleCount());+}diff --git a/tests/ui/background.sfui b/tests/ui/background.sfuinew file mode 100644index 00000000..24894c07--- /dev/null+++ b/tests/ui/background.sfui@@ -0,0 +1,57 @@+# The view's background (#21): Gradient (the default) or Flat Colour with a colour picker, in Preferences > Display+# and the Render palette; kept by Store Config and in projects, and scriptable (set_background).+run new_head+camera 20 5+key f+expect_value gradient_background == 1+shot gradient++# Preferences > Display: Gradient | Flat Colour and the colour.+click "Preferences##palette.preferences"+click "Display##preferences.display"+expect "Gradient##view.background_gradient"+expect "Flat Colour##view.background_flat"+expect_text "Background colour"+click "Flat Colour##view.background_flat"+expect_status "Background: Flat Colour"+expect_value gradient_background == 0+shot preferences-display+key escape+hover "Tool/SubTool"+shot flat++# A colour of your own, from a script.+run set_background color=60,70,80+expect_value gradient_background == 0+expect_value background_r == 60+expect_value background_b == 80+hover "Tool/SubTool"+shot flat-blue++# The Render palette has the same controls.+click "Render##palette.render"+expect "Gradient##view.background_gradient"+expect_text "Background colour"+click "Gradient##view.background_gradient"+expect_value gradient_background == 1+key escape++# Store Config keeps it for the next session (Restore Custom UI reads it back).+run set_background mode=flat+key ctrl+shift+i+expect_status "UI configuration stored"+run set_background mode=gradient+key f3+type "##Command palette" "restore custom"+key enter+expect_status "Custom UI restored"+expect_value gradient_background == 0+expect_value background_r == 60++# Projects keep their own.+run save_project path=sf_ui_background.sfproj+run set_background mode=gradient+run open path=sf_ui_background.sfproj+expect_value gradient_background == 0+expect_value background_b == 80+run set_background mode=gradient