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.

Kelvinlet brushes, Capture from view and Detail Clone in the app

islandmedf2de50e954dd
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 631affde..c948ee20 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -232,6 +232,7 @@ if(SCULPTFORGE_BUILD_APP)
src/app/Selection.cpp
src/app/PanelBrushes.cpp
src/app/PanelVdm.cpp
+ src/app/PanelKelvinlet.cpp
src/app/PanelFace.cpp
src/app/PanelBrushLibrary.cpp
src/app/PanelBrushGallery.cpp
diff --git a/src/app/App.cpp b/src/app/App.cpp
index 20b9c572..3e6c482b 100644
--- a/src/app/App.cpp
+++ b/src/app/App.cpp
@@ -716,6 +716,9 @@ int App::run() {
sm.start = sm.lastFrame = seconds();
strokeProbe_ = &sm.dabs;
if (options_.measureStrokeRadius > 0.0f) radiusPx_ = std::clamp(options_.measureStrokeRadius, 2.0f, 800.0f);
+ if (const char* b = std::getenv("SF_MEASURE_BRUSH")) // e.g. KelvinGrab: measure another built-in brush
+ for (int i = 0; i < int(BrushType::Count); ++i)
+ if (SDL_strcasecmp(brushName(BrushType(i)), b) == 0) brush_ = BrushType(i), doc_.activeBrush = -1;
onMouseDown(sm.cx + sm.r, sm.cy, SDL_BUTTON_LEFT);
if (drag_ != Drag::Stroke) {
std::printf("Stroke: no stroke began (nothing to sculpt under the circle's start)\n");
@@ -954,6 +957,7 @@ void App::onMouseDown(float x, float y, Uint8 button) {
if (guideMouseDown(x, y, mod)) return; // the QRemesh Guides brush (PanelRetopo.cpp)
if (faceMouseDown(x, y, mod)) return; // placing facial landmarks (PanelFace.cpp)
if (sculptableMouseDown(x, y)) return; // Make sculptable: landmarks, crop box (PanelSculptable.cpp)
+ if (captureMouseDown(x, y)) return; // Capture from view: the drag draws the square (PanelKelvinlet.cpp)
// Alt+click on another SubTool selects it (ZBrush); Alt+drag stays an inverted stroke or a pan.
// Shift+Alt+click selects and frames it (ZBrush), the active one too.
const bool frameClick = (mod & SDL_KMOD_ALT) && (mod & SDL_KMOD_SHIFT) && !ctrlDown(mod);
@@ -1061,6 +1065,7 @@ void App::onMouseMove(float x, float y, float dx, float dy, bool fromPen) {
case Drag::Gizmo: gizmoDragTo(x, y); break;
case Drag::Guide: guideDragTo(x, y); break;
case Drag::Sculptable: sculptableMouseMove(x, y); break;
+ case Drag::Capture: captureMouseMove(x, y); break;
case Drag::ZSphere: zsphereDragTo(x, y); break;
case Drag::None: break;
}
@@ -1110,6 +1115,7 @@ void App::onMouseUp() {
if (drag_ == Drag::SubToolClick) subtoolClickRelease();
if (drag_ == Drag::Guide) guideRelease();
if (drag_ == Drag::Sculptable) sculptableMouseUp();
+ if (drag_ == Drag::Capture) captureMouseUp();
if (drag_ == Drag::ZSphere) zsphereRelease();
gizmoRelease();
drag_ = Drag::None;
@@ -1119,6 +1125,11 @@ void App::onMouseUp() {
void App::onKey(SDL_Keycode key, SDL_Keymod mod) {
if (captureShortcutKey(key, mod)) return; // Ctrl+Alt+click a button, then press its new key
+ if (key == SDLK_ESCAPE && capture_.armed) { // Capture from view waiting for its square (PanelKelvinlet.cpp)
+ capture_.armed = false;
+ status_ = "Capture cancelled";
+ return;
+ }
if (lightBoxKey(key, mod)) return; // , LightBox, B / M pickers, S / I pop-ups (LightBox.cpp)
// Blender's Emulate Numpad: the number row works as the numpad, unless the key itself has an action.
if (blenderStyle() && uiPrefs_.emulateNumpad && key >= SDLK_0 && key <= SDLK_9 &&
@@ -1175,8 +1186,12 @@ void App::beginStroke(float x, float y, const RayHit& hit) {
grabPlanePoint_ = grabLast_ = hit.position;
return;
}
+ if (kelvinStrokeBrush()) { // KelvinGrab / Twist / Scale (PanelKelvinlet.cpp)
+ kelvinBegin(hit);
+ return;
+ }
lazyMouse_.reset(glm::vec2(x, y));
- if (strokeBrush_ == BrushType::SnakeHook && !recipe && strokeSculpt_) {
+ if ((strokeBrush_ == BrushType::SnakeHook || strokeBrush_ == BrushType::KelvinSnake) && !recipe && strokeSculpt_) {
grabPlanePoint_ = grabLast_ = hit.position; // the pulled tip (see snakeHookTo)
return;
}
@@ -1211,7 +1226,11 @@ void App::strokeTo(float x, float y) {
grabLast_ = p;
return;
}
- if (strokeBrush_ == BrushType::SnakeHook && !recipe && strokeSculpt_) {
+ if (kelvinStrokeBrush()) {
+ kelvinTo(x, y);
+ return;
+ }
+ if ((strokeBrush_ == BrushType::SnakeHook || strokeBrush_ == BrushType::KelvinSnake) && !recipe && strokeSculpt_) {
snakeHookTo(x, y);
return;
}
@@ -1367,6 +1386,7 @@ void App::dabAt(float x, float y, float pressure) {
void App::endStroke() {
drainStrokeDabs(0.0); // the dabs still waiting belong to this stroke
+ doc_.sculptor.flushDetailClone(doc_.mesh, doc_.bvh, symmetry_); // a Detail Clone click
strokeMask_ = false;
maskClickPending_ = false; // (a command can end a Ctrl+click before its release)
firstDabPending_ = false;
@@ -1675,6 +1695,7 @@ void App::drawUi() {
drawFaceOverlay(); // facial landmarks (PanelFace.cpp)
drawSplatTrainOverlay(); // splat training progress (PanelSplatTrain.cpp)
drawSculptableOverlay(); // Make sculptable: crop box, face landmarks (PanelSculptable.cpp)
+ drawCaptureOverlay(); // Capture from view: the square, the result window (PanelKelvinlet.cpp)
// In Gizmo mode (and with the QRemesh Guides brush) the brush ring shows only while Ctrl masks or Shift smooths.
const bool ringOff = gizmoActive() || (guidesMode_ && !(inputMods() & SDL_KMOD_SHIFT)) || sculptableHot() || zsphereActive();
if (((!ImGui::GetIO().WantCaptureMouse && canvasRect().contains(mouse.x, mouse.y)) || drag_ == Drag::Stroke) &&
diff --git a/src/app/App.h b/src/app/App.h
index fffafe32..9f56bcfb 100644
--- a/src/app/App.h
+++ b/src/app/App.h
@@ -28,6 +28,7 @@
#include "core/SpaceMouse.h"
#include "core/Tablet.h"
#include "core/UpdateCheck.h"
+#include "core/ViewCapture.h"
#include "core/Texture.h"
#include "io/ArExport.h"
#include "link/PhoneLink.h"
@@ -117,7 +118,7 @@ public:
void queueFile(FileAction action, std::string path);
private:
- enum class Drag { None, Stroke, Orbit, Pan, Zoom, Roll, MaskCanvas, SubToolClick, Select, Gizmo, Guide, Sculptable, ZSphere };
+ enum class Drag { None, Stroke, Orbit, Pan, Zoom, Roll, MaskCanvas, SubToolClick, Select, Gizmo, Guide, Sculptable, ZSphere, Capture };
void handleEvent(const SDL_Event& e);
void onMouseDown(float x, float y, Uint8 button);
@@ -418,6 +419,32 @@ private:
float faceTakeTime_ = 0.0f;
std::mutex faceTakeMutex_;
std::string pendingFaceTake_; // set by the file dialog thread
+ // Kelvinlet brushes and Alpha / VDM from viewport (PanelKelvinlet.cpp, core/Kelvinlet.h, core/ViewCapture.h).
+ bool kelvinStrokeBrush() const; // KelvinGrab / Twist / Scale: the drag drives the brush, not dabs
+ void kelvinBegin(const RayHit& hit);
+ void kelvinTo(float x, float y);
+ void drawKelvinletSection();
+ void registerKelvinletActions();
+ bool captureMouseDown(float x, float y); // true while Capture from view is armed (it takes the drag)
+ void captureMouseMove(float x, float y);
+ void captureMouseUp();
+ void drawCaptureOverlay(); // the square being dragged and the result window
+ void drawCaptureWindow();
+ void recapture();
+ bool kelvinUiValue(const std::string& name, double& out) const; // UI test values (UiTest.cpp)
+ struct CaptureUi {
+ bool armed = false, circle = false, open = false, haveFrame = false;
+ glm::vec2 anchor{0.0f}, current{0.0f};
+ CaptureFrame frame;
+ CaptureOptions options;
+ BrushAlpha alpha;
+ std::shared_ptr<const VectorDisplacement> vdm;
+ CaptureInfo alphaInfo, vdmInfo;
+ std::string error;
+ char name[64] = "Captured";
+ } capture_;
+ glm::vec3 kelvinCenter_{0.0f};
+ float kelvinRadius_ = 0.0f, kelvinLastX_ = 0.0f;
static void SDLCALL onVdmChosen(void* userdata, const char* const* files, int filter);
static void SDLCALL onVdmExportChosen(void* userdata, const char* const* files, int filter);
friend void drawVdmGrid(App&, GridMode);
diff --git a/src/app/AssetLibrary.h b/src/app/AssetLibrary.h
index bc2c3e96..e9733a4a 100644
--- a/src/app/AssetLibrary.h
+++ b/src/app/AssetLibrary.h
@@ -31,6 +31,7 @@ enum class AssetKind {
Material, // matcap (index; -1 = Studio)
Image, // reference image
Splat, // Gaussian splat capture (.ply .splat, splat .glb)
+ Vdm, // vector displacement map in the brush library (name; Capture from view saves these)
};
enum class Primitive { Sphere, Cube, Plane, Count };
diff --git a/src/app/Config.cpp b/src/app/Config.cpp
index ac6e7afe..4ea1225b 100644
--- a/src/app/Config.cpp
+++ b/src/app/Config.cpp
@@ -476,6 +476,7 @@ void App::initActions() {
registerSplatTrainUi(); // Splats > Train from capture (PanelSplatTrain.cpp)
registerSculptableUiActions(); // Splats > Make sculptable (PanelSculptable.cpp)
registerVdmActions(); // Brush > Vector Displacement (PanelVdm.cpp)
+ registerKelvinletActions(); // Brush > Kelvinlet & Capture: Capture from view (PanelKelvinlet.cpp)
registerFaceUiActions(); // Tool > Facial Shapes, face_take_play / face_take_stop (PanelFace.cpp)
registerPerformanceUiActions(); // Preferences > Performance (PanelPerformance.cpp)
registerInputActions(); // ZBrush keys: U I O, Space, L, V, Ctrl+A / I / H / W..., the input style (Input.cpp)
diff --git a/src/app/LightBox.cpp b/src/app/LightBox.cpp
index db2d5a55..590279ff 100644
--- a/src/app/LightBox.cpp
+++ b/src/app/LightBox.cpp
@@ -73,6 +73,8 @@ const char* glyphFor(AssetKind k) {
return ICON_LC_IMAGE;
case AssetKind::Splat:
return ICON_LC_SPARKLES;
+ case AssetKind::Vdm:
+ return ICON_LC_STAMP;
}
return ICON_LC_BOX;
}
@@ -228,6 +230,15 @@ void LightBox::rootEntries(App& app, std::vector<AssetEntry>& out) {
}
out.push_back(std::move(e));
}
+ // Vector displacement brushes from the library (built-ins are in the VDM picker).
+ for (const auto& v : app.doc_.vdms) {
+ if (v->builtin) continue;
+ AssetEntry e;
+ e.kind = AssetKind::Vdm;
+ e.name = v->name;
+ e.path = v->path;
+ out.push_back(std::move(e));
+ }
break;
case LibraryTab::Alpha: {
for (int i = 0; i < 3; ++i) {
@@ -360,6 +371,10 @@ ImTextureID LightBox::thumbnail(App& app, const AssetEntry& e) {
return t.alpha(builtinAlpha(e.index));
case AssetKind::Material:
return t.material(e.index);
+ case AssetKind::Vdm: {
+ const int i = findVdm(app.doc_, e.name);
+ return i >= 0 ? t.vdm(app.doc_.vdms[size_t(i)]) : ImTextureID(0);
+ }
default:
return ImTextureID(0);
}
@@ -428,6 +443,9 @@ void LightBox::activate(App& app, const AssetEntry& e, bool append) {
case AssetKind::BrushFile:
app.runCommand("brush_load", {{"path", e.path}});
return;
+ case AssetKind::Vdm: // the VDM brush with this map (Detail Clone keeps the brush, swapping its map)
+ app.runCommand("vdm_set", {{"name", e.name}});
+ return;
case AssetKind::Alpha:
app.runCommand("brush_set_alpha", {{"name", lower(kAlphaNames[std::clamp(e.index, 0, 2)])}});
return;
diff --git a/src/app/Palettes.cpp b/src/app/Palettes.cpp
index bbe4ec8d..4c5b3456 100644
--- a/src/app/Palettes.cpp
+++ b/src/app/Palettes.cpp
@@ -242,6 +242,10 @@ void App::drawPalette_Brush() {
}
}
}
+ if (subpalette("brush.kelvinlet", "Kelvinlet & Capture")) {
+ tray::Section section;
+ drawKelvinletSection(); // PanelKelvinlet.cpp
+ }
if (subpalette("brush.vdm", "Vector Displacement")) {
tray::Section section;
drawVdmSection(); // PanelVdm.cpp
diff --git a/src/app/PanelBrushes.cpp b/src/app/PanelBrushes.cpp
index cdbd81f4..3cc57544 100644
--- a/src/app/PanelBrushes.cpp
+++ b/src/app/PanelBrushes.cpp
@@ -96,7 +96,7 @@ void App::snakeHookTo(float x, float y) {
p.strokeDelta = delta / float(steps);
for (int i = 0; i < steps; ++i) {
p.center = grabLast_;
- doc_.sculptor.dab(doc_.mesh, doc_.bvh, BrushType::SnakeHook, p, symmetry_);
+ doc_.sculptor.dab(doc_.mesh, doc_.bvh, strokeBrush_, p, symmetry_); // SnakeHook or KelvinSnake
grabLast_ += p.strokeDelta;
}
}
diff --git a/src/app/PanelKelvinlet.cpp b/src/app/PanelKelvinlet.cpp
new file mode 100644
index 00000000..f04654b8
--- /dev/null
+++ b/src/app/PanelKelvinlet.cpp
@@ -0,0 +1,433 @@
+// SculptForge - open source digital sculpting
+// SPDX-License-Identifier: GPL-3.0-or-later
+//
+// Kelvinlet brushes and Alpha / VDM from viewport in the app (core/Kelvinlet.h, core/ViewCapture.h):
+// - KelvinGrab drags the grabbed point in the view plane, as Move does; KelvinTwist and KelvinScale act where
+// the stroke began and a drag to the right turns clockwise / swells (to the left: back / pinches);
+// KelvinSnake goes through snakeHookTo (PanelBrushes.cpp) and Detail Clone through the normal dabs.
+// - Brush > Kelvinlet: Squash (Poisson's ratio), Sharpness, the Detail Clone spacing.
+// - Capture from view (Ctrl+Alt+C): drag a square (or circle) over the model; a window shows the captured
+// height alpha and VDM, their options, and Use / Save to library buttons.
+#include "app/App.h"
+#include "app/Ui.h"
+
+#include "core/BrushLibrary.h"
+
+#include <IconsLucide.h>
+
+#include <algorithm>
+#include <cmath>
+#include <cstring>
+#include <filesystem>
+
+namespace sf {
+
+namespace {
+
+constexpr float kPi = 3.14159265f;
+
+void hint(const char* text) {
+ ImGui::PushStyleColor(ImGuiCol_Text, ImGui::GetStyleColorVec4(ImGuiCol_TextDisabled));
+ ImGui::TextWrapped("%s", text);
+ ImGui::PopStyleColor();
+}
+
+bool dragBrush(BrushType t) {
+ return t == BrushType::KelvinGrab || t == BrushType::KelvinTwist || t == BrushType::KelvinScale;
+}
+
+std::string vec3Arg(const glm::vec3& v) {
+ char buf[96];
+ std::snprintf(buf, sizeof buf, "%.6g,%.6g,%.6g", v.x, v.y, v.z);
+ return buf;
+}
+
+} // namespace
+
+bool App::kelvinStrokeBrush() const { return dragBrush(strokeBrush_) && !strokeRecipe() && strokeSculpt_; }
+
+// ---------------------------------------------------------------------------
+// Strokes
+// ---------------------------------------------------------------------------
+
+void App::kelvinBegin(const RayHit& hit) {
+ const float pressure = pressureSize_ ? std::max(strokePressure(), 0.05f) : 1.0f;
+ kelvinCenter_ = hit.position;
+ kelvinRadius_ = radiusPx_ * pressure * camera_.worldPerPixel(hit.position, canvasHeight());
+ grabPlanePoint_ = grabLast_ = hit.position;
+ kelvinLastX_ = lastX_;
+ lastDabScreen_ = glm::vec2(lastX_, lastY_);
+}
+
+void App::kelvinTo(float x, float y) {
+ if (strokeProbe_) strokeProbe_->emplace_back(x, y); // --measure-stroke counts each drag step as a dab
+ const float pressure = pressureStrength_ ? strokePressure() : 1.0f;
+ const float amount = std::min(1.0f, 2.0f * strength_) * pressure;
+ KelvinletStep step;
+ step.radius = kelvinRadius_;
+ step.viewDir = camera_.forward();
+ step.axis = -camera_.forward();
+ step.frontFacesOnly = frontFacesOnly_;
+ if (strokeBrush_ == BrushType::KelvinGrab) {
+ // The grabbed point follows the cursor in the plane through it facing the camera (as Move).
+ glm::vec3 origin, dir;
+ canvasRay(x, y, origin, dir);
+ const glm::vec3 n = camera_.forward();
+ const float denom = glm::dot(dir, n);
+ if (std::abs(denom) < 1e-6f) return;
+ const glm::vec3 target = origin + dir * (glm::dot(grabPlanePoint_ - origin, n) / denom);
+ const glm::vec3 delta = target - grabLast_;
+ // One pass integrates the drag in pieces (the elastic flow, not one big shear).
+ step.center = grabLast_;
+ step.delta = delta * amount;
+ step.travel = delta;
+ step.substeps = std::clamp(int(std::ceil(glm::length(delta) / (0.4f * kelvinRadius_))), 1, 16);
+ static const bool log = std::getenv("SF_KELVIN_LOG") != nullptr;
+ const SculptTimings before = doc_.sculptor.timings;
+ doc_.sculptor.kelvinletStep(doc_.mesh, doc_.bvh, strokeBrush_, step, symmetry_);
+ if (log) {
+ const SculptTimings& t = doc_.sculptor.timings;
+ SDL_Log("kelvin: %d pieces, %llu vertices, kernel %.1f normals %.1f bvh %.1f ms", step.substeps,
+ (unsigned long long)(t.vertices - before.vertices), t.kernelMs - before.kernelMs,
+ t.normalsMs - before.normalsMs, t.bvhMs - before.bvhMs);
+ }
+ grabLast_ = target;
+ } else {
+ // Twist / Scale: the drag's sideways distance in brush radii (Alt reverses).
+ const float dx = (x - kelvinLastX_) / std::max(radiusPx_, 1.0f) * amount * (strokeInvert_ ? -1.0f : 1.0f);
+ if (dx == 0.0f) return;
+ step.center = kelvinCenter_;
+ const float total = strokeBrush_ == BrushType::KelvinTwist ? -dx * 0.5f * kPi : dx * 0.6f;
+ // (Rotations about one axis compose exactly, and Scale integrates its own flow: one pass.)
+ if (strokeBrush_ == BrushType::KelvinTwist) step.angle = total;
+ else step.logScale = total;
+ doc_.sculptor.kelvinletStep(doc_.mesh, doc_.bvh, strokeBrush_, step, symmetry_);
+ }
+ kelvinLastX_ = x;
+ lastDabScreen_ = glm::vec2(x, y);
+}
+
+// ---------------------------------------------------------------------------
+// Brush > Kelvinlet
+// ---------------------------------------------------------------------------
+
+void App::drawKelvinletSection() {
+ KelvinletSettings& k = doc_.sculptor.kelvinlet;
+ const char* help = "Brush > Kelvinlet";
+ ImGui::SetNextItemWidth(-1);
+ float squash = k.squash * 100.0f;
+ if (ui::SliderInside("##kelvinsquash", &squash, 0.0f, 100.0f, "Squash %.0f")) k.squash = squash / 100.0f;
+ ui::HelpText("Squash", nullptr,
+ "How the Kelvinlet brushes' material keeps its volume (Poisson's ratio): 0 is rubbery (it stretches "
+ "without bulging), 100 is incompressible clay (pressing in bulges the surface up around the thumb, "
+ "pulling out draws the sides in).",
+ help);
+ ImGui::SetNextItemWidth(-1);
+ float sharp = k.sharpness * 100.0f;
+ if (ui::SliderInside("##kelvinsharp", &sharp, 0.0f, 100.0f, "Sharpness %.0f")) k.sharpness = sharp / 100.0f;
+ ui::HelpText("Sharpness", nullptr,
+ "A tighter, more pointed peak at the brush centre with the same soft reach (a smaller inner scale of "
+ "the multi-scale Kelvinlet): for pulling points and tips.",
+ help);
+ ImGui::SetNextItemWidth(-1);
+ ui::SliderInside("##clonespacing", &k.cloneSpacing, 0.25f, 3.0f, "Clone Spacing %.2f");
+ ui::HelpText("Clone Spacing", nullptr,
+ "Detail Clone: the distance between stamps along the stroke, in stamp widths (1 = edge to edge).", help);
+ ImGui::Checkbox("Clone follows stroke", &k.cloneFollowStroke);
+ ui::HelpText("Clone follows stroke", nullptr,
+ "Detail Clone: each stamp's top turns with the stroke (a row of scales or rivets along a curve); off, "
+ "every stamp keeps the screen's up.",
+ help);
+ ImGui::Dummy(ImVec2(0, 2.0f * uiScale_));
+ ui::ActionButton(*this, "brush.capture_view", ImVec2(ImGui::GetContentRegionAvail().x, 0));
+ hint("KelvinGrab moves like Move with elastic, volume-keeping falloff. KelvinTwist and KelvinScale act where you "
+ "press: drag right to turn clockwise or swell, left to turn back or pinch. KelvinSnake pulls tapering horns. "
+ "Detail Clone stamps the VDM brush's map along the stroke: capture one from the model with Capture from "
+ "view.");
+}
+
+void App::registerKelvinletActions() {
+ Action a;
+ a.id = "brush.capture_view";
+ a.label = "Capture from view";
+ a.icon = ICON_LC_SCAN_LINE;
+ a.palette = "Brush > Kelvinlet";
+ a.shortcut = "Ctrl+Alt+C";
+ a.description = "Alpha and VDM from the viewport: drag a square over any sculpted detail (Shift for a circle) and "
+ "capture it as a grayscale height alpha and as a vector displacement brush, ready to stamp with "
+ "the VDM brush or along strokes with Detail Clone, and to save in your library.";
+ a.run = [this] {
+ capture_.armed = !capture_.armed;
+ status_ = capture_.armed ? "Capture: drag a square over the model (Shift: circle); Esc cancels" : "Capture off";
+ };
+ a.checked = [this] { return capture_.armed; };
+ actions_.add(std::move(a));
+}
+
+// ---------------------------------------------------------------------------
+// Capture from view
+// ---------------------------------------------------------------------------
+
+bool App::captureMouseDown(float x, float y) {
+ if (!capture_.armed) return false;
+ capture_.anchor = capture_.current = glm::vec2(x, y);
+ capture_.circle = (inputMods() & SDL_KMOD_SHIFT) != 0;
+ drag_ = Drag::Capture;
+ return true;
+}
+
+void App::captureMouseMove(float x, float y) { capture_.current = glm::vec2(x, y); }
+
+namespace {
+
+// The square (centre, half side) in window pixels a capture drag describes: corner to corner, kept square;
+// a circle is dragged from its centre.
+void captureSquare(const glm::vec2& a, const glm::vec2& b, bool circle, glm::vec2& centre, float& half) {
+ if (circle) {
+ centre = a;
+ half = glm::length(b - a);
+ return;
+ }
+ const glm::vec2 d = b - a;
+ half = 0.5f * std::max(std::abs(d.x), std::abs(d.y));
+ centre = a + glm::vec2(d.x < 0.0f ? -half : half, d.y < 0.0f ? -half : half);
+}
+
+} // namespace
+
+void App::captureMouseUp() {
+ glm::vec2 centre;
+ float half = 0.0f;
+ captureSquare(capture_.anchor, capture_.current, capture_.circle, centre, half);
+ capture_.armed = false;
+ if (half < 4.0f) {
+ status_ = "Capture: drag a larger square";
+ return;
+ }
+ RayHit hit;
+ if (!pick(centre.x, centre.y, hit)) {
+ // The centre misses (a square over an edge): the nearest point of the model inside the square.
+ bool found = false;
+ for (int ring = 1; ring <= 6 && !found; ++ring)
+ for (int k = 0; k < 8 * ring && !found; ++k) {
+ const float ang = 2.0f * kPi * float(k) / float(8 * ring);
+ const float r = half * float(ring) / 7.0f;
+ found = pick(centre.x + r * std::cos(ang), centre.y + r * std::sin(ang), hit);
+ }
+ if (!found) {
+ status_ = "Capture: the square must be over the model";
+ return;
+ }
+ // Keep the square where it was drawn: the point on the plane through the hit under the centre.
+ glm::vec3 origin, dir;
+ canvasRay(centre.x, centre.y, origin, dir);
+ const glm::vec3 n = camera_.forward();
+ hit.position = origin + dir * (glm::dot(hit.position - origin, n) / glm::dot(dir, n));
+ }
+ const float halfWorld = half * camera_.worldPerPixel(hit.position, canvasHeight());
+ capture_.frame = makeCaptureFrame(hit.position, camera_.forward(), screenUpVector(0.0f), halfWorld, capture_.circle);
+ capture_.haveFrame = true;
+ capture_.open = true;
+ recapture();
+}
+
+void App::recapture() {
+ if (!capture_.haveFrame) return;
+ doc_.syncBvh();
+ capture_.error.clear();
+ std::string err;
+ BrushAlpha alpha;
+ CaptureInfo ai, vi;
+ if (captureHeightAlpha(doc_.mesh, doc_.bvh, capture_.frame, capture_.options, alpha, err, &ai)) {
+ alpha.name = capture_.name[0] ? capture_.name : "Captured";
+ capture_.alpha = std::move(alpha);
+ capture_.alphaInfo = ai;
+ } else {
+ capture_.error = err;
+ }
+ VectorDisplacement vdm;
+ if (captureVdmFromView(doc_.mesh, doc_.bvh, capture_.frame, capture_.options, vdm, err, &vi)) {
+ vdm.name = capture_.name[0] ? capture_.name : "Captured";
+ capture_.vdm = std::make_shared<const VectorDisplacement>(std::move(vdm));
+ capture_.vdmInfo = vi;
+ } else if (capture_.error.empty()) {
+ capture_.error = err;
+ }
+ status_ = capture_.error.empty() ? "Captured: use it as an alpha, a VDM brush or with Detail Clone"
+ : "Capture: " + capture_.error;
+}
+
+void App::drawCaptureOverlay() {
+ if (drag_ == Drag::Capture) {
+ glm::vec2 c;
+ float half = 0.0f;
+ captureSquare(capture_.anchor, capture_.current, capture_.circle, c, half);
+ ImDrawList* dl = ImGui::GetForegroundDrawList();
+ const ImU32 col = ui::color::accent, fill = IM_COL32(255, 255, 255, 18);
+ const float t = 1.5f * uiScale_;
+ if (capture_.circle) {
+ dl->AddCircleFilled(ImVec2(c.x, c.y), half, fill, 64);
+ dl->AddCircle(ImVec2(c.x, c.y), half, col, 64, t);
+ } else {
+ dl->AddRectFilled(ImVec2(c.x - half, c.y - half), ImVec2(c.x + half, c.y + half), fill);
+ dl->AddRect(ImVec2(c.x - half, c.y - half), ImVec2(c.x + half, c.y + half), col, 0.0f, 0, t);
+ }
+ dl->AddLine(ImVec2(c.x - 6 * uiScale_, c.y), ImVec2(c.x + 6 * uiScale_, c.y), col, t);
+ dl->AddLine(ImVec2(c.x, c.y - 6 * uiScale_), ImVec2(c.x, c.y + 6 * uiScale_), col, t);
+ }
+ if (capture_.open) drawCaptureWindow();
+}
+
+void App::drawCaptureWindow() {
+ const float s = uiScale_;
+ ImGui::SetNextWindowSize(ImVec2(340.0f * s, 0.0f), ImGuiCond_Appearing);
+ const CanvasRect cr = canvasRect();
+ ImGui::SetNextWindowPos(ImVec2(cr.x + cr.w - 360.0f * s, cr.y + 60.0f * s), ImGuiCond_Appearing);
+ if (!ImGui::Begin("Capture from view##capture", &capture_.open, ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_AlwaysAutoResize)) {
+ ImGui::End();
+ return;
+ }
+ const float side = std::floor((ImGui::GetContentRegionAvail().x - ImGui::GetStyle().ItemSpacing.x) * 0.5f);
+ ImDrawList* dl = ImGui::GetWindowDrawList();
+ auto preview = [&](ImTextureID tex, const char* label) {
+ ImGui::BeginGroup();
+ const ImVec2 p0 = ImGui::GetCursorScreenPos();
+ ImGui::Dummy(ImVec2(side, side));
+ dl->AddRectFilled(p0, ImVec2(p0.x + side, p0.y + side), IM_COL32(30, 30, 34, 255), 4.0f * s);
+ if (tex) dl->AddImageRounded(tex, p0, ImVec2(p0.x + side, p0.y + side), ImVec2(0, 0), ImVec2(1, 1), IM_COL32_WHITE, 4.0f * s);
+ ImGui::TextDisabled("%s", label);
+ ImGui::EndGroup();
+ };
+ preview(capture_.alpha.empty() ? ImTextureID(0) : thumbs_.alpha(capture_.alpha), "Height alpha");
+ ImGui::SameLine();
+ preview(capture_.vdm ? thumbs_.vdm(capture_.vdm) : ImTextureID(0), "Vector displacement");
+ if (!capture_.error.empty()) ImGui::TextColored(ImVec4(1.0f, 0.55f, 0.4f, 1.0f), "%s", capture_.error.c_str());
+ else
+ ImGui::TextDisabled("%zu points, height %.3g, reach %.2f radii", capture_.vdmInfo.vertices,
+ capture_.alphaInfo.depthRange, capture_.vdmInfo.maxOffset);
+
+ bool again = false;
+ CaptureOptions& o = capture_.options;
+ const char* help = "Capture from view";
+ ImGui::SetNextItemWidth(-1);
+ float smooth = o.smoothing * 100.0f;
+ if (ui::SliderInside("##capsmooth", &smooth, 0.0f, 100.0f, "Base Smoothing %.0f")) o.smoothing = smooth / 100.0f;
+ again |= ImGui::IsItemDeactivatedAfterEdit();
+ ui::HelpText("Base Smoothing", nullptr,
+ "What counts as the detail: the capture is the surface minus a smoothed copy of itself. 0 measures "
+ "from a flat plane (the whole shape); higher takes away more of the broad form, so a detail on a "
+ "curved arm or cheek captures flat. The VDM keeps each point's sideways offset too (overhangs).",
+ help);
+ ImGui::SetNextItemWidth(-1);
+ float fade = o.edgeFade * 100.0f;
+ if (ui::SliderInside("##capfade", &fade, 0.0f, 50.0f, "Edge Fade %.0f")) o.edgeFade = fade / 100.0f;
+ again |= ImGui::IsItemDeactivatedAfterEdit();
+ ui::HelpText("Edge Fade", nullptr, "Fades the capture out toward its border, so stamps blend into any surface.", help);
+ static const int kRes[] = {128, 256, 512, 1024};
+ int ri = 1;
+ for (int i = 0; i < 4; ++i)
+ if (kRes[i] == o.resolution) ri = i;
+ ImGui::SetNextItemWidth(-1);
+ if (ImGui::SliderInt("##capres", &ri, 0, 3, (std::to_string(kRes[ri]) + " px").c_str())) o.resolution = kRes[ri];
+ again |= ImGui::IsItemDeactivatedAfterEdit();
+ ui::HelpText("Resolution", nullptr, "Pixels a side of the alpha and the map (512 or less suits most details).", help);
+ again |= ImGui::Checkbox("Fit plane", &o.fitPlane);
+ ui::HelpText("Fit plane", nullptr,
+ "Height alpha: measure from a plane fitted to the surface (a tilted surface captures level) instead of "
+ "the screen's plane.",
+ help);
+ ImGui::SameLine();
+ again |= ImGui::Checkbox("Invert##capture", &o.invert);
+ ui::HelpText("Invert", nullptr, "Height alpha: white = deepest (for carving brushes).", help);
+ ImGui::SetNextItemWidth(-1);
+ if (ImGui::InputTextWithHint("##capname", "Name", capture_.name, sizeof capture_.name)) {
+ if (!capture_.alpha.empty()) capture_.alpha.name = capture_.name;
+ }
+ ui::HelpText("Name", nullptr, "What the alpha and the VDM are called in your library (the same name replaces).", help);
+ if (again) recapture();
+
+ const bool ok = capture_.error.empty() && capture_.vdm && !capture_.alpha.empty();
+ const std::string name = capture_.name[0] ? capture_.name : "Captured";
+ auto args = [&] {
+ Args a;
+ a["point"] = vec3Arg(capture_.frame.center);
+ a["view"] = vec3Arg(capture_.frame.forward);
+ a["up"] = vec3Arg(capture_.frame.up);
+ a["size"] = double(capture_.frame.halfSize);
+ a["circle"] = capture_.frame.circle;
+ a["resolution"] = double(o.resolution);
+ a["smoothing"] = double(o.smoothing);
+ a["edge_fade"] = double(o.edgeFade);
+ a["name"] = name;
+ return a;
+ };
+ const float w2 = std::floor((ImGui::GetContentRegionAvail().x - ImGui::GetStyle().ItemSpacing.x) * 0.5f);
+ ImGui::BeginDisabled(!ok);
+ if (ImGui::Button("Use as Alpha##capture", ImVec2(w2, 0))) {
+ Args a = args();
+ a["fit_plane"] = o.fitPlane;
+ a["invert"] = o.invert;
+ runCommand("capture_alpha", a);
+ }
+ ui::HelpText("Use as Alpha", nullptr, "Make the height capture the brush alpha (it shapes every brush's stamp).", help);
+ ImGui::SameLine();
+ if (ImGui::Button("Use as VDM##capture", ImVec2(w2, 0))) {
+ Args a = args();
+ a["save"] = false;
+ runCommand("capture_vdm", a);
+ brush_ = BrushType::Vdm;
+ doc_.activeBrush = -1;
+ paintMode_ = false;
+ }
+ ui::HelpText("Use as VDM", nullptr, "Make the capture the VDM brush's map and pick the VDM brush (DragRect stamps it).", help);
+ if (ImGui::Button("Detail Clone##capture", ImVec2(w2, 0))) {
+ Args a = args();
+ a["save"] = false;
+ runCommand("capture_vdm", a);
+ brush_ = BrushType::DetailClone;
+ doc_.activeBrush = -1;
+ paintMode_ = false;
+ }
+ ui::HelpText("Detail Clone", nullptr, "Paint copies of the captured detail along your strokes, each turned to follow the stroke.", help);
+ ImGui::SameLine();
+ if (ImGui::Button("Save to Library##capture", ImVec2(w2, 0))) {
+ // The VDM into the brush library, the alpha into the LightBox's Alphas folder.
+ Args a = args();
+ a["save"] = true;
+ runCommand("capture_vdm", a);
+ if (!library_.user.empty()) {
+ Args b = args();
+ b["fit_plane"] = o.fitPlane;
+ b["invert"] = o.invert;
+ std::string file = brushFileName(name);
+ file = file.substr(0, file.size() - std::strlen(".sfbrush")) + ".png";
+ b["path"] = library_.user + "/Alphas/" + file;
+ runCommand("capture_alpha", b);
+ libraryScanner_.invalidate();
+ }
+ status_ = "Saved '" + name + "' to your library (LightBox > Alpha, and the VDM picker)";
+ }
+ ui::HelpText("Save to Library", nullptr,
+ "Keep both: the alpha as a PNG in your LightBox Alphas folder, the VDM in your brush library (Alpha "
+ "picker, Brush > Vector Displacement and the LightBox's Brush tab), with thumbnails.",
+ help);
+ ImGui::EndDisabled();
+ if (ImGui::Button("Capture again##capture", ImVec2(-1, 0))) {
+ capture_.armed = true;
+ status_ = "Capture: drag a square over the model (Shift: circle)";
+ }
+ ImGui::End();
+}
+
+bool App::kelvinUiValue(const std::string& name, double& out) const {
+ if (name == "capture_armed") return out = capture_.armed ? 1.0 : 0.0, true;
+ if (name == "capture_open") return out = capture_.open ? 1.0 : 0.0, true;
+ if (name == "capture_ok") return out = capture_.error.empty() && capture_.vdm ? 1.0 : 0.0, true;
+ if (name == "capture_points") return out = double(capture_.vdmInfo.vertices), true;
+ if (name == "capture_reach") return out = double(capture_.vdmInfo.maxOffset), true;
+ if (name == "alpha_width") return out = double(doc_.brushAlpha.width), true;
+ if (name == "kelvin_squash") return out = std::round(doc_.sculptor.kelvinlet.squash * 100.0f), true;
+ return false;
+}
+
+} // namespace sf
diff --git a/src/app/Pickers.cpp b/src/app/Pickers.cpp
index 0e435fe0..89203b11 100644
--- a/src/app/Pickers.cpp
+++ b/src/app/Pickers.cpp
@@ -390,6 +390,19 @@ const char* brushTypeDescription(int type) {
case BrushType::Vdm:
return "Vector displacement: drag out one stamp of a whole 3D shape, overhangs and all (a horn, an ear, "
"scales). Choose the map in Brush > Vector Displacement or the Alpha picker. Works best on dense meshes.";
+ case BrushType::KelvinGrab:
+ return "Elastic move from the physics of elasticity (Kelvinlets): the surface follows the cursor like real clay, "
+ "fading out with no edge. Squash (Brush > Kelvinlet) makes it bulge like incompressible clay.";
+ case BrushType::KelvinTwist:
+ return "Elastic twist: press and drag right to turn the surface clockwise around that point (left turns it "
+ "back); the turn fades smoothly, keeping the volume.";
+ case BrushType::KelvinScale:
+ return "Elastic pinch and swell: press and drag left to pinch the surface toward that point, right to swell it.";
+ case BrushType::KelvinSnake:
+ return "Elastic SnakeHook: pulls horns, tentacles and spikes that taper naturally as they stretch.";
+ case BrushType::DetailClone:
+ return "Paints copies of a captured detail along the stroke, each turned to follow it. Capture any detail on "
+ "the model with Capture from view (Ctrl+Alt+C), or pick a VDM.";
default:
return "";
}
diff --git a/src/app/Shell.cpp b/src/app/Shell.cpp
index fe5049e8..cde291db 100644
--- a/src/app/Shell.cpp
+++ b/src/app/Shell.cpp
@@ -128,6 +128,43 @@ void drawBrushIcon(ImDrawList* dl, ImVec2 c, float r, int type) {
break;
}
case BrushType::Inflate: dl->AddCircle(c, r * 0.45f, hi, 24, w); break;
+ case BrushType::KelvinGrab: { // a soft bulge with a drag arrow
+ dl->AddCircle(c, r * 0.5f, hi, 32, w * 0.6f);
+ const ImVec2 a(c.x - r * 0.1f, c.y + r * 0.1f), b(c.x + r * 0.5f, c.y - r * 0.5f);
+ dl->AddLine(a, b, hi, w);
+ dl->AddTriangleFilled(b, ImVec2(b.x - r * 0.3f, b.y + r * 0.02f), ImVec2(b.x - r * 0.02f, b.y + r * 0.3f), hi);
+ break;
+ }
+ case BrushType::KelvinTwist: { // a swirl
+ ImVec2 pts[24];
+ for (int i = 0; i < 24; ++i) {
+ const float t = float(i) / 23.0f, ang = t * 5.0f, rr = r * (0.1f + 0.45f * t);
+ pts[i] = ImVec2(c.x + std::cos(ang) * rr, c.y - std::sin(ang) * rr);
+ }
+ dl->AddPolyline(pts, 24, hi, 0, w);
+ break;
+ }
+ case BrushType::KelvinScale: // four arrows pointing in
+ for (int k = 0; k < 4; ++k) {
+ const float ang = 0.785f + 1.5708f * float(k);
+ const ImVec2 o(c.x + std::cos(ang) * r * 0.6f, c.y + std::sin(ang) * r * 0.6f);
+ const ImVec2 i(c.x + std::cos(ang) * r * 0.2f, c.y + std::sin(ang) * r * 0.2f);
+ dl->AddLine(o, i, hi, w * 0.8f);
+ }
+ break;
+ case BrushType::KelvinSnake: { // a tapering hook
+ ImVec2 pts[12];
+ for (int i = 0; i < 12; ++i) {
+ const float t = float(i) / 11.0f;
+ pts[i] = ImVec2(c.x - r * 0.4f + r * 0.8f * t, c.y + r * 0.35f - r * 0.75f * t * t);
+ }
+ for (int i = 0; i + 1 < 12; ++i) dl->AddLine(pts[i], pts[i + 1], hi, w * (1.4f - float(i) / 11.0f));
+ break;
+ }
+ case BrushType::DetailClone: // a row of stamps
+ for (int k = -1; k <= 1; ++k)
+ dl->AddCircleFilled(ImVec2(c.x + r * 0.42f * float(k), c.y + r * 0.12f * float(k)), r * 0.16f, hi, 16);
+ break;
case BrushType::Pinch:
dl->AddLine(ImVec2(c.x - r * 0.5f, c.y - r * 0.4f), ImVec2(c.x, c.y), hi, w);
dl->AddLine(ImVec2(c.x + r * 0.5f, c.y - r * 0.4f), ImVec2(c.x, c.y), hi, w);
@@ -286,6 +323,11 @@ void App::registerShellActions() {
"Slides the surface sideways along the stroke.",
"Vector displacement: one DragRect stamps a whole shape with overhangs (horn, ear curl, scales, nostril, or "
"your own from a VDM plane). Pick the map under Brush > Vector Displacement.",
+ "Elastic move (Kelvinlets): drags the surface like real clay, with no falloff edge; Squash makes it bulge.",
+ "Elastic twist: drag right to turn the surface clockwise around where you pressed, left to turn it back.",
+ "Elastic pinch / swell: drag left to pinch the surface toward where you pressed, right to swell it.",
+ "Elastic SnakeHook: pulls smooth, tapering horns and tendrils out along the stroke.",
+ "Stamps the VDM brush's map along the stroke, each copy turned to follow it. Capture one with Capture from view.",
};
static_assert(std::size(kBrushHelp) == size_t(BrushType::Count));
for (int i = 0; i < int(BrushType::Count); ++i) {
diff --git a/src/app/Thumbnails.cpp b/src/app/Thumbnails.cpp
index cdb5f674..2a37084d 100644
--- a/src/app/Thumbnails.cpp
+++ b/src/app/Thumbnails.cpp
@@ -217,6 +217,29 @@ std::unique_ptr<Mesh> sculptBrushPreview(const BrushRecipe* recipe, int type) {
case BrushType::Vdm: // one stamp of the built-in Horn
stroke(d, nullptr, bt, {glm::vec3(0.0f, -0.05f, 2.0f)}, 0.45f, 0.5f, false);
break;
+ case BrushType::KelvinGrab: // the silhouette pulled out into a smooth, bulging lobe
+ d.sculptor.kelvinlet.squash = 1.0f;
+ stroke(d, nullptr, bt, line({-0.45f, 0.45f, 2.0f}, {-0.8f, 0.8f, 2.0f}), 0.45f, 0.5f, false);
+ break;
+ case BrushType::KelvinTwist: // a raised bar twisted into an S
+ stroke(d, nullptr, BrushType::Standard, line({-0.5f, 0.0f, 2.0f}, {0.5f, 0.0f, 2.0f}), 0.16f, 1.0f, false);
+ stroke(d, nullptr, BrushType::Standard, line({-0.5f, 0.0f, 2.0f}, {0.5f, 0.0f, 2.0f}), 0.16f, 1.0f, false);
+ stroke(d, nullptr, bt, line({0.0f, 0.0f, 2.0f}, {0.45f, 0.0f, 2.0f}), 0.45f, 0.5f, false);
+ break;
+ case BrushType::KelvinScale: // a ring of bumps pinched toward the middle
+ for (int i = 0; i < 6; ++i) {
+ const float a = float(i) * kPi / 3.0f;
+ for (int pass = 0; pass < 3; ++pass)
+ stroke(d, nullptr, BrushType::Standard, {glm::vec3(0.4f * std::cos(a), 0.4f * std::sin(a), 2.0f)}, 0.12f, 1.0f, false);
+ }
+ stroke(d, nullptr, bt, line({0.0f, 0.0f, 2.0f}, {-0.5f, 0.0f, 2.0f}), 0.4f, 0.5f, false);
+ break;
+ case BrushType::KelvinSnake: // a tapering horn pulled out past the silhouette
+ stroke(d, nullptr, bt, line({0.3f, 0.3f, 2.0f}, {1.1f, 0.85f, 2.0f}), 0.24f, 0.5f, false);
+ break;
+ case BrushType::DetailClone: // a row of horns along a curve
+ stroke(d, nullptr, bt, arc(0.0f, -0.25f, 0.55f, kPi * 0.15f, kPi * 0.85f), 0.12f, 0.5f);
+ break;
default: // Standard: a soft rounded S
stroke(d, nullptr, bt, frontCurve(1.15f), 0.19f, 1.0f);
break;
diff --git a/src/app/UiLayout.cpp b/src/app/UiLayout.cpp
index a1d00186..7c1eb98a 100644
--- a/src/app/UiLayout.cpp
+++ b/src/app/UiLayout.cpp
@@ -41,7 +41,8 @@ UiLayout standardLayout() {
"subtool.solo", "view.splats"};
l.bottomShelf = {"brush.standard", "brush.clay", "brush.claybuildup", "brush.damstandard", "brush.move",
"brush.smooth", "brush.inflate", "brush.pinch", "brush.flatten", "brush.crease",
- "brush.trim", "brush.snakehook", "brush.layer", "brush.nudge", "brush.paint",
+ "brush.trim", "brush.snakehook", "brush.layer", "brush.nudge", "brush.kelvingrab",
+ "brush.detailclone", "brush.paint",
"widget.add_brush"};
return l;
}
diff --git a/src/app/UiTest.cpp b/src/app/UiTest.cpp
index 41adc74d..7ebab2ec 100644
--- a/src/app/UiTest.cpp
+++ b/src/app/UiTest.cpp
@@ -399,6 +399,7 @@ double Demo::query(const std::string& name, bool& known) const {
if (name == "lazy_mouse") return app_.strokeType_ == StrokeType::LazyMouse ? 1.0 : 0.0;
if (name == "stroke_type") return double(int(app_.strokeType_)); // 0 Dots, 1 DragRect, 2 DragDot, 3 Spray, 4 LazyMouse
if (name == "vdms") return double(app_.doc_.vdms.size());
+ if (double kv = 0.0; app_.kelvinUiValue(name, kv)) return kv; // capture_*, kelvin_* (PanelKelvinlet.cpp)
// Facial shapes (PanelFace.cpp): landmarks placed, placing them, a take playing, and face_<shape>: that layer's weight.
if (name == "face_landmarks") return double(app_.faceLandmarks_.count());
if (name == "face_placing") return app_.facePlacing_ ? 1.0 : 0.0;
diff --git a/tests/ui/kelvinlet_capture.sfui b/tests/ui/kelvinlet_capture.sfui
new file mode 100644
index 00000000..79e13987
--- /dev/null
+++ b/tests/ui/kelvinlet_capture.sfui
@@ -0,0 +1,68 @@
+# Kelvinlet brushes and Capture from view: KelvinGrab from the bottom shelf drags the sphere out elastically (undo
+# puts it back), Twist and Scale act where they press, the Kelvinlet section's Squash slider; then Ctrl+Alt+C, a
+# square dragged over a sculpted detail, the capture window, and Detail Clone stamping the capture along a stroke.
+run new_sphere subdivisions=7
+wait_idle 30
+
+# KelvinGrab: the grabbed side follows the cursor, the surface around it follows softly (no edge).
+click "KelvinGrab##brush.kelvingrab"
+expect_value brush_type == 15
+snapshot
+stroke 0.62 0.42 0.78 0.3
+expect_value moved > 2000
+expect_value moved_max > 0.1
+expect_value can_undo == 1
+wait_idle 30
+shot kelvin_grab
+key ctrl+z
+expect_value moved == 0
+
+# Twist and Scale: press, drag sideways.
+click "Brush##palette.brush"
+click "Brush/##totray"
+wait 0.3
+click "Kelvinlet & Capture##brush.kelvinlet"
+expect "##kelvinsquash"
+expect "Capture from view##brush.capture_view"
+hold ctrl
+hover "##kelvinsquash"
+expect_help Poisson
+hold none
+click "KelvinTwist##Built-in16"
+expect_value brush_type == 16
+snapshot
+stroke 0.5 0.45 0.62 0.45
+expect_value moved > 200
+key ctrl+z
+click "KelvinScale##Built-in17"
+expect_value brush_type == 17
+snapshot
+stroke 0.5 0.45 0.4 0.45
+expect_value moved > 200
+key ctrl+z
+
+# A detail to capture: a horn from the VDM brush, then Ctrl+Alt+C and a square over it.
+run vdm_stamp point=0,0,2 view=0,0,-1 radius=0.25
+wait_idle 30
+key ctrl+alt+c
+expect_value capture_armed == 1
+view_drag 0.328 0.375 0.497 0.656
+wait_value capture_open == 1
+expect_value capture_ok == 1
+expect_value capture_points > 1000
+expect "Capture from view##capture"
+expect "Detail Clone##capture"
+wait_idle 30
+shot capture_window
+hold ctrl
+hover "##capsmooth"
+expect_help detail
+hold none
+click "Detail Clone##capture"
+expect_value brush_type == 19
+run new_sphere subdivisions=7
+snapshot
+stroke 0.38 0.62 0.66 0.62
+expect_value moved > 500
+wait_idle 30
+shot detail_clone
diff --git a/tests/ui/lightbox.sfui b/tests/ui/lightbox.sfui
index 951c3a56..8c5d5916 100644
--- a/tests/ui/lightbox.sfui
+++ b/tests/ui/lightbox.sfui
@@ -62,6 +62,7 @@ shot lightbox-brush
expect_not "LightBox/Skin Pores"
drag_item "LightBox/Inflate" -700 0
drag_item "LightBox/Nudge" -700 0
+drag_item "LightBox/KelvinSnake" -700 0
expect "LightBox/Skin Pores"
expect_status Brush: DamStandard