Skip to content

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.

Merge texture transfer (Auto UV keeps paint, Keep Texture on remesh/QRemesh/merge, Decimate seams, xatlas fix)

islandmed71b032820181
diff --cc docs/guide/subtools.md
index f2f1e8ef,39cb8141..48cb49bc
--- a/docs/guide/subtools.md
+++ b/docs/guide/subtools.md
@@@ -92,10 -92,12 +92,14 @@@ The up and down arrow buttons under th
they are.
Merging keeps every attribute, gives each original mesh its own polygroups (so you can split them again later) and
-matches sculpt layers by name. The merged SubTool starts with an empty undo history.
+matches sculpt layers by name. The merged SubTool starts with an empty undo history. A SubTool with
+[subdivision levels](subdivision-levels.md) is merged (or split) at the level it is on, which becomes the base of
+the result; the status line names the SubTools that lost their levels.
+ Painted textures are kept too: the merged SubTool gets new Auto UVs and one texture, the size of the largest,
+ holding each part's paint exactly (texture layers are flattened; parts without a texture are white). On big
+ meshes the Auto UV takes a while. Scripts can skip it with `keep_texture=false`, which drops the textures.
+
> **Tip:** Merge first when you want one [voxel remesh](geometry.md#voxel-remesh) to fuse several pieces into a
> single watertight surface.
diff --cc src/app/PanelRetopo.cpp
index 3a3090f3,64c3c3dc..219b3641
--- a/src/app/PanelRetopo.cpp
+++ b/src/app/PanelRetopo.cpp
@@@ -103,7 -120,81 +120,82 @@@ void App::startQRemesh()
" quads...";
}
+ void App::startVoxelRemesh() {
+ if (voxelRemesh_) return;
+ Args args{{"resolution", double(voxelResolution_)}};
+ if (!hasTexture(doc_.mesh) || !keepTexture_) {
+ if (hasTexture(doc_.mesh)) args["keep_texture"] = false; // Keep Texture off
+ runCommand("remesh", args);
+ return;
+ }
+ // Keeping a texture adds Auto UV of the result, which takes seconds to minutes: run it all in the background.
+ if (doc_.sculptor.strokeActive()) endStroke();
+ auto job = std::make_unique<VoxelRemeshJob>();
+ job->progress = std::make_shared<std::atomic<float>>(0.0f);
+ job->cancel = std::make_shared<std::atomic<bool>>(false);
+ job->result = std::make_shared<Mesh>();
+ job->error = std::make_shared<std::string>();
+ job->note = std::make_shared<std::string>();
+ job->subtool = doc_.activeSubtoolInfo().id;
+ job->triangles = doc_.mesh.triangleCount();
+ job->resolution = std::clamp(voxelResolution_, 32, 512);
+ std::promise<bool> promise;
+ job->done = promise.get_future();
+ std::thread([promise = std::move(promise), source = std::make_shared<Mesh>(doc_.mesh), res = job->resolution,
+ progress = job->progress, cancel = job->cancel, result = job->result, error = job->error,
+ note = job->note]() mutable {
+ progress->store(0.02f);
+ *result = voxelRemesh(*source, res, error.get());
+ bool ok = result->triangleCount() > 0;
+ progress->store(0.15f);
+ if (ok) *note = carryTextureNote(*source, *result, true, [&](float f) {
+ progress->store(0.15f + 0.85f * f);
+ return !cancel->load();
+ });
+ if (ok && cancel->load()) {
+ ok = false;
+ *error = "Voxel Remesh cancelled";
+ }
+ promise.set_value(ok);
+ }).detach();
+ voxelRemesh_ = std::move(job);
+ status_ = "Voxel Remesh: remeshing and keeping the texture...";
+ }
+
+ void App::pollVoxelRemesh() {
+ if (!voxelRemesh_) return;
+ if (voxelRemesh_->done.wait_for(std::chrono::seconds(0)) != std::future_status::ready) {
+ status_ = "Voxel Remesh (keeping the texture): " + std::to_string(int(voxelRemesh_->progress->load() * 100.0f)) + "%";
+ return;
+ }
+ const std::unique_ptr<VoxelRemeshJob> job = std::move(voxelRemesh_);
+ if (!job->done.get()) {
+ status_ = *job->error;
+ return;
+ }
+ int index = -1;
+ for (int i = 0; i < doc_.subtoolCount(); ++i)
+ if (doc_.subtools[size_t(i)].id == job->subtool) index = i;
+ if (index < 0 || doc_.subtoolMesh(index).triangleCount() != job->triangles) {
+ status_ = "Voxel Remesh skipped: the SubTool changed while it was being remeshed";
+ return;
+ }
+ if (index != doc_.activeSubtool) doc_.selectSubtool(index);
+ if (doc_.sculptor.strokeActive()) endStroke();
+ doc_.replaceMeshUndoable(std::move(*job->result), "Remesh"); // as the remesh command
- const CommandResult r{true, "Remeshed to " + std::to_string(doc_.mesh.triangleCount()) + " triangles" + *job->note};
++ CommandResult r{true, "Remeshed to " + std::to_string(doc_.mesh.triangleCount()) + " triangles" + *job->note};
++ if (const std::string notice = doc_.takeNotice(); !notice.empty()) r.message += ". " + notice; // levels dropped
+ status_ = r.message;
+ lastCommandOk_ = true;
+ clearLods();
+ playingLayer_ = -1;
+ uvLinesKey_ = 0;
+ updateTitle();
+ consoleEcho("remesh", {{"resolution", double(job->resolution)}}, r);
+ }
+
void App::pollQRemesh() {
+ pollVoxelRemesh(); // polled with QRemesh, its sibling rebuild job
if (!qremesh_) return;
if (qremesh_->done.wait_for(std::chrono::seconds(0)) != std::future_status::ready) {
status_ = "QRemesh: " + std::to_string(int(qremesh_->progress->load() * 100.0f)) + "%";
@@@ -124,8 -215,7 +216,8 @@@
}
if (index != doc_.activeSubtool) doc_.selectSubtool(index);
if (doc_.sculptor.strokeActive()) endStroke();
- CommandResult r{true, applyQRemesh(doc_, std::move(*job->result), job->keepOriginal, *job->stats)};
+ CommandResult r{true, applyQRemesh(doc_, std::move(*job->result), job->keepOriginal, *job->stats) + *job->textureNote};
+ if (const std::string notice = doc_.takeNotice(); !notice.empty()) r.message += ". " + notice; // levels dropped
status_ = r.message;
lastCommandOk_ = true;
clearLods();
diff --cc src/app/UiTest.cpp
index 744f1121,f2270ece..8218fe1e
--- a/src/app/UiTest.cpp
+++ b/src/app/UiTest.cpp
@@@ -770,10 -766,8 +770,10 @@@ bool Demo::parseStep(int line, const st
const bool idle = !busy(app_.pendingBrush_) && !busy(app_.pendingGenerator_) && !busy(app_.pendingModels_) &&
!busy(app_.pendingUnreal_) && !busy(app_.pendingComfyCheck_) && !app_.galleryBusy() &&
!app_.thumbs_.busy() && !app_.libraryScanner_.busy() && !app_.autoUv_ &&
- !app_.bakeBusy() && !app_.qremesh_;
+ !app_.bakeBusy() && !app_.qremesh_ && !app_.voxelRemesh_;
- if (idle) return true;
+ *idleFrames = idle ? *idleFrames + 1 : 0;
+ if (*idleFrames >= 4) return true;
+ if (idle) return false;
SDL_Delay(10); // real work runs in real time
if (t > timeout) fail(line, "still busy after " + number(timeout) + " s");
return t > timeout;
diff --cc src/core/SubTools.cpp
index c1611f98,23a20509..6a30029a
--- a/src/core/SubTools.cpp
+++ b/src/core/SubTools.cpp
@@@ -365,7 -367,8 +368,9 @@@ void registerSubToolCommands(CommandReg
const int i = doc.activeSubtool;
if (i + 1 >= doc.subtoolCount()) return {false, "There's no SubTool below " + doc.activeSubtoolInfo().name};
Mesh merged = mergeMeshes({&doc.subtoolMesh(i), &doc.subtoolMesh(i + 1)});
+ const std::string texture = carryMergedTexturesNote({&doc.subtoolMesh(i), &doc.subtoolMesh(i + 1)}, merged,
+ argBool(a, "keep_texture", true));
+ for (int k : {i, i + 1}) noteSubtoolLevelsDropped(doc, k); // merged at their current levels
const std::string name = doc.subtools[size_t(i)].name, below = doc.subtools[size_t(i + 1)].name;
doc.removeSubtool(i + 1);
doc.replaceActiveMesh(std::move(merged));
@@@ -381,7 -385,11 +387,12 @@@
if (doc.subtools[size_t(i)].visible) visible.push_back(i);
if (visible.size() < 2) return {false, "Show at least two SubTools to merge"};
Mesh merged = mergedVisibleMesh(doc);
+ std::vector<const Mesh*> parts; // as mergedVisibleMesh gathers them
+ for (int i : visible)
+ if (doc.subtoolMesh(i).triangleCount()) parts.push_back(&doc.subtoolMesh(i));
+ const std::string texture =
+ parts.size() > 1 ? carryMergedTexturesNote(parts, merged, argBool(a, "keep_texture", true)) : std::string();
+ for (int k : visible) noteSubtoolLevelsDropped(doc, k); // merged at their current levels
const size_t tris = merged.triangleCount();
const int at = visible.front();
doc.addSubtool(std::move(merged), "Merged", true, at);