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
v0.9 merge fixes: rename the facial-shapes landmark struct to FaceFitLandmarks (clashed with Make sculptable's FaceLandmarks); phone scans train with the fake splat tools in UI tests; What's New test checks the newest section
islandmedb4798667c51b
diff --git a/CMakeLists.txt b/CMakeLists.txtindex 96bfa8d9..cf39b596 100644--- a/CMakeLists.txt+++ b/CMakeLists.txt@@ -503,11 +503,13 @@ if(SCULPTFORGE_BUILD_TESTS)add_test(NAME ui_${name} COMMAND sculptforge --ui-test ${script} --ui-out ${CMAKE_CURRENT_BINARY_DIR}/ui-shots/${name})set_tests_properties(ui_${name} PROPERTIES LABELS ui TIMEOUT 300)endforeach()- # Splat training runs the fake Brush / COLMAP / ffmpeg.- if(TEST ui_splat_train)- set_tests_properties(ui_splat_train PROPERTIES ENVIRONMENT- "SCULPTFORGE_BRUSH=$<TARGET_FILE:sf_fake_splat_tools>;SCULPTFORGE_COLMAP=$<TARGET_FILE:sf_fake_splat_tools>;SCULPTFORGE_FFMPEG=$<TARGET_FILE:sf_fake_splat_tools>")- endif()+ # Splat training (also started by a phone scan) runs the fake Brush / COLMAP / ffmpeg.+ foreach(t ui_splat_train ui_phone_link)+ if(TEST ${t})+ set_tests_properties(${t} PROPERTIES ENVIRONMENT+ "SCULPTFORGE_BRUSH=$<TARGET_FILE:sf_fake_splat_tools>;SCULPTFORGE_COLMAP=$<TARGET_FILE:sf_fake_splat_tools>;SCULPTFORGE_FFMPEG=$<TARGET_FILE:sf_fake_splat_tools>")+ endif()+ endforeach()# The shell layout again on a 1920x1080 window (docs/ui-design.md §2.3).add_test(NAME ui_shell_layout_1080 COMMAND sculptforge --ui-test ${CMAKE_CURRENT_SOURCE_DIR}/tests/ui/shell_layout.sfui--size 1920x1080 --ui-out ${CMAKE_CURRENT_BINARY_DIR}/ui-shots/shell_layout_1080)diff --git a/src/app/App.h b/src/app/App.hindex 5b69bd43..fec5058a 100644--- a/src/app/App.h+++ b/src/app/App.h@@ -382,7 +382,7 @@ private:void drawFaceOverlay();void animateFaceTake(float dt); // every frame (from animateLayers): file dialog results, take playbackstatic void SDLCALL onFaceTakeChosen(void* userdata, const char* const* files, int filter);- FaceLandmarks faceLandmarks_;+ FaceFitLandmarks faceLandmarks_;bool facePlacing_ = false;int facePlaceIndex_ = 0;int faceSymmetry_ = 0; // 0 Auto, 1 On, 2 Offdiff --git a/src/app/PanelFace.cpp b/src/app/PanelFace.cppindex afc99700..fcce30f4 100644--- a/src/app/PanelFace.cpp+++ b/src/app/PanelFace.cpp@@ -128,7 +128,7 @@ void App::registerFaceUiActions() {"face_landmarks_detect");add("face.landmarks_clear", "Clear Landmarks", ICON_LC_ERASER,[this] {- faceLandmarks_ = FaceLandmarks{};+ faceLandmarks_ = FaceFitLandmarks{};facePlacing_ = false;status_ = "Landmarks cleared: Generate fits automatically";},diff --git a/src/core/Face.cpp b/src/core/Face.cppindex 9c4d16ee..384b8cc0 100644--- a/src/core/Face.cpp+++ b/src/core/Face.cpp@@ -230,9 +230,9 @@ const char* faceLandmarkKey(int i) { return i >= 0 && i < kFaceLandmarkCount ? kconst char* faceLandmarkLabel(int i) { return i >= 0 && i < kFaceLandmarkCount ? kLandmarks[i].label : ""; }uint32_t faceLandmarkVertex(int i) { return i >= 0 && i < kFaceLandmarkCount ? kLandmarks[i].vertex : 0; }-int FaceLandmarks::count() const { return int(std::count(set.begin(), set.end(), true)); }+int FaceFitLandmarks::count() const { return int(std::count(set.begin(), set.end(), true)); }-Json FaceLandmarks::toJson() const {+Json FaceFitLandmarks::toJson() const {Json j = Json::object();for (int i = 0; i < kFaceLandmarkCount; ++i) {if (!set[size_t(i)]) continue;@@ -243,8 +243,8 @@ Json FaceLandmarks::toJson() const {return j;}-bool FaceLandmarks::fromJson(const Json& j, FaceLandmarks& out, std::string& error) {- FaceLandmarks l;+bool FaceFitLandmarks::fromJson(const Json& j, FaceFitLandmarks& out, std::string& error) {+ FaceFitLandmarks l;if (!j.isObject()) {error = "Landmarks must be a JSON object like {\"nose_tip\":[0,1.6,0.1]}";return false;@@ -452,7 +452,7 @@ struct FitScore {// Similarity ICP over the face vertices (every `stride`-th); returns the last iteration's score.FitScore similarityIcp(const TriangleBVH& sculpt, const FaceTemplate& t, const std::vector<glm::vec3>& templNormals,- const FaceLandmarks* landmarks, Similarity& align, int iterations, uint32_t stride) {+ const FaceFitLandmarks* landmarks, Similarity& align, int iterations, uint32_t stride) {FitScore score;std::vector<glm::vec3> pos(t.neutral.size()), nrm(t.neutral.size());Correspondences c;@@ -509,7 +509,7 @@ FitScore similarityIcp(const TriangleBVH& sculpt, const FaceTemplate& t, const s} // namespacebool fitFaceTemplate(const std::vector<glm::vec3>& positions, const std::vector<glm::uvec3>& triangles,- const FaceLandmarks* landmarksIn, FaceFit& out, std::string& error) {+ const FaceFitLandmarks* landmarksIn, FaceFit& out, std::string& error) {const TemplateData& td = templateData();const FaceTemplate& t = td.t;if (t.neutral.empty()) {@@ -520,7 +520,7 @@ bool fitFaceTemplate(const std::vector<glm::vec3>& positions, const std::vector<error = "The mesh is empty";return false;}- const FaceLandmarks* landmarks = landmarksIn && landmarksIn->count() >= 3 ? landmarksIn : nullptr;+ const FaceFitLandmarks* landmarks = landmarksIn && landmarksIn->count() >= 3 ? landmarksIn : nullptr;if (landmarksIn && landmarksIn->count() > 0 && !landmarks) {error = "Place at least 3 landmarks (or none, for the automatic fit)";return false;diff --git a/src/core/Face.h b/src/core/Face.hindex 5508d50b..94e01a91 100644--- a/src/core/Face.h+++ b/src/core/Face.h@@ -79,13 +79,13 @@ const char* faceLandmarkKey(int i); // "eye_outer_right", ... (JSON keys)const char* faceLandmarkLabel(int i); // "Right eye, outer corner", ...uint32_t faceLandmarkVertex(int i); // the template vertex-struct FaceLandmarks {+struct FaceFitLandmarks {std::array<glm::vec3, kFaceLandmarkCount> position{};std::array<bool, kFaceLandmarkCount> set{};int count() const;Json toJson() const;// {"nose_tip":[x,y,z], ...}; unknown keys are an error.- static bool fromJson(const Json& j, FaceLandmarks& out, std::string& error);+ static bool fromJson(const Json& j, FaceFitLandmarks& out, std::string& error);};// Uniform scale, rotation and translation (template -> sculpt).@@ -101,7 +101,7 @@ struct Similarity {struct FaceFit {Similarity align; // the rigid part of the fitstd::vector<glm::vec3> positions; // the template's vertices wrapped onto the sculpt (sculpt space)- FaceLandmarks landmarks; // the template's landmarks after the fit (sculpt space)+ FaceFitLandmarks landmarks; // the template's landmarks after the fit (sculpt space)float rmsError = 0.0f; // face vertices that found the sculpt: RMS distance to it (sculpt units)float coverage = 0.0f; // the fraction of face vertices that found the sculpt};@@ -109,7 +109,7 @@ struct FaceFit {// Fits the template to the visible triangles of `positions` / `triangles` (the sculpt with its layers at zero).// `landmarks` (optional, at least 3 set) start the fit and pull their template vertices all the way.bool fitFaceTemplate(const std::vector<glm::vec3>& positions, const std::vector<glm::uvec3>& triangles,- const FaceLandmarks* landmarks, FaceFit& out, std::string& error);+ const FaceFitLandmarks* landmarks, FaceFit& out, std::string& error);// Deformation transfer: the offsets (sculpt space, per template vertex) of every template shape on the fitted// template, in arkitBlendShapeNames() order. On the template itself this gives back its own shapes.@@ -118,7 +118,7 @@ void transferFaceShapes(const FaceFit& fit, std::vector<std::vector<glm::vec3>>&constexpr size_t kFaceMinVertices = 20000;struct FaceShapesOptions {- FaceLandmarks landmarks; // none set = automatic+ FaceFitLandmarks landmarks; // none set = automaticint symmetry = -1; // -1 = when the sculpt is symmetric about X = 0, 0 = off, 1 = onbool subtools = true; // eyes, teeth, tongue and SubTools on the face get the shapes tooint level = -1; // subdivision level to make them on (-1 = the lowest with kFaceMinVertices)diff --git a/src/core/FaceCommands.cpp b/src/core/FaceCommands.cppindex 146521c0..3b2ae9c3 100644--- a/src/core/FaceCommands.cpp+++ b/src/core/FaceCommands.cpp@@ -115,7 +115,7 @@ void registerFaceCommands(CommandRegistry& registry) {const std::string lm = argString(a, "landmarks");if (!lm.empty()) {Json j;- if (!Json::parse(lm, j, error) || !FaceLandmarks::fromJson(j, o.landmarks, error))+ if (!Json::parse(lm, j, error) || !FaceFitLandmarks::fromJson(j, o.landmarks, error))return {false, "Landmarks: " + error};}const std::string sym = argString(a, "symmetry", "auto");diff --git a/tests/test_face.cpp b/tests/test_face.cppindex 6b7fb64f..f47d0ccc 100644--- a/tests/test_face.cpp+++ b/tests/test_face.cpp@@ -212,7 +212,7 @@ TEST(face_fit_finds_the_landmarks_on_a_known_head) {CHECK(fit.coverage > 0.8f);// With the landmarks placed (as the artist would click them, a little off): closer still.- FaceLandmarks lm;+ FaceFitLandmarks lm;for (int l = 0; l < kFaceLandmarkCount; ++l) {lm.position[size_t(l)] = otherPerson(t.neutral[faceLandmarkVertex(l)]) + glm::vec3(0.0005f, -0.0003f, 0.0f);lm.set[size_t(l)] = true;@@ -227,7 +227,7 @@ TEST(face_fit_finds_the_landmarks_on_a_known_head) {CHECK(worstGuided < 0.01f * height);// Too few landmarks is an error, not a bad fit.- FaceLandmarks two;+ FaceFitLandmarks two;two.set[kNoseTip] = two.set[kChin] = true;CHECK(!fitFaceTemplate(head.positions, head.triangles, &two, guided, error));// A sphere has no face: the fit runs but finds little of the template on it.diff --git a/tests/ui/phone_link.sfui b/tests/ui/phone_link.sfuiindex 6dada831..7beef969 100644--- a/tests/ui/phone_link.sfui+++ b/tests/ui/phone_link.sfui@@ -31,12 +31,15 @@ wait 0.2expect_text "iPhone"expect_status "Phone connected"-# A scan (a few photos here): saved to Captures; splat training belongs to the splat feature.+# A scan (a few photos here): saved to Captures and handed to splat training, which (rightly) turns down+# two photos with a clear message; tests/ui/splat_train.sfui trains a full capture.phone_upload splat data/phone/scan_01.png data/phone/scan_02.pngwait 0.2expect_value phone_captures == 1-expect_status "Scan received"expect_text "-splat"+wait_idle 120+expect_value splat_train_stage == 5+expect_status "Only 2 usable photos"# A splat .ply from a scanning app loads next to the sculpt.phone_upload ply data/phone/scan_splat.plydiff --git a/tests/ui/whats_new.sfui b/tests/ui/whats_new.sfuiindex 9d0c7f3c..4e051d89 100644--- a/tests/ui/whats_new.sfui+++ b/tests/ui/whats_new.sfui@@ -10,6 +10,6 @@ expect_text "Version 0.7"expect_text "Version 0.6"expect_text "Version 0.5"expect_text "Version 0.4.2"-expect_text "More like ZBrush"# The newest section is on screen.+expect_text "Facial shapes and live face"shot whats-new