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
Inbox 11-04: pattern brushes on micro levels (#120), VC++ runtime in the Windows zip + start-failure message (#109), Ctrl/Cmd+, opens Preferences (#111)
islandmedb0fd591d8519
diff --git a/CMakeLists.txt b/CMakeLists.txtindex ecae399a..6556034c 100644--- a/CMakeLists.txt+++ b/CMakeLists.txt@@ -478,6 +478,13 @@ elseif(WIN32)else()set(SF_DOC_DIR ${CMAKE_INSTALL_DOCDIR})endif()+# Windows: the Visual C++ runtime (msvcp140, vcruntime140, vcruntime140_1) goes next to the exe, so the portable zip+# and the installer start on a PC without the Visual C++ Redistributable (#109: nothing happened at all).+if(MSVC)+ set(CMAKE_INSTALL_SYSTEM_RUNTIME_DESTINATION ${CMAKE_INSTALL_BINDIR})+ set(CMAKE_INSTALL_UCRT_LIBRARIES OFF) # the Universal CRT is part of Windows 10 and 11+ include(InstallRequiredSystemLibraries)+endif()install(FILES LICENSE THIRD_PARTY_NOTICES.md README.md CHANGELOG.md DESTINATION ${SF_DOC_DIR})install(FILES docs/ai-services.md docs/unreal.md docs/generators.md docs/comfyui.md DESTINATION ${SF_DOC_DIR}/docs)# Bundled ComfyUI workflows, where the Generate 3D window looks for them (see src/ai/ComfyUI.cpp).diff --git a/changes/fix-inbox-1104.md b/changes/fix-inbox-1104.mdnew file mode 100644index 00000000..dc6259f0--- /dev/null+++ b/changes/fix-inbox-1104.md@@ -0,0 +1,17 @@+---+whats_new: **Pattern brushes on micro levels**: Dragon Scales, Skin Pores, Stone Chisel and the other pattern brushes keep their pattern on a micro level, and carving ones (Wrinkle) carve.+whats_new: **Cmd+, opens Preferences** (Ctrl+, on Windows and Linux).+fixed: **Pattern brushes on micro levels** (#120, reported by RodTDai): a brush recipe on a micro level was a plain+ Standard dab, without its surface pattern (Dragon Scales, Skin Pores, Cracks...) and building up even when the+ recipe carves. It now keeps the pattern and its depth's sign there; planes, pinch and drag still don't apply to+ micro levels.+fixed: **Windows portable zip starts on a fresh PC** (#109, reported by git-tiger): the Visual C++ runtime+ (msvcp140, vcruntime140, vcruntime140_1) now ships next to sculptforge.exe in the zip and the installer; before,+ a PC without the Visual C++ Redistributable couldn't start it. When SculptForge can't start (no OpenGL 3.3, an+ old graphics driver) it now says why in a message box, with the log's path, instead of quietly exiting.+added: **Cmd+, / Ctrl+, opens Preferences** (#111, suggested by fenixpoints).+testers:+ - Windows PC without the Visual C++ Redistributable (or a fresh VM): unzip the portable zip, run bin\sculptforge.exe: it starts.+ - Any OS: Divide to Micro 4 or more, sculpt with Dragon Scales: scales appear; Wrinkle carves a groove.+ - macOS: Cmd+, opens Preferences; Windows/Linux: Ctrl+,.+---diff --git a/docs/guide/shortcuts.md b/docs/guide/shortcuts.mdindex 712936b9..cae4f429 100644--- a/docs/guide/shortcuts.md+++ b/docs/guide/shortcuts.md@@ -103,6 +103,12 @@ generated from SculptForge's action registry, the same source as the Controls wi|---|---|---|| Material picker | <kbd>M</kbd> | Pop up the materials under the cursor. Hover one to preview it on the model; click to keep it. |+### Palettes++| Action | Keys | What it does |+|---|---|---|+| Preferences | <kbd>Ctrl</kbd>+<kbd>,</kbd> | Open the Preferences palette (click its tray icon to keep it in a tray). |+### Preferences| Action | Keys | What it does |diff --git a/src/app/App.cpp b/src/app/App.cppindex b8d5f790..b247978e 100644--- a/src/app/App.cpp+++ b/src/app/App.cpp@@ -108,6 +108,7 @@ bool App::init(const AppOptions& options) {SDL_SetHint(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, "0");if (!headless && options.demo.empty()) applyCachedThreadCount(); // the hardware profile's threads, before any brush workif (!SDL_Init(SDL_INIT_VIDEO)) {+ startError_ = std::string("The window system did not start: ") + SDL_GetError();SDL_Log("SDL_Init failed: %s", SDL_GetError());return false;}@@ -137,6 +138,7 @@ bool App::init(const AppOptions& options) {const int winW = sized ? options.width : saved.w, winH = sized ? options.height : saved.h;window_ = SDL_CreateWindow("SculptForge", winW, winH, flags);if (!window_) {+ startError_ = std::string("The OpenGL 3.3 window could not be made: ") + SDL_GetError();SDL_Log("SDL_CreateWindow failed: %s", SDL_GetError());return false;}@@ -164,6 +166,7 @@ bool App::init(const AppOptions& options) {}glContext_ = SDL_GL_CreateContext(window_);if (!glContext_) {+ startError_ = std::string("OpenGL 3.3 is not available: ") + SDL_GetError();SDL_Log("OpenGL 3.3 context creation failed: %s", SDL_GetError());return false;}@@ -171,6 +174,7 @@ bool App::init(const AppOptions& options) {SDL_GL_SetSwapInterval(1);if (const char* missing = gl::load([](const char* n) { return reinterpret_cast<gl::GenericProc>(SDL_GL_GetProcAddress(n)); })) {+ startError_ = std::string("The graphics driver lacks the OpenGL function ") + missing + ".";SDL_Log("Missing OpenGL function: %s", missing);return false;}@@ -179,6 +183,7 @@ bool App::init(const AppOptions& options) {std::string err;if (!renderer_.init(err)) {+ startError_ = err;SDL_Log("%s", err.c_str());return false;}diff --git a/src/app/App.h b/src/app/App.hindex 5996c37a..6bace761 100644--- a/src/app/App.h+++ b/src/app/App.h@@ -125,6 +125,7 @@ public:App();~App();bool init(const AppOptions& options);+ const std::string& startError() const { return startError_; } // why init failed, for the message box (#109)int run(); // returns the process exit code// Redraw on demand (#14): the interactive loop sleeps in SDL_WaitEventTimeout until an event, a background// job or an animation needs a new frame. UI tests and recordings (runRecording) draw every frame as before.@@ -510,6 +511,7 @@ private:bool scrollChat_ = false;// Image to 3DAppOptions options_;+ std::string startError_;bool showImageTo3D_ = false;bool textMode_ = false;char textPrompt_[512] = "";diff --git a/src/app/Shell.cpp b/src/app/Shell.cppindex cc111e38..9d4596fa 100644--- a/src/app/Shell.cpp+++ b/src/app/Shell.cpp@@ -723,7 +723,8 @@ void App::registerShellActions() {for (int i = 0; i < count; ++i) {const std::string id = list[i].id;add({"ui.palette." + id, list[i].name, list[i].icon,- std::string("Open the ") + list[i].name + " palette (click its tray icon to keep it in a tray).", "Palettes", "",+ std::string("Open the ") + list[i].name + " palette (click its tray icon to keep it in a tray).", "Palettes",+ id == "preferences" ? "Ctrl+," : "", // (Cmd+, on macOS, where apps keep their settings, #111)"",[this, id] {if (std::count(layout_.leftTray.begin(), layout_.leftTray.end(), id) +diff --git a/src/app/main.cpp b/src/app/main.cppindex 6092afdc..b87fd084 100644--- a/src/app/main.cpp+++ b/src/app/main.cpp@@ -251,6 +251,18 @@ int main(int argc, char** argv) {if (!crashTest.empty()) crashOnPurpose(crashTest);sf::App app;if (!app.init(options)) {+ // A double-clicked app that can't start says why (#109: on a laptop it just vanished, not even in the+ // Task Manager). Tests, renders and benchmarks keep failing quietly with their log.+ const bool interactive = options.renderPath.empty() && options.recordPath.empty() && options.uiTest.empty() &&+ options.timelapsePath.empty() && !options.benchmark && options.demo.empty() &&+ !automatedRun();+ if (interactive) {+ std::string text = "SculptForge could not start.\n\n" ++ (app.startError().empty() ? std::string("See the log for details.") : app.startError()) ++ "\n\nUpdating the graphics driver (from the PC or GPU maker) usually fixes this.";+ if (!sf::crashlog::path().empty()) text += "\n\nLog: " + sf::crashlog::path();+ SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "SculptForge", text.c_str(), nullptr);+ }app.shutdown();sf::crashlog::stop();return 1;diff --git a/src/core/Micro.h b/src/core/Micro.hindex ad764423..0526e430 100644--- a/src/core/Micro.h+++ b/src/core/Micro.h@@ -252,7 +252,8 @@ public:// toward `alphaUp` (#92).void dab(Mesh& m, const BVH& bvh, BrushType type, const glm::vec3& center, const glm::vec3& viewDir, float radius,float strength, bool invert, float focal, const glm::vec3& alphaUp, bool maskBrush, float maskStrength,- const BrushAlpha* alpha = nullptr);+ const BrushAlpha* alpha = nullptr, const std::function<float(const glm::vec3&)>& texture = {});+ // (texture: a brush recipe's surface pattern, 0..1 at a surface point, times the tip; #120)// Move: captures the points within the dab (with each mirror's signs), then moves them along their normals.void beginGrab(Mesh& m, const BVH& bvh, const glm::vec3& center, float radius, float focal, const glm::mat3& mirror);void grab(Mesh& m, const glm::vec3& delta);diff --git a/src/core/MicroSculpt.cpp b/src/core/MicroSculpt.cppindex 09a980cc..ce1b7e19 100644--- a/src/core/MicroSculpt.cpp+++ b/src/core/MicroSculpt.cpp@@ -268,7 +268,7 @@ void MicroStroke::stitch(const Mesh& m, MicroMesh& mm, std::span<const uint32_t>void MicroStroke::dab(Mesh& m, const BVH& bvh, BrushType type, const glm::vec3& center, const glm::vec3& viewDir, float radius,float strength, bool invert, float focal, const glm::vec3& alphaUp, bool maskBrush, float maskStrength,- const BrushAlpha* alpha) {+ const BrushAlpha* alpha, const std::function<float(const glm::vec3&)>& texture) {if (!active_ || !m.micro || radius <= 0.0f) return;if (!maskBrush && microBrushSupport(type) == 0) return;auto clock = std::chrono::steady_clock::now();@@ -413,6 +413,7 @@ void MicroStroke::dab(Mesh& m, const BVH& bvh, BrushType type, const glm::vec3&const float edge = std::clamp((1.0f - cheb) / 0.35f, 0.0f, 1.0f);f = edge * edge * (3.0f - 2.0f * edge) * corner;}+ if (texture) f *= texture(p);if (mk && stride == 1) f *= 1.0f - float(mk[idx]) / 255.0f; // (coarse: the fine points' mask, below)if (f <= 0.0f) continue;const float facing = std::max(glm::dot(nn, areaNormal), 0.3f); // moving along nn reaches a plane this much slowerdiff --git a/src/core/Sculpt.cpp b/src/core/Sculpt.cppindex fd719b0d..d9fa4e90 100644--- a/src/core/Sculpt.cpp+++ b/src/core/Sculpt.cpp@@ -1163,8 +1163,29 @@ void Sculptor::updateDabNormals(Mesh& mesh, const BVH& bvh) {void Sculptor::dabRecipe(Mesh& mesh, BVH& bvh, const BrushRecipe& recipe, const DabParams& p, Symmetry sym) {if (!active_) return;- if (mesh.micro && microMatches(mesh)) { // recipes aren't grid brushes: a micro level gets the Standard dab- dab(mesh, bvh, BrushType::Standard, p, sym);+ if (microReady(mesh)) {+ // A micro level: the grid takes a Standard dab with the recipe's depth (its sign carves or builds) and its+ // surface pattern (Dragon Scales, Skin Pores..., #120: they sculpted plain blobs there). Planes, pinch and+ // drag aren't grid brushes.+ const float patternFreq = 1.0f / std::max(p.radius * recipe.patternScale, 1e-6f);+ std::function<float(const glm::vec3&)> texture;+ if (recipe.pattern != BrushRecipe::Pattern::None && recipe.patternAmount > 0.0f)+ texture = [&recipe, patternFreq](const glm::vec3& x) {+ return glm::mix(1.0f, samplePattern(recipe.pattern, x * patternFreq), recipe.patternAmount);+ };+ const bool invert = p.invert != (recipe.depth < 0.0f);+ // (Standard's 0.08 r layer per full dab against the recipe's 0.12 r * depth)+ const float strength = p.strength * std::min(1.0f, std::abs(recipe.depth) * 1.5f);+ const float pressure = std::pow(std::clamp(p.pressure, 0.0f, 1.0f), recipe.pressureCurve);+ const double k0 = micro_.findMs + micro_.kernelMs, s0 = micro_.stitchMs;+ const uint64_t pts = micro_.points;+ for (const SymCopy& m : copies(sym))+ micro_.dab(mesh, bvh, BrushType::Standard, m.point(p.center), m.dir(p.viewDir), p.radius, strength * pressure,+ invert, p.focal, m.dir(p.alphaUp), false, 0.0f, p.alpha, texture);+ timings.kernelMs += micro_.findMs + micro_.kernelMs - k0;+ timings.normalsMs += micro_.stitchMs - s0;+ timings.vertices += micro_.points - pts;+ ++timings.dabs;return;}const bool useAlpha = p.alpha && !p.alpha->empty(); // (an alpha reaches its square's corners, #75)diff --git a/tests/test_micro.cpp b/tests/test_micro.cppindex 8c9d8b00..b3c86b7e 100644--- a/tests/test_micro.cpp+++ b/tests/test_micro.cpp@@ -6,6 +6,7 @@#include "TestHarness.h"#include "core/Benchmark.h"+#include "core/BrushRecipe.h"#include "core/Commands.h"#include "core/Micro.h"#include "core/Multires.h"@@ -147,6 +148,41 @@ TEST(micro_standard_brush_raises_and_undoes) {CHECK(doc.mesh.micro->disp == after);}+// #120: a recipe brush on a micro level keeps its surface pattern (Dragon Scales was a plain Standard blob) and its+// depth's sign (Wrinkle carves).+TEST(micro_recipe_brushes_keep_pattern_and_depth) {+ auto recipe = [](const char* name) {+ for (const BrushRecipe& r : builtinBrushRecipes())+ if (r.name == name) return r;+ CHECK(false);+ return BrushRecipe{};+ };+ const BrushRecipe scales = recipe("Dragon Scales"), wrinkle = recipe("Wrinkle");+ Symmetry sym;+ auto sculpt = [&](const BrushRecipe* r) {+ Document doc = microDoc(4);+ CHECK(doc.sculptor.beginStroke(doc.mesh, "Recipe"));+ for (int i = 0; i < 6; ++i) {+ if (r) doc.sculptor.dabRecipe(doc.mesh, doc.bvh, *r, dabAt(glm::vec3(0, 0, 1), 0.3f), sym);+ else doc.sculptor.dab(doc.mesh, doc.bvh, BrushType::Standard, dabAt(glm::vec3(0, 0, 1), 0.3f), sym);+ }+ doc.undo.push(doc.sculptor.endStroke());+ CHECK(watertight(doc.mesh));+ return doc;+ };+ const float h0 = frontHeight(microDoc(4));+ const Document plain = sculpt(nullptr), scaled = sculpt(&scales), carved = sculpt(&wrinkle);+ CHECK(frontHeight(scaled) > h0 + 0.001f);+ CHECK(frontHeight(carved) < h0 - 0.001f);+ // The pattern: the scales' displacement differs from Standard's smooth bump over many grid points.+ const auto& a = plain.mesh.micro->disp;+ const auto& b = scaled.mesh.micro->disp;+ CHECK(a.size() == b.size());+ size_t differ = 0;+ for (size_t i = 0; i < a.size(); ++i) differ += std::abs(int(a[i]) - int(b[i])) > 2;+ CHECK(differ > 1000);+}+TEST(micro_brushes_each_change_the_surface_and_stay_closed) {struct Case {BrushType type;