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
Merge remote-tracking branch 'origin/main' into feat/pbr-phase2
islandmed51394daf3349
diff --cc CHANGELOG.mdindex 52595821,ad45d558..a6d29d16--- a/CHANGELOG.md+++ b/CHANGELOG.md@@@ -6,27 -6,81 +6,102 @@@ All notable changes to SculptForge are## [Unreleased]+### Added+- PBR viewport: **Material > Viewport Shading** switches between **Lit Sphere** (the default) and **PBR**, which+ shows the texture's material channels as a game engine or renderer does: GGX reflections from a prefiltered+ environment, diffuse light from its spherical harmonics, multiple-scattering energy for rough metals, exposure+ and an ACES, AgX or Reinhard tone map. Painted Normal and Height channels bend the shading through MikkTSpace+ tangents. Four environments: **Studio** (generated) and three CC0 HDRIs from Poly Haven (**Photo Studio**,+ **Small Studio**, **Outdoor Sky**), plus `.hdr` / `.exr` files from `SCULPTFORGE_HDRI_PATH`; rotation, the+ environment behind the model and a cavity term that keeps sculpted detail readable. Parts without a material+ texture use a roughness and metallic set there. A new environment is prepared on a worker thread, and a+ 20.9-million-triangle mesh draws in about 8 ms in PBR next to about 6 ms with Lit Sphere (Apple M1 Pro).+ Saved with the project (`viewport_shading mode=pbr environment=outdoor_sky exposure=0.5 tone_map=agx`).+- Mesh Maps bake: **Tool > Bake** adds **Curvature** (convex edges bright, creases dark, from the surface's mean+ curvature at a set radius), **Thickness** (how far rays travel inside), **Position** (16-bit) and **ID** (a colour+ per polygroup or per Part) to the normal, world normal, displacement, AO, cavity and colour maps. The source can+ be the Part's own **top subdivision level** (baked onto its lowest level) or its **micro level** (onto its base),+ besides other Parts. UVs outside 0..1 bake as **UDIM tiles** (`name_normal.1001.png`, `1002`, ...). The bake runs+ on a worker thread with progress and Cancel (`bake source=subdivision maps=normal,ao,curvature,thickness,position,id`).+- Mesh Maps in the texture (`mesh_maps`): AO, curvature, thickness, position, world normal and ID baked on the+ texture's own UVs and size, tile by tile on every core, for Fill layers to read. After sculpting, only the tiles+ near the change are baked again, from a compact copy of the nearby triangles, and the result matches a full bake+ texel for texel (2K maps of an 82k-triangle Part: about 10 s in full, about 0.5 s for a local change).+ ## [0.10.5] - 2026-11-01+ ### Added+ - **Radial symmetry** (#63): **R** in Transform > Symmetry and on the top shelf repeats strokes around the X, Y or Z+ axis (Radial Count 2-64), combined with the X / Y / Z mirrors (mirror + radial = 2N copies), and **Local**+ symmetry about the active Part's centre. Applies to every brush and stroke, mask and smooth strokes, vertex paint+ and texture painting, Mask / Select Rectangle and Lasso, Dynamic Topology (new topology on every copy) and Insert;+ the brush cursor shows on every copy. Saved in projects; `radial`, `radial_axis` and `local` arguments on+ `stroke`, `vdm_stamp`, `mask_rect`, `mask_lasso`, `hide_rect`, `hide_lasso`, `insert_primitive` and `insert_mesh`.+ - **Preferences > Interface > Timeline position** (#63): the Sculpt Timeline strip at the top of the viewport (the+ new default, away from the brush shelf) or at the bottom; Store Config keeps it.+ - **UV Editor** (Tool > Texture Map > UV Editor, Alt+U): a window with the active Part's UV layout over the UDIM+ tile grid, drawn on the GPU (pan, zoom, a checker or the painted texture behind). Select vertices, edges, faces or+ islands (1-4) by click or box, or on the model with **Select in 3D**; move, rotate and scale with the selection's+ handles or G / R / S (X / Y lock an axis, Ctrl snaps). **Seam Tool**: drag on the model to mark seams along the+ shortest edge paths (Alt clears); seams also from face groups, island borders or sharp edges, and show in red on+ the model. **Unwrap**: Least Stretch (LSCM, then as-rigid-as-possible), Conformal (LSCM), By Face Groups, Planar,+ Unfold Islands (keeps pins) and Auto Seams (xatlas), solved with a multigrid preconditioner (a 1.3M-triangle+ sphere unwraps in seconds); closed, looped and tangled pieces get cut automatically; selected faces unwrap in+ place. **Pack** into one tile or across UDIM tiles with a margin, rotation and equal texel density, by island+ outline or box (whichever fits larger), or at a fixed texel density spilling into more tiles. **Texel density**:+ set, match and pick, with a density heat map. **Trim sheets**: lay islands into horizontal strips (count, heights+ or v ranges), fitted to the width or keeping proportions. **Pin**, **Weld**, **Split**, **Straighten**, **Flip**,+ **Rotate 90**. The model shows islands, stretch or density colours and a UDIM-tinted checker live during edits, and+ **Paint stays on the model** re-projects a painted texture (every layer) onto each new layout in the same undo+ step. Seams and pins are saved in projects. Commands: `uv_unwrap`, `uv_pack`, `uv_seam`, `uv_select`,+ `uv_transform`, `uv_edit`, `uv_density`, `uv_trim`, `uv_info` (scripts, CLI, Python, MCP); guide chapter UV+ Editor.+ - **Preferences > Input > Start strokes off the model** (#62, off by default) and **Toggle strokes off the model**+ (<kbd>Shift</kbd>+<kbd>L</kbd>): a left-drag that starts on the background begins a stroke, which touches the model+ once the cursor reaches it (Lazy Stroke and the stroke path start there, so nothing jumps). Ctrl (mask) and Shift+ (smooth) strokes work the same way; a Ctrl+click on the background still inverts the mask. The view still turns+ with a right-drag (or a pen button set to Right click), pans with Alt+drag or a middle-drag, moves with Space held+ when that option is on, and Blender and Maya keys keep Alt+left-drag. A label at the top of the canvas shows while+ it is on. Mask Lasso, Mask Rectangle and the hide / show shapes are unchanged.++ ### Changed+ - Features use SculptForge's own names (Parts, Forge Spheres, Vertex Paint, Face Groups, Library, Lit Spheres,+ Quad Remesh, Voxel Remesh, Dynamic Topology, Snapshot, Gizmo, Lazy Stroke, Wireframe, Send to ZBrush, Sharp+ Crease, Clay Block, Tendril...); searching for ZBrush terms still finds them. MatCaps are now Lit Spheres. The user guide's chapters follow+ (Parts, Forge Spheres, Vertex Paint, Face Groups; the old web addresses redirect), and+ Help > User Guide > Coming from ZBrush has the table of ZBrush terms and their SculptForge names. The ZBrush+ plug-in is now called SculptForge ZTL Export (same file, `SculptForgeZToolExport.txt`).+ - New installs default to the SculptForge-style keys (Preferences > Input); a first-start "Coming from: ZBrush /+ Blender / Maya / New to sculpting" choice sets the key style, and existing users keep their saved choice.+ ZBrush's keys are the **ZBrush-style** option.+ - Contributions are signed off under the Developer Certificate of Origin (`git commit -s`; see CONTRIBUTING.md).+ - Faster CI and releases with the same tests (docs/releasing.md):+ - **Compiler caching:** compiles go through ccache, cached only by pushes to main and maintainers' own runs.+ Pull requests only read the cache, and tags never save one.+ - **Parallel tests:** `sculptforge_tests` runs as eight parallel shards (`sculptforge_tests --shard K/N`; each test+ now prints its time). ctest runs in parallel, with timed measurements and clipboard tests alone. The slowest+ test sets are spread over several free runners.+ - **Skipped work:** website-only pushes skip the build and test jobs.+ - **Build once, promote:** the release packages are built and tested on every push to main (the new Packages+ workflow). A tagged release promotes the packages of the commit it tags instead of building them again.+ - **Smoke tests before publishing:** every package (Windows installer and .zip, .dmg, .deb and AppImage on x86_64+ and arm64, .rpm) is installed on a fresh runner, opens a model, sculpts and saves.+ - `scripts/release.sh X.Y.Z` tags, waits and brings the site, update feed, guide, AUR, Homebrew and Omarchy to the+ release, and drafts the issue replies. It is resumable, and stops with the fix when something is wrong.+ ### Added+ - Selection Sets (**Tool > Selection Sets**, `selection_set_*`): any number of named snapshots per Part of the mask,+ polygroups, visibility, vertex paint, UVs and shape, each holding the channels you tick. Store, restore, rename,+ delete, combine (union / intersect / subtract, also as restore modes onto the current mask and visibility) and a+ quick set from the visible faces, each one undo step. A set restores at any subdivision level of its Part (values+ carried through the levels as the stack carries attributes; shapes as offsets, so in-between detail stays). Stored+ compactly (runs of masked / painted / hidden elements, run-length polygroups) in projects under the optional+ `selection_sets` key (no format version bump; older versions skip it), in `.sfsets` files+ (`selection_sets_export` / `selection_sets_import`) and in USD exports as GeomSubsets and primvars, which USD import+ reads back. A set with its shape is a morph target: the new **Morph** brush pulls toward it (Alt pushes away) and+ `selection_set_morph` (Morph to Set) blends the whole Part toward it by an amount, within the mask. Python:+ `Document.selection_sets`, `selection_set(name)` and `set_selection_set(name, mask=..., ...)` push and pull sets as+ NumPy arrays.++ ### Fixed+ - The viewport now appears on Windows setups whose window uses another colour format (seen on NVIDIA with high-resolution displays): the view was drawn but never reached the window, so the cursor left trails and the model never showed (#29).## [0.10.4] - 2026-11-01diff --cc CMakeLists.txtindex 4c4ad2b5,5bb6d34c..eddf160a--- a/CMakeLists.txt+++ b/CMakeLists.txt@@@ -72,11 -73,11 +73,15 @@@ add_library(sculptforge_core STATIsrc/core/PaintLayer.cppsrc/core/Texture.cppsrc/core/TextureCommands.cpp+ src/core/Uv.cpp+ src/core/UvCommands.cpp+ src/core/UvPack.cpp+ src/core/UvUnwrap.cppsrc/core/TileImage.cpp+ src/core/EnvironmentMath.cpp+ src/core/MeshMaps.cpp+ src/core/LayerStack.cpp+ src/core/MaterialRecipe.cppsrc/core/TextureChannels.cppsrc/core/TextureChannelCommands.cppsrc/core/LayerStackIO.cpp@@@ -287,8 -275,8 +293,9 @@@ if(SCULPTFORGE_BUILD_APPsrc/app/PanelPolypaint.cppsrc/app/PanelPaintLayers.cppsrc/app/PanelTexture.cpp+ src/app/PanelUvEditor.cppsrc/app/PanelPbr.cpp+ src/app/PanelFill.cppsrc/app/PanelGeometry.cppsrc/app/Gizmo.cppsrc/app/PanelBake.cppdiff --cc THIRD_PARTY_NOTICES.mdindex 5d3d20c1,f7afe18b..2f85dae9--- a/THIRD_PARTY_NOTICES.md+++ b/THIRD_PARTY_NOTICES.md@@@ -17,8 -17,8 +17,9 @@@ licenses require| [tinyexr](https://github.com/syoyo/tinyexr) | 1.0.13 | BSD 3-Clause License (includes OpenEXR code under the OpenEXR BSD licence) | OpenEXR reading and writing for vector displacement maps (Brush > Vector Displacement). Vendored in third_party/tinyexr; uses stb's zlib. || [Instant Meshes](https://github.com/wjakob/instant-meshes) | formulas only, nothing vendored | BSD 3-Clause License | QRemesh (Tool > Geometry): the field formulas in src/core/QRemesh.cpp (extrinsic 4-RoSy orientation / position compatibility, the middle point of two tangent planes, lattice rounding) follow its reference code. The rest of QRemesh is our own. || QRemesh 2 (published methods, no third-party code) | — | — | The default QRemesh method (src/core/QRemesh2*.cpp) is our own implementation of published techniques: integer-grid maps / mixed-integer quadrangulation (Bommes, Zimmer & Kobbelt 2009; Bommes, Campen, Ebke, Alliez & Kobbelt 2013), N-RoSy fields as complex powers and the smoothest field by inverse power iteration (Ray, Vallet, Li & Lévy 2008; Knöppel, Crane, Pinkall & Schröder 2013), the dihedral curvature tensor (Cohen-Steiner & Morvan 2003), isotropic remeshing (Botsch & Kobbelt 2004) and smoothed aggregation multigrid. No code from QuadWild (GPL-3), libigl (MPL-2.0), CoMISo or Instant Meshes is included. |+ | [GoB](https://github.com/JoseConseco/GoB) | format reference only, nothing vendored | GNU GPL 3 | The .GoZ file layout that Send to ZBrush and the .GoZ import/export read and write (src/io/GozIO.cpp, docs/goz.md) follows this open-source Blender add-on, credited with thanks. No code from it is included. || [Inter typeface](https://github.com/rsms/inter) | 4.1 | SIL Open Font License 1.1 | User interface font, embedded in the desktop app. Vendored in assets/fonts. |+| [Poly Haven](https://polyhaven.com) HDRIs: Brown Photostudio 02, Studio Small 09 (Sergej Majboroda), Kloofendal 48d Partly Cloudy (Pure Sky) (Greg Zaal, sky edits by Jarod Guest) | 1K files, downsampled to 512 x 256 | CC0 1.0 (public domain) | Image-based lighting of the PBR viewport (Material > Viewport Shading). Vendored in assets/hdri and embedded. || [ICT-FaceKit](https://github.com/ICT-VGL/ICT-FaceKit) (ICT Face Model Light) | commit on master, 2020 | MIT License | The template head of Generate Facial Shapes (Tool > Facial Shapes): its neutral skin, mouth and eye sockets and its 53 ARKit-style expression shapes, converted by tools/face/build_ict_template.py into assets/face/ict-arkit.sfface (embedded). Not the separately licensed full ICT Face Model. || [libcurl](https://curl.se) | system library | curl License (MIT/X derivate) | HTTPS for optional AI features on Linux and macOS. Linked dynamically from the operating system; Windows uses the built-in WinHTTP instead. || [QR Code generator](https://github.com/nayuki/QR-Code-generator) | 1.8.0 | MIT License | The phone link's pairing QR code (File > Capture from phone). Vendored in third_party/qrcodegen. |diff --cc src/app/App.cppindex 61626612,8054ddfa..7af9bb5b--- a/src/app/App.cpp+++ b/src/app/App.cpp@@@ -1,9 -1,9 +1,10 @@@// SculptForge - open source digital sculpting// SPDX-License-Identifier: GPL-3.0-or-later#include "app/App.h"+#include "core/LayerStack.h"#include "app/ShellQuote.h"#include "app/SpaceCamera.h"+ #include "app/AirStroke.h"#include "app/AsyncStroke.h"#include "app/Calibration.h"#include "app/CrashLog.h"@@@ -646,8 -645,8 +649,8 @@@ bool App::backgroundBusy() constauto running = [](const auto& f) { return f.valid() && f.wait_for(std::chrono::seconds(0)) != std::future_status::ready; };return running(pendingBrush_) || running(pendingGenerator_) || running(pendingModels_) || running(pendingUnreal_) ||running(pendingComfyCheck_) || galleryBusy() || thumbs_.busy() || libraryScanner_.busy() || autoUv_ ||- bakeBusy() || qremesh_ || voxelRemesh_ || updateJob_ || splatTrainBusy() || sculptableBusy() || phoneBusy() ||+ bakeBusy() || qremesh_ || voxelRemesh_ || updateJob_ || splatTrainBusy() || sculptableBusy() || phoneBusy() || uvEditorBusy() ||- supportCardLoading();+ supportCardLoading() || renderer_.environmentPending() || meshMapsBusy();}void App::redrawIn(double seconds) {@@@ -1963,8 -1967,8 +1976,9 @@@ void App::syncScene()// Solo channel view (channel_view): the texture's shown texels follow before the renderer uploads them.if (mesh->texture) syncChannelView(*mesh->texture, doc_.channelView);const bool flat = s.shading == Shading::Flat || (s.shading == Shading::Default && renderSettings_.flatShading);- scene.push_back({s.id, mesh, active, s.visible, bakeNormalMap(s.id, *mesh), renderSettings_.wireframe, flat,- renderSettings_.pbr()});+ scene.push_back({s.id, mesh, active, s.visible, bakeNormalMap(s.id, *mesh), renderSettings_.wireframe, flat});++ scene.back().pbr = renderSettings_.pbr();+ if (active && &shown == &doc_.mesh) scene.back().overlay = uvEditorOverlay(s.id); // the UV Editor's colours}renderer_.syncScene(scene);renderer_.syncSplats(doc_.splats, doc_.splatsVersion);diff --cc src/app/PanelBake.cppindex 86fc15e0,10615677..fc4587ad--- a/src/app/PanelBake.cpp+++ b/src/app/PanelBake.cpp@@@ -213,10 -208,9 +213,10 @@@ void App::registerBakeUiActions()actions_.add(std::move(a));};add("bake.run", "Bake", [this] { startBake(); }, nullptr,- [this] { return !bake_->job && doc_.mesh.hasUvs() && doc_.subtoolCount() > 1; },- "Bake the chosen maps from the source Part(s) onto this Part's UVs, in the background. Maps are saved as "- "PNGs (displacement also as a 32-bit EXR) in the output folder, and the normal map shows on the model.",+ [this] { return !bake_->job && doc_.mesh.hasUvs() && (doc_.subtoolCount() > 1 || bake_->levelSource); },- "Bake the chosen maps from the source SubTool(s), or this Part's own top subdivision or micro level, onto its "++ "Bake the chosen maps from the source Part(s), or this Part's own top subdivision or micro level, onto its "+ "UVs, in the background. Maps are saved as PNGs (displacement also as a 32-bit EXR, position as a 16-bit PNG) "+ "in the output folder, one set per UDIM tile when the UVs use them, and the normal map shows on the model.","bake");add("bake.cancel", "Cancel Bake", [this] {if (bake_->job) bake_->job->cancel->store(true);@@@ -246,30 -240,19 +246,30 @@@void App::startBake() {BakeUiState& b = *bake_;if (b.job) return;- if (!doc_.mesh.hasUvs()) {- status_ = "Bake needs UVs on this Part (the low-poly): Tool > Texture Map > Auto UV";- return;- }- // Source SubTools: the chosen one, or every visible SubTool but this one.- std::string source = "all";- for (int i = 0; i < doc_.subtoolCount(); ++i)- if (b.source && doc_.subtools[size_t(i)].id == b.source) source = doc_.subtools[size_t(i)].name;+ // Source: the active Part's own levels, or other Parts (the chosen one, or every visible Part but this one).+ auto low = std::make_shared<Mesh>();+ auto sources = std::make_shared<std::vector<Mesh>>();std::vector<int> idx;std::string err;- if (!bakeSourceSubtools(doc_, source, idx, err)) {- status_ = err;- return;+ if (b.levelSource) {+ Mesh high;+ if (!bakeLevelSources(doc_.mesh, b.levelSource == 1 ? "subdivision" : "micro", *low, high, err)) {+ status_ = err;+ return;+ }+ sources->push_back(std::move(high));+ } else {+ if (!doc_.mesh.hasUvs()) {- status_ = "Bake needs UVs on this SubTool (the low-poly): Tool > Texture Map > Auto UV";++ status_ = "Bake needs UVs on this Part (the low-poly): Tool > Texture Map > Auto UV";+ return;+ }+ std::string source = "all";+ for (int i = 0; i < doc_.subtoolCount(); ++i)+ if (b.source && doc_.subtools[size_t(i)].id == b.source) source = doc_.subtools[size_t(i)].name;+ if (!bakeSourceSubtools(doc_, source, idx, err)) {+ status_ = err;+ return;+ }}if (doc_.sculptor.strokeActive()) endStroke();BakeSettings st = b.settings;@@@ -328,10 -299,8 +328,10 @@@promise.set_value(ok);}).detach();b.job = std::move(job);- status_ = "Baking " + std::to_string(st.size) + " maps from " + std::to_string(idx.size()) + " Part" +- (idx.size() == 1 ? "" : "s") + "...";+ status_ = b.levelSource ? "Baking " + std::to_string(st.size) + " maps from the " ++ (b.levelSource == 1 ? "top subdivision level" : "micro level") + "..."- : "Baking " + std::to_string(st.size) + " maps from " + std::to_string(idx.size()) + " SubTool" +++ : "Baking " + std::to_string(st.size) + " maps from " + std::to_string(idx.size()) + " Part" ++ (idx.size() == 1 ? "" : "s") + "...";}void App::pollBake() {@@@ -396,15 -364,8 +396,15 @@@ void App::drawBakeContents()ImGui::TextUnformatted("Source");ImGui::SameLine();ImGui::SetNextItemWidth(-1);+ const bool hasLevels = subdivLevelCount(m) >= 2, hasMicroLevel = hasMicro(m);+ if (b.levelSource == 1 && !hasLevels) b.levelSource = 0;+ if (b.levelSource == 2 && !hasMicroLevel) b.levelSource = 0;+ if (b.levelSource == 1) current = "Own top subdivision level";+ if (b.levelSource == 2) current = "Own micro level";if (ImGui::BeginCombo("##bakesource", current.c_str())) {- if (ImGui::Selectable("All visible Parts", b.source == 0)) b.source = 0;+ if (hasLevels && ImGui::Selectable("Own top subdivision level##level", b.levelSource == 1)) b.levelSource = 1, b.source = 0;+ if (hasMicroLevel && ImGui::Selectable("Own micro level##micro", b.levelSource == 2)) b.levelSource = 2, b.source = 0;- if (ImGui::Selectable("All visible SubTools", b.source == 0 && !b.levelSource)) b.source = 0, b.levelSource = 0;++ if (ImGui::Selectable("All visible Parts", b.source == 0 && !b.levelSource)) b.source = 0, b.levelSource = 0;for (int i = 0; i < doc_.subtoolCount(); ++i) {if (i == doc_.activeSubtool) continue;const SubTool& st = doc_.subtools[size_t(i)];@@@ -415,9 -376,8 +415,9 @@@ImGui::EndCombo();}ui::HelpText("Source", nullptr,- "The high-poly to bake from: one SubTool, or every visible SubTool except the active one (the low-poly), "- "The high-poly to bake from: one Part, or every visible Part except the active one (the low-poly). "- "Hidden faces of the source are ignored.",++ "The high-poly to bake from: one Part, or every visible Part except the active one (the low-poly), "+ "or this Part's own top subdivision level baked onto its lowest level, or its micro level baked onto its "+ "base. Hidden faces of the source are ignored. UVs outside 0..1 bake as UDIM tiles (name.1001.png, ...).",kPath);// Maps, two columns.@@@ -429,14 -389,7 +429,14 @@@"reported when the bake finishes) and a 32-bit EXR in world units.","Ambient occlusion: how much of the sky each point of the high-poly sees. Darker in creases and folds.","Cavity: the high-poly's fine surface curvature. Mid-grey on smooth surfaces, dark in cracks, light on ridges.",- "Colour transfer: the source's polypaint, or its painted texture.",+ "Colour transfer: the source's vertex paint, or its painted texture.",+ "Curvature: the high-poly's surface bend at the radius below: mid-grey flat, bright on convex edges, dark in "+ "concave ones. Drives edge wear.",+ "Thickness: how far rays travel through the high-poly before leaving it. Dark where it is thin (ears, fins, "+ "edges). Drives subsurface and translucency.",+ "Position: each point's place in the bounding box as colour, 16-bit. Drives gradients and noise that ignore "+ "UV seams.",- "ID: a flat colour per polygroup of the high-poly, for selecting areas in other programs.",++ "ID: a flat colour per face group of the high-poly, for selecting areas in other programs.",};for (int i = 0; i < kBakeMapCount; ++i) {if (i % 2) {diff --cc src/app/Shell.cppindex 089a05c5,72b7eef0..e0c4a2c6--- a/src/app/Shell.cpp+++ b/src/app/Shell.cpp@@@ -420,22 -437,8 +437,22 @@@ void App::registerShellActions()actions_.add(std::move(a));}flag("view.polypaint", "Paint", ICON_LC_PALETTE, "Render", "", &renderSettings_.showPolypaint,- "Show polypaint colours (off: plain material).");+ "Show vertex paint colours (off: plain material).");// Shading (Material palette, Tool > Display): the scene's, and the active SubTool's own.+ // Viewport shading (Material > Viewport Shading): Lit Sphere or PBR.+ add({"view.shading_lit_sphere", "Lit Sphere", nullptr,+ "Lit Sphere shading (the default): the chosen material sphere or the studio lights, made for reading forms "+ "while sculpting.",+ "Material > Viewport Shading", "", "viewport_shading",+ [this] { runCommand("viewport_shading", {{"mode", std::string("lit_sphere")}}); },+ [this] { return !renderSettings_.pbr(); }, nullptr});+ add({"view.shading_pbr", "PBR", nullptr,+ "PBR shading: the texture's material channels (base colour, roughness, metallic, normal, height, AO, emissive) "+ "lit by an environment, as a game engine or renderer shows them. Meshes without a material use the roughness "+ "and metallic set here.",+ "Material > Viewport Shading", "", "viewport_shading",+ [this] { runCommand("viewport_shading", {{"mode", std::string("pbr")}}); },+ [this] { return renderSettings_.pbr(); }, nullptr});add({"material.smooth", "Smooth", nullptr,"Smooth shading (the default): normals blend across polygons, so the surface reads as one form.", "Material", "","", [this] { runCommand("set_shading", {{"mode", std::string("smooth")}}); },diff --cc src/app/Ui.cppindex 3d22adfc,96bce54d..d9910553--- a/src/app/Ui.cpp+++ b/src/app/Ui.cpp@@@ -118,9 -118,8 +118,9 @@@ 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 == "view.background_gradient" || id == "view.background_flat" || id == "view.shading_lit_sphere" ||+ id == "view.shading_pbr" ||- id.substr(0, 16) == "subtool.shading_";+ id.substr(0, 16) == "subtool.shading_" || id.substr(0, 8) == "uv.mode_";}bool Checkbox(const char* label, bool* v) {diff --cc src/core/Bake.cppindex 80d91a5c,91e31278..128253bb--- a/src/core/Bake.cpp+++ b/src/core/Bake.cpp@@@ -1061,19 -1125,14 +1061,19 @@@ void registerBakeCommands(CommandRegistusing T = ParamSpec::Type;reg.add({"bake","Bake maps from a high-poly source onto the active Part's UVs (the low-poly): tangent-space normal "- "(MikkTSpace), object-space normal, displacement (16-bit PNG + 32-bit EXR), ambient occlusion, cavity and "- "colour. Rays go along the low-poly's smooth normals from 'front' in front of it to 'rear' behind it. "- "Writes <name>_<map>.png into the output folder.",- {{"source", T::String, "Part to bake from, or all (default: every visible Part but the active one).", false},- {"maps", T::String, "Comma list: normal, object_normal, displacement, ao, cavity, color, or all. Default normal.", false},+ "(MikkTSpace), object-space (world) normal, displacement (16-bit PNG + 32-bit EXR), ambient occlusion, cavity, "+ "colour, curvature, thickness, position (16-bit) and ID (polygroups or Parts). Rays go along the low-poly's "+ "smooth normals from 'front' in front of it to 'rear' behind it. The source can be other Parts, or the "+ "active Part's own top subdivision level (baked onto its lowest level) or micro level (onto its base). "+ "UVs outside 0..1 bake as UDIM tiles. Writes <name>_<map>.png (<name>_<map>.1001.png per UDIM tile) into "+ "the output folder.",+ {{"source", T::String, "A Part to bake from, all (default: every visible Part but the active one), subdivision "+ "(the active Part's top level onto its lowest) or micro (its micro level onto its base).", false},+ {"maps", T::String, "Comma list: normal, object_normal (world_normal), displacement, ao, cavity, color, curvature, "+ "thickness, position, id, or all. Default normal.", false},{"size", T::Number, "Map size in texels: 512, 1024, 2048 (default), 4096 or 8192 (1k...8k also work).", false},{"out", T::String, "Output folder (default: the project's folder, or the current folder).", false},- {"name", T::String, "File name prefix (default: the active SubTool's name).", false},+ {"name", T::String, "File name prefix (default: the active Part's name).", false},{"front", T::String, "Ray start in front of the low-poly, as a fraction of its size (e.g. 0.02), or auto (default).", false},{"rear", T::String, "How far behind the low-poly rays look, as a fraction of its size, or auto (default).", false},{"samples", T::Number, "Anti-aliasing: samples x samples rays per texel, 1-4. Default 2.", false},diff --cc src/core/Polypaint.cppindex e0b73cc3,6bdc64fd..3f8f267f--- a/src/core/Polypaint.cpp+++ b/src/core/Polypaint.cpp@@@ -1,9 -1,7 +1,10 @@@// SculptForge - open source digital sculpting// SPDX-License-Identifier: GPL-3.0-or-later#include "core/Polypaint.h"+#include "core/LayerStack.h"+#include "core/MaterialRecipe.h"+#include "core/MeshMaps.h"+ #include "core/Uv.h"#include "core/MapExport.h"#include "core/Commands.h"@@@ -406,10 -404,8 +407,11 @@@ void registerPaintCommands(CommandRegis}});registerPaintLayerCommands(registry); // paint_layer_* (core/PaintLayer.cpp)registerTextureCommands(registry); // texture_*, uv_auto, paint_target (core/TextureCommands.cpp)+ registerUvCommands(registry); // uv_unwrap, uv_pack, uv_seam, uv_select, ... (core/UvCommands.cpp)registerTextureChannelCommands(registry); // texture_channels, paint_material, channel_view (core/TextureChannelCommands.cpp)+ registerMeshMapCommands(registry); // mesh_maps (core/MeshMaps.cpp)+ registerLayerStackCommands(registry); // fill_layer (core/LayerStack.cpp)+ registerMaterialRecipeCommands(registry); // material_recipe (core/MaterialRecipe.cpp)registerMapExportCommands(registry); // export_maps (core/MapExport.cpp)}diff --cc src/core/Project.cppindex 4218e984,491ac3c4..00eae256--- a/src/core/Project.cpp+++ b/src/core/Project.cpp@@@ -6,8 -6,8 +6,9 @@@#include "core/Multires.h"+#include "core/LayerStack.h"#include "core/LayerStackIO.h"+ #include "core/SelectionSets.h"#include "core/Texture.h"#include "core/ThreadPool.h"#include "core/ZSpheres.h"diff --cc src/render/Renderer.cppindex 36297e79,3fa6097a..30fb1f8e--- a/src/render/Renderer.cpp+++ b/src/render/Renderer.cpp@@@ -1317,7 -1167,9 +1341,9 @@@ void Renderer::syncScene(const std::vecdrawList_.clear();for (const SceneMesh& m : scene) {if (!m.visible || !m.mesh) continue; // hidden: keeps its dirty state until shown- sync(slot(m.id), *m.mesh, m.normalMap, m.wireframe && m.active, m.pbr);+ MeshSlot& ms = slot(m.id);+ ms.overlay = m.active ? m.overlay : nullptr;- sync(ms, *m.mesh, m.normalMap, m.wireframe && m.active);++ sync(ms, *m.mesh, m.normalMap, m.wireframe && m.active, m.pbr);drawList_.push_back({m.id, m.active, m.flat});}}@@@ -2838,18 -2516,19 +2890,22 @@@ void Renderer::drawSlot(const MeshSlotdrawMicro(s, active, flat, settings);return;}+ // The UV Editor's checker on the model.+ const bool checker = active && s.hasUvs && s.overlay && s.overlay->checker;// A painted texture shows through the textured program (polypaint still multiplies it).- const bool textured = s.hasUvs && s.paintTexture && settings.showPolypaint && settings.showTexture;+ const bool textured = s.hasUvs && ((s.paintTexture && settings.showPolypaint && settings.showTexture) || checker);- // A baked normal map preview bends the shading normal (core/Bake.h).- const bool normalMapped = s.hasUvs && s.normalTexture && s.hasTangents;+ const bool pbr = settings.pbr() && envTexture_;+ // A baked normal map preview bends the shading normal (core/Bake.h), and in the PBR view the texture's+ // Normal / Height channels do (syncTexture's material normal, with tangents from syncNormalMap).+ const GLuint normalTex = s.normalTexture ? s.normalTexture : (pbr && textured ? s.matNormalTexture : 0);+ const bool normalMapped = s.hasUvs && normalTex && s.hasTangents;- const int groups = active && settings.showPolygroups ? (s.hasGroups ? 1 : 2) : 0;+ const int groups = active && s.overlayColors ? 3+ : active && settings.showPolygroups && !s.overlayColors ? (s.hasGroups ? 1 : 2)+ : 0;// (Not through the textured program's geometry shader: those meshes are sculpted without the preview.)const bool ghost = active && s.id == ghostId_ && !ghost_.empty() && !settings.motionProxy && !textured && !normalMapped;- const int features = (s.hasColors || s.hasMask ? kPaint : 0) | (groups == 1 ? kPrim : 0) | (textured ? kTextured : 0) |- (normalMapped ? kNormalMap : 0) | (flat ? kFlat : 0) | (pbr ? kPbr : 0);+ const int features = (s.hasColors || s.hasMask ? kPaint : 0) | (groups == 1 || groups == 3 ? kPrim : 0) |- (textured ? kTextured : 0) | (normalMapped ? kNormalMap : 0) | (flat ? kFlat : 0);++ (textured ? kTextured : 0) | (normalMapped ? kNormalMap : 0) | (flat ? kFlat : 0) | (pbr ? kPbr : 0);const MeshProgram* p = meshProgram(features);if (!p) return;const auto bind = [&](const MeshProgram* p) {diff --cc src/render/Renderer.hindex a12a317d,9487019d..cd271e02--- a/src/render/Renderer.h+++ b/src/render/Renderer.h@@@ -81,7 -73,7 +90,8 @@@ struct SceneMeshbool wireframe = false; // keep the wireframe's edges on the GPU (built on first need; draw() falls back to// outlining the triangles, quad diagonals included, until they are)bool flat = false; // flat shading: each triangle shows its own face normal (faceted)+ bool pbr = false; // the view shades PBR: upload the texture's material channels and their tangents+ const MeshOverlay* overlay = nullptr; // the UV Editor's view of the active mesh (must outlive the frame)};// Part of the target the 3D view is drawn into (framebuffer pixels, origin bottom-left); the rest is@@@ -245,17 -235,11 +260,20 @@@ private// Baked normal map preview (NormalMapView): the map, and the tangents per drawn corner (texture buffer).GLuint normalTexture = 0, tangentData = 0, tangentTexture = 0;uint64_t normalSerial = 0;+ // PBR view (RenderSettings::Shading::Pbr): the texture's material channels packed (pbrViewTexels) as+ // ORM, normal and emissive textures; `pbrPlanes` says which are uploaded (pbrViewPlanes bits). A material+ // normal uses tangents computed here (MikkTSpace) unless a baked normal map preview brings its own.+ GLuint ormTexture = 0, matNormalTexture = 0, emissiveTexture = 0;+ uint32_t pbrPlanes = 0;+ uint64_t pbrSerial = 0;+ std::vector<glm::vec4> matTangents; // per mesh corner+ uint64_t matTangentKey = 0; // UV fingerprint + counts they were computed for+ bool tangentsFromMaterial = false; // tangentTexture holds matTangents (not the baked preview's)bool hasTangents = false, tangentsStale = true, normalFlipGreen = false;bool hasColors = false, hasMask = false, hasGroups = false, hasUvs = false;+ const MeshOverlay* overlay = nullptr; // this frame's (SceneMesh::overlay)+ uint64_t overlaySerial = 0; // the one uploaded+ bool overlayColors = false; // the per-triangle data holds overlay colours, not polygroupsbool fresh = true; // nothing uploaded yetbool regrid = false; // a stroke's vertex left the position grid (prepareStrokeUpload): the next sync re-sends everythingbool outOfMemory = false; // the last full upload ran out of GPU memory: not drawn@@@ -387,14 -359,11 +405,14 @@@GLuint id = 0;GLint view = -1, proj = -1, gridOrigin = -1, gridStep = -1, viewport = -1, projScale = -1, baseColor = -1, paint = -1,showMask = -1, groups = -1, matcap = -1, matcapCavity = -1, dim = -1, primBase = -1, hasPaint = -1,- normalFlipY = -1, twoSided = -1;+ normalFlipY = -1, twoSided = -1, checker = -1, checkerScale = -1;+ GLint hasOrm = -1, hasEmissive = -1, hasMatNormal = -1, envLevels = -1, exposure = -1, toneMap = -1, material = -1,+ pbrCavity = -1, viewToEnv = -1, sh = -1;GLint ghostGroups = -1, ghostRange = -1, ghostEdge = -1, ghostA = -1, ghostB = -1, ghostC = -1, ghostBound = -1, ghostKind = -1, ghostFocal = -1;};- static constexpr int kPaint = 1, kPrim = 2, kTextured = 4, kNormalMap = 8, kFlat = 16, kMicro = 32, kGhost = 64;- MeshProgram programs_[128];+ static constexpr int kPaint = 1, kPrim = 2, kTextured = 4, kNormalMap = 8, kFlat = 16, kMicro = 32, kGhost = 64,+ kPbr = 128;+ MeshProgram programs_[256];void drawMicro(const MeshSlot& s, bool active, bool flat, const RenderSettings& settings);std::string programError_;const MeshProgram* meshProgram(int features);