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.

Brush engine 0.10.9: Clay follows Intensity/pressure (#83), alphas on micro levels (#92), strokes hold at silhouettes (#84), Smooth face group borders (#81), colour tints the material

islandmed7a8616ad87bc
diff --git a/CHANGELOG.md b/CHANGELOG.md
index a5607791..90cb6efb 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,6 +6,21 @@ All notable changes to SculptForge are listed here. The format follows
## [Unreleased]
+### Fixed
+- Clay and Clay Block follow Intensity and pen pressure: below the default Intensity a dab no longer planes the
+ surface all the way to its plane, so light strokes and low Intensity build gently instead of looking the same as
+ full strength (#83, thanks NimeNayota). Custom clay brushes and micro levels too.
+- Alphas work on micro levels: Drag Stamp and every other stroke stamp the alpha instead of a round dab (#92,
+ thanks Devon0209).
+- Strokes keep sculpting across a silhouette: when the cursor slides just past the edge of a form seen in profile
+ and the brush still covers it, the dab lands on the edge instead of stopping (#84, thanks Bro-Code-99).
+
+### Added
+- Smooth face group borders only (Brush palette): Smooth straightens the borders between face groups along the
+ surface and leaves the rest alone, for clean clothing edges (#81, thanks bossian0220).
+- Colour tints the material (Color palette, on by default): the current colour tints the Lit Sphere material of
+ Parts with no vertex paint; grey leaves it as it is (thanks ThinkingPolygons).
+
## [0.10.8] - 2026-11-02
### Fixed
diff --git a/docs/guide/micro-levels.md b/docs/guide/micro-levels.md
index 48a830d7..df297adc 100644
--- a/docs/guide/micro-levels.md
+++ b/docs/guide/micro-levels.md
@@ -35,7 +35,8 @@ triangles draws faster than Micro 4 on 1.2 million.
These brushes work on micro levels: **Standard**, **Clay**, **Clay Block**, **Smooth**, **Inflate**,
**Flatten**, **Trim**, **Layer**, **Pinch**, **Crease**, **Sharp Crease** and **Mask** (with
-<kbd>Ctrl</kbd>). Symmetry, Falloff, pressure and the mask work as usual, and every stroke is one undo step.
+<kbd>Ctrl</kbd>). Symmetry, Falloff, pressure, alphas (Drag Stamp included) and the mask work as usual, and every
+stroke is one undo step.
- A micro level stores one height per point, so it moves the surface in and out, never sideways. **Pinch**,
**Crease** and **Sharp Crease** sharpen the height profile instead of pulling points together (the result
diff --git a/docs/guide/sculpting.md b/docs/guide/sculpting.md
index 70824b17..6c611ff7 100644
--- a/docs/guide/sculpting.md
+++ b/docs/guide/sculpting.md
@@ -18,7 +18,9 @@ symmetry and pen pressure. To design your own brushes, see [Brush Lab and sharin
oldest steps are dropped beyond that.
Dragging on the background never sculpts: it rotates the view (see [Navigation](navigation.md)). The brush only
-works on the active Part, and only on parts that are visible and not masked.
+works on the active Part, and only on parts that are visible and not masked. A stroke that started on the model
+keeps sculpting when it slides past the edge of a form seen in profile, as long as the brush circle still covers
+the model: the brush holds on to the silhouette (#84).
> **ZBrush:** the modifiers are the ones you know. <kbd>Alt</kbd> flips Add and Sub for one stroke,
> <kbd>Shift</kbd> smooths with any brush, <kbd>Ctrl</kbd> paints a mask (see [Masking](masking.md)).
@@ -31,7 +33,7 @@ are on the bottom shelf by default and in the brush picker.
| Brush | Key | What it does | With <kbd>Alt</kbd> |
|---|---|---|---|
| **Standard** | <kbd>1</kbd> | Raises the surface along the stroke, the all-purpose brush. | Digs in |
-| **Clay** | <kbd>2</kbd> | Builds up clay that fills the hollows first, with a slightly flat top. | Carves away |
+| **Clay** | <kbd>2</kbd> | Builds up clay that fills the hollows first, with a slightly flat top. Intensity and pen pressure set how fast it builds. | Carves away |
| **Smooth** | <kbd>3</kbd> | Relaxes the surface, evening out bumps. The same brush <kbd>Shift</kbd> gives you. | No change |
| **Move** | <kbd>4</kbd> | Grabs the surface under the cursor and pulls it along, parallel to the screen. | No change |
| **Inflate** | <kbd>5</kbd> | Swells the surface outward along its normals. | Deflates |
@@ -175,6 +177,15 @@ bumps but leaves the form where it is (a Taubin smooth, one step in and a slight
the Smooth brush use; letting go of <kbd>Shift</kbd> mid-stroke then switches to the plain one. Saved with the
project.
+### Smooth face group borders
+
+**Smooth face group borders only** in the **Brush** palette turns Smooth (and <kbd>Shift</kbd>) into a border
+straightener: only the points on a border between [face groups](face-groups.md) move, each along the surface
+toward its neighbours on the border, so a jagged edge (a cuff, a collar, the hem of a shirt, a panel line) becomes
+a clean line while the rest of the model stays where it is. Corners where three or more groups meet stay put.
+Group the clothing first (for example **Group masked** after masking it), then brush over the edge. Saved with the
+project (#81).
+
On a micro level (see [Micro levels](micro-levels.md)) Smooth is always the plain one for now. On a quad mesh
(after Quad Remesh, or an imported quad model) Smooth follows the quads' own edges, never their diagonals, so the
quads keep their shape (#69).
@@ -329,7 +340,7 @@ brush, built-in or custom. Choose one from the **Alpha** tile on the left shelf
**Alpha** palette, which also shows a large preview of the current alpha.
[Falloff](#draw-size-intensity-rgb-intensity-and-falloff) fades it as in ZBrush: set it to -100 to
stamp the whole alpha (a crisp square, or a pattern out to its edges), 0 for a soft round fade, +100 for a soft
-point.
+point. Alphas work on [micro levels](micro-levels.md) too, with every stroke type including Drag Stamp.
![The alpha picker](images/alpha-picker.jpg)
diff --git a/docs/guide/vertex-paint.md b/docs/guide/vertex-paint.md
index 940277b4..4747754e 100644
--- a/docs/guide/vertex-paint.md
+++ b/docs/guide/vertex-paint.md
@@ -182,6 +182,12 @@ To choose one:
Vertex Paint multiplies the material, and cavity shading stays on with every material (strongest with Sculpt). The
material is saved with the project: projects saved with Studio open with Studio.
+**Colour tints the material** (in the **Color** palette, on by default): on a Part with no vertex paint yet, the
+current colour tints its Lit Sphere material, as in ZBrush, so you can try a skin, stone or bronze tone without
+painting anything. The colour's hue and saturation tint it; grey (the starting colour) and black leave the material
+as it is, and the material keeps its own light and shade. Once a Part has vertex paint, the paint shows instead.
+PBR shading uses the material channels and is not tinted. Saved with the project.
+
> **Tip:** **Sculpt** is the material to judge strokes with. The prettier ones (Skin, Red Wax) soften small
> detail; switch to them for presenting.
diff --git a/docs/guide/whats-new.md b/docs/guide/whats-new.md
index d8920df6..c87d08cf 100644
--- a/docs/guide/whats-new.md
+++ b/docs/guide/whats-new.md
@@ -5,6 +5,18 @@ chapter opens by itself the first time you start a new version; you can always f
**Help > What's New**. Every detail is in the
[changelog](https://github.com/islandmed/SculptForge/blob/main/CHANGELOG.md).
+## Version 0.10.9
+
+- **Clay follows Intensity and pressure**: Clay and Clay Block build gently with a light pen or a low Intensity
+ instead of planing flat as at full strength (#83). See [Sculpting](sculpting.md#built-in-brushes).
+- **Alphas on micro levels**: Drag Stamp and every stroke stamp your alpha on a micro level too (#92).
+- **Brushes hold on at silhouettes**: a stroke sliding past the edge of a form in profile keeps sculpting while the
+ brush still covers it (#84).
+- **Smooth face group borders**: a Brush palette option that straightens jagged clothing edges between face
+ groups and leaves the rest alone (#81). See [Smooth face group borders](sculpting.md#smooth-face-group-borders).
+- **Colour tints the material**: pick a colour and Parts with no vertex paint take it on in the Lit Sphere
+ material. See [Vertex Paint and materials](vertex-paint.md#materials-lit-spheres).
+
## Version 0.10.8
- **Tablets in mouse mode work again**: on some Windows tablets with **Mouse mode** on (Preferences > Tablet) the
diff --git a/src/app/App.cpp b/src/app/App.cpp
index 08c6194c..0d5d02a9 100644
--- a/src/app/App.cpp
+++ b/src/app/App.cpp
@@ -20,6 +20,7 @@
#include <imgui_internal.h>
#include "ai/Generator3D.h"
#include "core/Micro.h"
+#include "core/Polypaint.h"
#include "core/EnginePresets.h"
#include "link/UnrealLink.h"
#include "core/BrushLibrary.h"
@@ -1045,6 +1046,7 @@ int App::run() {
notePerformanceFrame(std::chrono::duration<double, std::milli>(std::chrono::steady_clock::now() - syncStart).count());
const int samples = viewSamples();
renderSettings_.motionProxy = perf_.proxyNow; // big meshes draw their lighter proxy while the view moves
+ renderSettings_.materialTint = materialTintFor(doc_.paintColor); // (Color > Colour tints the material)
perf_.samplesUsed = renderer_.drawView(camera_, fbW, fbH, renderSettings_, canvasViewport(fbW, fbH), samples);
if (snapshotEnv && *snapshotEnv && (sm.moving || sm.releasing)) {
// Three points of the stroke, and the end (the frame the last dab reached the screen).
@@ -1910,7 +1912,9 @@ void App::dabAt(float x, float y, float pressure) {
dabAngle_ = s.angle;
}
RayHit hit;
- if (!(dabView_ ? pickWith(*dabView_, x, y, hit) : pick(x, y, hit))) return;
+ // Off the surface but the brush still over it (sliding over a silhouette, #84): the nearest surface within it.
+ auto cast = [&](float cx, float cy, RayHit& h) { return dabView_ ? pickWith(*dabView_, cx, cy, h) : pick(cx, cy, h); };
+ if (!pickNearCursor(x, y, st.radiusPx * dabRadiusScale_, cast, hit)) return;
if (pressure < 0.0f) pressure = strokePressure();
DabParams p;
@@ -1921,6 +1925,7 @@ void App::dabAt(float x, float y, float pressure) {
// Smooth keeps its own Z Intensity (ZBrush), whether picked or held with Shift.
p.strength = (st.brush == BrushType::Smooth ? st.smoothStrength : st.strength) * dabStrengthScale_;
p.keepVolume = st.brush == BrushType::Smooth && st.smoothKeepVolume;
+ p.groupBorders = st.brush == BrushType::Smooth && st.smoothGroupBorders;
p.pressure = st.pressureStrength ? pressure : 1.0f;
p.invert = st.invert;
p.frontFacesOnly = st.frontFacesOnly;
diff --git a/src/app/App.h b/src/app/App.h
index 34fbdfa2..653cb282 100644
--- a/src/app/App.h
+++ b/src/app/App.h
@@ -286,6 +286,7 @@ private:
float radiusPx = 60.0f, strength = 0.5f, smoothStrength = 0.5f, focal = 0.0f, maskStrength = 1.0f;
float sprayScatter = 1.0f;
bool smoothKeepVolume = false; // Smooth keeps the volume (smoothKeepVolume_, or the alternate smooth)
+ bool smoothGroupBorders = false; // Smooth moves face group borders only (smoothGroupBorders_, #81)
bool pressureSize = false, pressureStrength = true, invert = false, frontFacesOnly = false;
bool connectedOnly = false, viewFalloff = false; // the falloff options (Brush palette)
bool mask = false, paint = false, sculpt = true, visible = true;
@@ -1527,6 +1528,7 @@ private:
glm::vec2 constrainStroke(float x, float y);
float smoothStrength_ = 0.5f; // Smooth's own Z Intensity (Shift+stroke, or the Smooth brush)
bool smoothKeepVolume_ = false; // Brush > Smooth keeps volume: a Taubin smooth instead of the plain one (#40)
+ bool smoothGroupBorders_ = false; // Brush > Smooth face group borders only: straightens the borders (#81)
// ZBrush's alternate smooth (#40): a stroke begun with Shift held that lets go of Shift while still pressing
// smooths the other way (keeping the volume, or plainly when Smooth keeps volume) for the rest of the stroke.
bool strokeAltSmooth_ = false;
diff --git a/src/app/AsyncStroke.cpp b/src/app/AsyncStroke.cpp
index 9e3ce384..9116b537 100644
--- a/src/app/AsyncStroke.cpp
+++ b/src/app/AsyncStroke.cpp
@@ -311,6 +311,7 @@ App::DabSettings App::dabSettings() const {
st.strength = strength_;
st.smoothStrength = smoothStrength_;
st.smoothKeepVolume = smoothKeepVolume_ != strokeAltSmooth_;
+ st.smoothGroupBorders = smoothGroupBorders_;
st.focal = focalShift_;
st.maskStrength = maskStrength_;
st.sprayScatter = sprayScatter_;
diff --git a/src/app/I18nSpanish.cpp b/src/app/I18nSpanish.cpp
index 64f74029..57a06d23 100644
--- a/src/app/I18nSpanish.cpp
+++ b/src/app/I18nSpanish.cpp
@@ -207,6 +207,7 @@ constexpr Entry kSpanish[] = {
{"Invert (Alt)", "Invertir (Alt)"},
{"Invert", "Invertir"},
{"Smooth keeps volume", "Smooth conserva el volumen"},
+ {"Smooth face group borders only", "Smooth solo en los bordes de grupos de caras"},
{"Symmetry", "Simetría"},
{"Symmetry X", "Simetría X"},
{"Local", "Local"},
@@ -291,6 +292,7 @@ constexpr Entry kSpanish[] = {
{"Show mask", "Mostrar máscara"},
{"Show face groups", "Mostrar grupos de caras"},
{"Show vertex paint", "Mostrar pintura de vértices"},
+ {"Colour tints the material", "El color tiñe el material"},
{"Show texture", "Mostrar textura"},
{"Show UVs", "Mostrar UVs"},
{"Mask", "Máscara"},
diff --git a/src/app/Palettes.cpp b/src/app/Palettes.cpp
index 36025693..4dec7df8 100644
--- a/src/app/Palettes.cpp
+++ b/src/app/Palettes.cpp
@@ -319,6 +319,12 @@ void App::drawPalette_Brush() {
"that also flattens it. Either way, let go of Shift while still pressing a Shift-smooth stroke to "
"switch to the other smooth for the rest of the stroke (ZBrush's alternate smooth).",
"Brush");
+ ImGui::Checkbox(tr("Smooth face group borders only##smooth_group_borders"), &smoothGroupBorders_);
+ ui::HelpText("Smooth face group borders only", nullptr,
+ "The Smooth brush (and Shift) straightens the borders between face groups and leaves everything "
+ "else alone: a jagged clothing edge, a cuff or a panel line becomes a clean line along the surface. "
+ "Corners where three groups meet stay where they are.",
+ "Brush");
if (BrushRecipe* recipe = doc_.activeBrush >= 0 && doc_.activeBrush < int(doc_.brushes.size())
? &doc_.brushes[size_t(doc_.activeBrush)]
: nullptr) {
diff --git a/src/app/PanelPolypaint.cpp b/src/app/PanelPolypaint.cpp
index 6f3c0e0d..2aa3cb69 100644
--- a/src/app/PanelPolypaint.cpp
+++ b/src/app/PanelPolypaint.cpp
@@ -429,6 +429,12 @@ void App::drawPalette_Color() {
ImGui::EndDisabled();
ui::HelpText("Clear", nullptr, "Remove all vertex paint from the Part, paint layers included (undoable).", "Color");
ImGui::Checkbox(tr("Show vertex paint"), &renderSettings_.showPolypaint);
+ ImGui::Checkbox(tr("Colour tints the material"), &renderSettings_.colorTintsMaterial);
+ ui::HelpText("Colour tints the material", nullptr,
+ "On a Part with no vertex paint, the colour above tints its Lit Sphere material, so you can try a "
+ "skin, stone or metal tone without painting. Grey and black leave the material as it is. Vertex "
+ "paint, once there, shows instead.",
+ "Color");
if (hasTexture(doc_.mesh)) {
ImGui::SameLine();
ImGui::Checkbox(tr("Texture##show"), &renderSettings_.showTexture);
diff --git a/src/app/PanelProject.cpp b/src/app/PanelProject.cpp
index d3df4918..87df31d3 100644
--- a/src/app/PanelProject.cpp
+++ b/src/app/PanelProject.cpp
@@ -285,6 +285,7 @@ void App::storeProjectSettings() {
render.set("wireframe", renderSettings_.wireframe);
render.set("base_color", vec3Json(renderSettings_.baseColor));
render.set("show_polypaint", renderSettings_.showPolypaint);
+ render.set("color_tints_material", renderSettings_.colorTintsMaterial);
render.set("show_mask", renderSettings_.showMask);
render.set("show_polygroups", renderSettings_.showPolygroups);
render.set("show_mesh", renderSettings_.showMesh);
@@ -327,6 +328,7 @@ void App::storeProjectSettings() {
brush.set("strength", double(strength_));
brush.set("smooth_strength", double(smoothStrength_));
brush.set("smooth_keep_volume", smoothKeepVolume_);
+ brush.set("smooth_group_borders", smoothGroupBorders_);
brush.set("rgb_intensity", double(rgbIntensity_));
brush.set("focal_shift", double(focalShift_));
brush.set("invert", invertToggle_);
@@ -382,6 +384,7 @@ void App::applyProjectSettings() {
readBool(r, "wireframe", renderSettings_.wireframe);
readVec3(r["base_color"], renderSettings_.baseColor);
readBool(r, "show_polypaint", renderSettings_.showPolypaint);
+ readBool(r, "color_tints_material", renderSettings_.colorTintsMaterial);
readBool(r, "show_mask", renderSettings_.showMask);
readBool(r, "show_polygroups", renderSettings_.showPolygroups);
readBool(r, "show_mesh", renderSettings_.showMesh);
@@ -455,6 +458,7 @@ void App::applyProjectSettings() {
focalShift_ = std::clamp(focalShift_, -1.0f, 1.0f);
readBool(b, "invert", invertToggle_);
readBool(b, "smooth_keep_volume", smoothKeepVolume_);
+ readBool(b, "smooth_group_borders", smoothGroupBorders_);
readBool(b, "front_faces_only", frontFacesOnly_);
readBool(b, "connected_only", uiPrefs_.connectedOnly);
readBool(b, "view_falloff", uiPrefs_.viewFalloff);
diff --git a/src/app/UiTest.cpp b/src/app/UiTest.cpp
index fcef8be5..56a8d118 100644
--- a/src/app/UiTest.cpp
+++ b/src/app/UiTest.cpp
@@ -92,6 +92,7 @@
// viewport_cursor (the system cursor: 0 arrow, 1 text, 7 hand, 100 crosshair; #73),
// smooth_keep_volume (Brush > Smooth keeps volume), stroke_keep_volume (1 when Smooth
// dabs keep the volume now: the option, flipped by letting go of Shift mid-stroke),
+// smooth_group_borders (Brush > Smooth face group borders only, #81),
// moved_out (summed movement along the snapshot's normals: > 0 out, < 0 in),
// pen_pressure (raw), brush_pressure (after the curve; 1 for the mouse),
// stroke_continuous (Stroke > Continuous, 1 on),
@@ -454,6 +455,7 @@ double Demo::query(const std::string& name, bool& known) const {
// ZBrush feel (Input.cpp): the intensities and Focal Shift as shown (0-100, -100..100).
if (name == "z_intensity") return std::round(app_.strength_ * 100.0f);
if (name == "smooth_keep_volume") return app_.smoothKeepVolume_ ? 1.0 : 0.0;
+ if (name == "smooth_group_borders") return app_.smoothGroupBorders_ ? 1.0 : 0.0;
if (name == "stroke_keep_volume") return app_.dabSettings().smoothKeepVolume ? 1.0 : 0.0; // (Smooth's dabs)
if (name == "smooth_intensity") return std::round(app_.smoothStrength_ * 100.0f);
if (name == "rgb_intensity") return std::round(app_.rgbIntensity_ * 100.0f);
diff --git a/src/core/Micro.h b/src/core/Micro.h
index 710a6777..be67a41b 100644
--- a/src/core/Micro.h
+++ b/src/core/Micro.h
@@ -238,14 +238,17 @@ private:
// sharpen instead of pulling sideways; Move moves along the normal), 0 = not at all.
int microBrushSupport(BrushType type);
+struct BrushAlpha;
struct MicroUndo;
class MicroStroke {
public:
void begin(Mesh& m);
// One dab (one mirror) of a displacement brush, or the mask brush (`maskBrush`: raises the mask to 1, or
- // lowers it with invert).
+ // lowers it with invert). `alpha` (null/empty = round) shapes a displacement dab as on a mesh, its top edge
+ // 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);
+ float strength, bool invert, float focal, const glm::vec3& alphaUp, bool maskBrush, float maskStrength,
+ const BrushAlpha* alpha = nullptr);
// 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.cpp
index 8f918bc2..65fea3a9 100644
--- a/src/core/MicroSculpt.cpp
+++ b/src/core/MicroSculpt.cpp
@@ -12,6 +12,7 @@
#include "core/Micro.h"
#include "core/BVH.h"
+#include "core/BrushAlpha.h"
#include "core/Sculpt.h"
#include "core/ThreadPool.h"
#include "core/TierConfig.h"
@@ -264,7 +265,8 @@ 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) {
+ float strength, bool invert, float focal, const glm::vec3& alphaUp, bool maskBrush, float maskStrength,
+ const BrushAlpha* alpha) {
if (!active_ || !m.micro || radius <= 0.0f) return;
if (!maskBrush && microBrushSupport(type) == 0) return;
auto clock = std::chrono::steady_clock::now();
@@ -273,7 +275,9 @@ void MicroStroke::dab(Mesh& m, const BVH& bvh, BrushType type, const glm::vec3&
const float r = radius, r2 = r * r;
const float s = std::clamp(strength, 0.0f, 1.0f);
const float sign = invert ? -1.0f : 1.0f;
- const float reach = type == BrushType::ClayBuildup && !maskBrush ? 1.3f : 1.0f;
+ // An alpha reaches its square's corners, the square ClayBuildup tip a little past the circle (as Sculpt.cpp).
+ const bool useAlpha = alpha && !alpha->empty() && !maskBrush;
+ const float reach = useAlpha ? kAlphaReach : type == BrushType::ClayBuildup && !maskBrush ? 1.3f : 1.0f;
// The displacement range this dab may need: widened first (it costs precision) when what a dab adds could
// pass it; a dab that still clips (planes far off) widens it for the next one.
@@ -399,8 +403,9 @@ void MicroStroke::dab(Mesh& m, const BVH& bvh, BrushType type, const glm::vec3&
any = true;
continue;
}
- float f = brushFalloff(std::sqrt(dist2), r, focal);
- if (type == BrushType::ClayBuildup) { // square tip, rounded corners (as Sculpt.cpp)
+ float f = useAlpha ? alpha->stamp(glm::dot(o, right) / r, glm::dot(o, up) / r, focal)
+ : brushFalloff(std::sqrt(dist2), r, focal);
+ if (type == BrushType::ClayBuildup && !useAlpha) { // square tip, rounded corners (as Sculpt.cpp)
const float cheb = std::max(std::abs(glm::dot(o, right)), std::abs(glm::dot(o, up))) / r;
const float corner = std::clamp((1.3f - std::sqrt(dist2) / r) / 0.3f, 0.0f, 1.0f);
const float edge = std::clamp((1.0f - cheb) / 0.35f, 0.0f, 1.0f);
@@ -445,13 +450,13 @@ void MicroStroke::dab(Mesh& m, const BVH& bvh, BrushType type, const glm::vec3&
case BrushType::Clay: {
const glm::vec3 pp = areaCenter + areaNormal * (sign * r * 0.05f * s);
const float h = glm::dot(p - pp, areaNormal);
- if (sign * h < 0.0f) delta = -h * f / facing;
+ if (sign * h < 0.0f) delta = -h * f * clayPull(s) / facing;
break;
}
case BrushType::ClayBuildup: {
const glm::vec3 pp = areaCenter + areaNormal * (sign * r * 0.08f * s);
const float h = glm::dot(p - pp, areaNormal);
- if (sign * h < 0.0f) delta = -h * f / facing;
+ if (sign * h < 0.0f) delta = -h * f * clayPull(s) / facing;
break;
}
case BrushType::Trim: {
diff --git a/src/core/Polypaint.h b/src/core/Polypaint.h
index fec732b3..82fc470b 100644
--- a/src/core/Polypaint.h
+++ b/src/core/Polypaint.h
@@ -10,6 +10,7 @@
#include "core/Mesh.h"
#include "core/Sculpt.h"
+#include <algorithm>
#include <string>
namespace sf {
@@ -22,6 +23,13 @@ class CommandRegistry;
bool parseColor(const std::string& text, glm::vec3& linear);
// "#rrggbb" (sRGB) for a linear colour.
std::string colorToHex(const glm::vec3& linear);
+// The tint the active colour gives a Lit Sphere material on a mesh with no vertex paint (as ZBrush's main
+// colour): its hue and saturation at full brightness, so a grey (the default colour) or black leaves the material
+// as it is and a red turns it red while the material keeps its own light and shade.
+inline glm::vec3 materialTintFor(const glm::vec3& linear) {
+ const float m = std::max(linear.x, std::max(linear.y, linear.z));
+ return m > 1e-4f ? glm::clamp(linear / m, 0.0f, 1.0f) : glm::vec3(1.0f);
+}
// One Paint brush dab inside a Sculptor stroke: blends `color` into the
// vertices under the brush with the smoothstep falloff, strength x pressure,
diff --git a/src/core/Sculpt.cpp b/src/core/Sculpt.cpp
index 2a9a07c4..38711e96 100644
--- a/src/core/Sculpt.cpp
+++ b/src/core/Sculpt.cpp
@@ -665,6 +665,34 @@ UndoRecord Sculptor::endStroke() {
return std::move(record_);
}
+int groupBorderNeighbours(const Mesh& mesh, uint32_t v, uint32_t out[3]) {
+ if (!mesh.hasPolygroups()) return 0;
+ int count = 0;
+ const auto tris = mesh.vertexTriangles(v);
+ for (uint32_t t : tris) {
+ const glm::uvec3 tr = mesh.triangles[t];
+ for (int k = 0; k < 3; ++k) {
+ const uint32_t n = tr[k];
+ if (n == v) continue;
+ bool seen = false;
+ for (int i = 0; i < count && !seen; ++i) seen = out[i] == n;
+ if (seen) continue;
+ // The edge v-n: a border when the triangles sharing it don't all have one group.
+ const uint32_t g = mesh.polygroupAt(t);
+ bool border = false;
+ for (uint32_t u : tris) {
+ if (u == t) continue;
+ const glm::uvec3 o = mesh.triangles[u];
+ if ((o.x == n || o.y == n || o.z == n) && mesh.polygroupAt(u) != g) border = true;
+ }
+ if (!border) continue;
+ out[count++] = n;
+ if (count == 3) return 3;
+ }
+ }
+ return count;
+}
+
void Sculptor::dab(Mesh& mesh, BVH& bvh, BrushType type, const DabParams& p, Symmetry sym) {
if (!active_) return;
// Morph: nothing without a target (Tool > Selection Sets > Morph Target); not on micro levels (no grid shapes).
@@ -678,7 +706,7 @@ void Sculptor::dab(Mesh& mesh, BVH& bvh, BrushType type, const DabParams& p, Sym
const uint64_t pts = micro_.points;
for (const SymCopy& m : copies(sym))
micro_.dab(mesh, bvh, type, m.point(p.center), m.dir(p.viewDir), p.radius, p.strength * std::clamp(p.pressure, 0.0f, 1.0f),
- p.invert, p.focal, m.dir(p.alphaUp), false, 0.0f);
+ p.invert, p.focal, m.dir(p.alphaUp), false, 0.0f, p.alpha);
timings.kernelMs += micro_.findMs + micro_.kernelMs - k0;
timings.normalsMs += micro_.stitchMs - s0;
timings.vertices += micro_.points - pts;
@@ -752,7 +780,7 @@ void Sculptor::dabSingle(Mesh& mesh, BVH& bvh, BrushType type, const DabParams&
const float strokeLen = glm::length(p.strokeDelta);
const glm::vec3 strokeDir = strokeLen > 1e-12f ? p.strokeDelta / strokeLen : glm::vec3(0.0f);
if (type == BrushType::Layer) prepareLayer(mesh, r * 0.08f * std::clamp(p.strength, 0.0f, 1.0f));
- const bool keepVolume = type == BrushType::Smooth && p.keepVolume;
+ const bool keepVolume = type == BrushType::Smooth && p.keepVolume && !p.groupBorders;
if (keepVolume) taubinShrink(mesh);
const std::vector<glm::vec3>* morph = type == BrushType::Morph ? morphTarget(mesh) : nullptr;
if (type == BrushType::Morph && !morph) return;
@@ -776,6 +804,13 @@ void Sculptor::dabSingle(Mesh& mesh, BVH& bvh, BrushType type, const DabParams&
d = nrm[v] * (sign * s * r * 0.05f * f);
break;
case BrushType::Smooth: {
+ if (p.groupBorders) { // along the border, on the tangent plane; junctions and inner vertices stay
+ uint32_t nb[3];
+ if (groupBorderNeighbours(mesh, v, nb) != 2) break;
+ const glm::vec3 mid = 0.5f * (pos[nb[0]] + pos[nb[1]]);
+ d = projectOnPlane(mid - x, nrm[v]) * std::min(1.0f, s * f);
+ break;
+ }
auto ring = mesh.polygonNeighbors(v);
if (ring.empty()) break;
glm::vec3 avg(0.0f);
@@ -805,7 +840,7 @@ void Sculptor::dabSingle(Mesh& mesh, BVH& bvh, BrushType type, const DabParams&
// Raise a plane slightly above the surface and pull everything below up to it.
glm::vec3 planePoint = areaCenter + areaNormal * (sign * r * 0.05f * s);
float h = glm::dot(x - planePoint, areaNormal);
- if (sign * h < 0.0f) d = -areaNormal * (h * f);
+ if (sign * h < 0.0f) d = -areaNormal * (h * f * clayPull(s));
break;
}
case BrushType::Crease: {
@@ -847,7 +882,7 @@ void Sculptor::dabSingle(Mesh& mesh, BVH& bvh, BrushType type, const DabParams&
}
glm::vec3 planePoint = areaCenter + areaNormal * (sign * r * 0.08f * s);
float h = glm::dot(x - planePoint, areaNormal);
- if (sign * h < 0.0f) d = -areaNormal * (h * w);
+ if (sign * h < 0.0f) d = -areaNormal * (h * w * clayPull(s));
break;
}
case BrushType::SnakeHook: {
@@ -1110,7 +1145,7 @@ void Sculptor::dabRecipeSingle(Mesh& mesh, BVH& bvh, const BrushRecipe& r, const
case BrushRecipe::Plane::Clay: {
glm::vec3 planePoint = areaCenter + areaNormal * (sign * rad * 0.06f * s);
float hc = glm::dot(x - planePoint, areaNormal);
- if (sign * hc < 0.0f) d -= areaNormal * (hc * f * r.planeAmount);
+ if (sign * hc < 0.0f) d -= areaNormal * (hc * f * r.planeAmount * clayPull(s));
break;
}
case BrushRecipe::Plane::Flatten: d -= areaNormal * (h * s * f * r.planeAmount); break;
diff --git a/src/core/Sculpt.h b/src/core/Sculpt.h
index 1203f417..f2956803 100644
--- a/src/core/Sculpt.h
+++ b/src/core/Sculpt.h
@@ -10,6 +10,7 @@
#include "core/Symmetry.h"
#include "core/Undo.h"
+#include <algorithm>
#include <chrono>
#include <functional>
#include <memory>
@@ -72,6 +73,10 @@ struct DabParams {
// Smooth: keep the volume (#40). A Taubin step, one shrink then one inflate, removes bumps as the plain
// (Laplacian) smooth does without shrinking the form. Not on micro levels (they smooth plainly).
bool keepVolume = false;
+ // Smooth: face group borders only (#81, clothing edges). Only vertices on a border between face groups move,
+ // each toward its two neighbours along the border and kept on the surface's tangent plane, so a jagged border
+ // straightens into a clean line while the rest stays put. Junctions of three or more groups hold still.
+ bool groupBorders = false;
// Falloff options (#55, Blender's proportional editing): `connectedOnly` keeps the dab to the surface joined
// to the point under the cursor (the other leg, the next finger stay put); `viewFalloff` measures the falloff
// on screen, so the brush reaches through the model along the view as a cylinder.
@@ -134,6 +139,13 @@ glm::vec3 brushAreaNormal(const Mesh& mesh, const BVH& bvh, const glm::vec3& cen
// the angle between them) of parallel to the ray, so the cursor can't say where along it.
bool lineRayClosest(const glm::vec3& point, const glm::vec3& dir, const glm::vec3& origin, const glm::vec3& rayDir,
float& s, float minSine = 0.25f);
+// How far one Clay / Clay Block dab pulls the surface up to its plane (#83), from the dab's strength (Intensity x
+// pressure, 0..1): all the way from the default Intensity (50) up, less below it, so a light touch or a low
+// Intensity builds gently instead of planing the surface flat as a full-strength dab would.
+// Face group borders (#81): the neighbours of `v` across whose shared edge the face group changes, up to 3
+// (`out`); the return value is how many there are (a count of 3 means a junction).
+int groupBorderNeighbours(const Mesh& mesh, uint32_t v, uint32_t out[3]);
+inline float clayPull(float s) { return s >= 0.5f ? 1.0f : 2.0f * std::max(s, 0.0f); }
// Smoothstep brush falloff: 1 at the centre, 0 at `radius`. `focal` is ZBrush's Focal Shift (-1..1): below 0
// the full-strength centre widens (a harder, broader tip), above 0 it narrows to a softer point; 0 is the plain
// smoothstep, unchanged.
diff --git a/src/core/Stroke.h b/src/core/Stroke.h
index 5c3cc531..88861c8f 100644
--- a/src/core/Stroke.h
+++ b/src/core/Stroke.h
@@ -7,6 +7,7 @@
#include <glm/glm.hpp>
+#include <cmath>
#include <cstdint>
#include <vector>
@@ -68,4 +69,34 @@ private:
uint32_t state_ = 1;
};
+// A stroke's surface point at screen (x, y), catching the surface near a silhouette (#84): `cast(x, y, hit)` casts
+// the cursor ray there. When it misses but the brush circle (`radiusPx`) still overlaps the model, as when a
+// stroke slides over the edge of a form seen in profile, rays on rings around the cursor find the surface and a
+// few halving steps toward the cursor bring the point to the silhouette, so the dab lands on the edge it covers.
+// False when nothing lies within the circle (the stroke pauses there, as before).
+template <class Hit, class Cast>
+bool pickNearCursor(float x, float y, float radiusPx, Cast&& cast, Hit& hit) {
+ if (cast(x, y, hit)) return true;
+ if (!(radiusPx >= 1.0f)) return false;
+ constexpr int kRings = 4, kDirs = 16;
+ for (int ring = 1; ring <= kRings; ++ring) {
+ const float r = radiusPx * float(ring) / float(kRings);
+ for (int k = 0; k < kDirs; ++k) {
+ const float a = 6.28318531f * float(k) / float(kDirs);
+ const glm::vec2 dir(std::cos(a), std::sin(a));
+ if (!cast(x + dir.x * r, y + dir.y * r, hit)) continue;
+ // Hit between the last ring and this one: halve toward the cursor while the ray still finds it.
+ float lo = r - radiusPx / float(kRings), hi = r;
+ for (int i = 0; i < 5 && hi - lo > 0.5f; ++i) {
+ const float mid = 0.5f * (lo + hi);
+ Hit h = hit;
+ if (cast(x + dir.x * mid, y + dir.y * mid, h)) hi = mid, hit = h;
+ else lo = mid;
+ }
+ return true;
+ }
+ }
+ return false;
+}
+
} // namespace sf
diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp
index 65fbe19e..bb773f24 100644
--- a/src/render/Renderer.cpp
+++ b/src/render/Renderer.cpp
@@ -357,6 +357,7 @@ void microFetch() {
uniform vec4 uViewport; // the view's rectangle in window pixels
uniform vec2 uProjScale; // projection x and y scale
uniform vec3 uBaseColor;
+uniform vec3 uTintShift; // the material tint less 1 (0, the default, is no tint): the active colour, no vertex paint
uniform int uPaint; // 1: vertex colours replace the base colour
uniform int uShowMask; // 1: darken masked areas
uniform int uGroups; // 0: off, 1: per-triangle ids from uGroupIds, 2: everything is group 0, 3: per-triangle
@@ -473,8 +474,8 @@ void main() {
#ifdef MICRO
microFetch();
#endif
- vec3 albedo = uBaseColor;
- vec3 tint = vec3(1.0); // multiplies a matcap: polypaint or polygroup colours
+ vec3 tint = vec3(1.0) + uTintShift; // multiplies a matcap: polypaint or polygroup colours, or the active colour
+ vec3 albedo = uBaseColor * tint;
#ifdef PRIM
if (uGroups == 3) albedo = tint = faceColor(texelFetch(uGroupIds, vPrimBase + gl_PrimitiveID).r);
else if (uGroups == 1) albedo = tint = groupColor(texelFetch(uGroupIds, vPrimBase + gl_PrimitiveID).r);
@@ -878,6 +879,7 @@ const Renderer::MeshProgram* Renderer::meshProgram(int features) {
p.viewport = at("uViewport");
p.projScale = at("uProjScale");
p.baseColor = at("uBaseColor");
+ p.tintShift = at("uTintShift");
p.paint = at("uPaint");
p.showMask = at("uShowMask");
p.groups = at("uGroups");
@@ -2877,6 +2879,12 @@ void Renderer::drawClusters(const MeshSlot& s, const std::vector<uint32_t>& clus
}
// One mesh. Mask and polygroup colours are for the SubTool being edited; polypaint shows on all of them.
+// The material tint a mesh gets (RenderSettings::colorTintsMaterial), less 1: Lit Sphere shading, no vertex paint.
+static glm::vec3 materialTintShift(const RenderSettings& settings, bool hasColors) {
+ if (!settings.colorTintsMaterial || settings.pbr() || hasColors) return glm::vec3(0.0f);
+ return settings.materialTint - glm::vec3(1.0f);
+}
+
void Renderer::drawMicro(const MeshSlot& s, bool active, bool flat, const RenderSettings& settings) {
const MeshProgram* p = meshProgram(kMicro | (flat ? kFlat : 0) | (settings.pbr() && envTexture_ ? kPbr : 0));
if (!p) return;
@@ -2888,6 +2896,7 @@ void Renderer::drawMicro(const MeshSlot& s, bool active, bool flat, const Render
const bool orthographic = frameProj_[3][3] == 1.0f;
gl::Uniform2f(p->projScale, orthographic ? 1e20f : frameProj_[0][0], orthographic ? 1e20f : frameProj_[1][1]);
gl::Uniform3fv(p->baseColor, 1, glm::value_ptr(settings.baseColor));
+ gl::Uniform3fv(p->tintShift, 1, glm::value_ptr(materialTintShift(settings, s.hasColors)));
gl::Uniform1i(p->matcap, matcapTexture(settings.matcap) ? 1 : 0);
const MatcapCavity cavity = matcapCavity(settings.matcap);
gl::Uniform2f(p->matcapCavity, cavity.crease, cavity.ridge);
@@ -2942,6 +2951,7 @@ void Renderer::drawSlot(const MeshSlot& s, bool active, bool flat, const RenderS
const bool orthographic = frameProj_[3][3] == 1.0f;
gl::Uniform2f(p->projScale, orthographic ? 1e20f : frameProj_[0][0], orthographic ? 1e20f : frameProj_[1][1]);
gl::Uniform3fv(p->baseColor, 1, glm::value_ptr(settings.baseColor));
+ gl::Uniform3fv(p->tintShift, 1, glm::value_ptr(materialTintShift(settings, s.hasColors)));
gl::Uniform1i(p->matcap, matcapTexture(settings.matcap) ? 1 : 0);
const MatcapCavity cavity = matcapCavity(settings.matcap);
gl::Uniform2f(p->matcapCavity, cavity.crease, cavity.ridge);
diff --git a/src/render/Renderer.h b/src/render/Renderer.h
index 50a1e27c..b790b380 100644
--- a/src/render/Renderer.h
+++ b/src/render/Renderer.h
@@ -27,6 +27,10 @@ struct RenderSettings {
bool wireframe = false;
glm::vec3 baseColor{0.62f, 0.58f, 0.53f}; // Studio's colour: a warm clay grey, like the default Soft Clay
bool showPolypaint = true; // vertex colours replace baseColor when the mesh has them
+ // The active colour tints the Lit Sphere material on meshes with no vertex paint (Color palette, as ZBrush's
+ // main colour does): materialTint multiplies the material there, white leaves it as it is (materialTintFor).
+ bool colorTintsMaterial = true;
+ glm::vec3 materialTint{1.0f};
bool showTexture = true; // with showPolypaint: a SubTool's painted texture (core/Texture.h) multiplies in
bool showMask = true; // masked areas render darker (ZBrush style)
bool showPolygroups = false; // colour each polygroup (see polygroupColor)
@@ -413,7 +417,7 @@ private:
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, checker = -1, checkerScale = -1;
+ normalFlipY = -1, twoSided = -1, checker = -1, checkerScale = -1, tintShift = -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;
diff --git a/tests/test_brush_engine_0109.cpp b/tests/test_brush_engine_0109.cpp
new file mode 100644
index 00000000..8dc84a51
--- /dev/null
+++ b/tests/test_brush_engine_0109.cpp
@@ -0,0 +1,211 @@
+// SculptForge - open source digital sculpting
+// SPDX-License-Identifier: GPL-3.0-or-later
+//
+// Brush engine fixes for 0.10.9: Clay follows Intensity and pressure (#83), alphas on micro levels (#92), strokes
+// over a silhouette (#84), Smooth along face group borders (#81) and the colour tinting the material.
+#include "TestHarness.h"
+
+#include "core/Benchmark.h"
+#include "core/BrushAlpha.h"
+#include "core/Micro.h"
+#include "core/Polypaint.h"
+#include "core/Primitives.h"
+#include "core/Sculpt.h"
+#include "core/Stroke.h"
+
+#include <algorithm>
+#include <cmath>
+
+using namespace sf;
+
+namespace {
+
+constexpr Symmetry kNone{false, false, false};
+
+// The highest point of the plane (its normal is +Y) after one stroke of `dabs` dabs along X.
+float clayStrokeHeight(BrushType type, float strength, float pressure, int dabs = 24) {
+ Document d = makeDoc(makePlane(64, 2.0f));
+ d.sculptor.beginStroke(d.mesh, brushName(type));
+ for (int i = 0; i < dabs; ++i) {
+ DabParams p;
+ // On the surface under the cursor, as the app picks it (the slab rises under the stroke).
+ p.center = glm::vec3(-0.3f + 0.6f * float(i) / float(dabs - 1), 0.0f, 0.0f);
+ RayHit hit;
+ if (d.bvh.raycast(d.mesh, p.center + glm::vec3(0, 5, 0), glm::vec3(0, -1, 0), hit)) p.center = hit.position;
+ p.viewDir = glm::vec3(0, -1, 0);
+ p.radius = 0.25f;
+ p.strength = strength;
+ p.pressure = pressure;
+ for (int k = 0; k < 3; ++k) d.sculptor.dab(d.mesh, d.bvh, type, p, kNone); // (a slow stroke: dabs overlap)
+ }
+ d.undo.push(d.sculptor.endStroke());
+ float top = 0.0f;
+ for (const glm::vec3& x : d.mesh.positions) top = std::max(top, x.y);
+ return top;
+}
+
+float microFront(const Document& doc, float x, float y) {
+ RayHit hit;
+ CHECK(microRaycast(doc.mesh, doc.bvh, glm::vec3(x, y, 5.0f), glm::vec3(0, 0, -1), hit));
+ return glm::length(hit.position);
+}
+
+} // namespace
+
+TEST(clay_follows_intensity_and_pressure) {
+ for (BrushType type : {BrushType::Clay, BrushType::ClayBuildup}) {
+ const float i10 = clayStrokeHeight(type, 0.1f, 1.0f), i50 = clayStrokeHeight(type, 0.5f, 1.0f),
+ i100 = clayStrokeHeight(type, 1.0f, 1.0f);
+ CHECK(i10 > 0.0f);
+ CHECK(i10 < 0.5f * i50); // (before #83 a light stroke planed nearly as high as a full one)
+ CHECK(i50 < 0.8f * i100);
+ const float light = clayStrokeHeight(type, 0.5f, 0.2f), full = clayStrokeHeight(type, 0.5f, 1.0f);
+ CHECK(light > 0.0f);
+ CHECK(light < 0.5f * full);
+ }
+ // The pull follows the strength below the default Intensity and is whole from it up.
+ CHECK(clayPull(0.0f) == 0.0f && clayPull(0.25f) == 0.5f && clayPull(0.5f) == 1.0f && clayPull(1.0f) == 1.0f);
+}
+
+TEST(clay_follows_intensity_on_micro_levels) {
+ float heights[3];
+ const float strengths[3] = {0.25f, 0.5f, 1.0f}; // (on a sphere a weak Clay fills the sides first)
+ for (int k = 0; k < 3; ++k) {
+ Document doc = makeDoc(makeBenchSphere(20000));
+ std::string err;
+ CHECK(microDivide(doc.mesh, 3, err));
+ const float h0 = microFront(doc, 0.001f, 0.002f);
+ DabParams p;
+ p.center = glm::vec3(0, 0, 1);
+ p.viewDir = glm::vec3(0, 0, -1);
+ p.radius = 0.3f;
+ p.strength = strengths[k];
+ CHECK(doc.sculptor.beginStroke(doc.mesh, "Clay"));
+ for (int i = 0; i < 20; ++i) doc.sculptor.dab(doc.mesh, doc.bvh, BrushType::Clay, p, kNone);
+ doc.undo.push(doc.sculptor.endStroke());
+ heights[k] = microFront(doc, 0.001f, 0.002f) - h0;
+ }
+ CHECK(heights[0] < 0.5f * heights[1]);
+ CHECK(heights[1] < heights[2]);
+}
+
+// #92: a stamp (Drag Stamp or any stroke) keeps its alpha on a micro level instead of falling back to round.
+TEST(micro_dabs_use_the_alpha) {
+ BrushAlpha square = BrushAlpha::square();
+ float corner[2], centre[2];
+ for (int k = 0; k < 2; ++k) {
+ Document doc = makeDoc(makeBenchSphere(20000));
+ std::string err;
+ CHECK(microDivide(doc.mesh, 3, err));
+ const float c0 = microFront(doc, 0.25f, 0.25f), m0 = microFront(doc, 0.001f, 0.002f);
+ DabParams p;
+ p.center = glm::vec3(0, 0, 1);
+ p.viewDir = glm::vec3(0, 0, -1);
+ p.radius = 0.3f;
+ p.strength = 0.5f;
+ p.focal = -1.0f; // (Focal Shift -100: the square shows hard to its corners)
+ p.alpha = k == 1 ? &square : nullptr;
+ CHECK(doc.sculptor.beginStroke(doc.mesh, "Standard"));
+ for (int i = 0; i < 8; ++i) doc.sculptor.dab(doc.mesh, doc.bvh, BrushType::Standard, p, kNone);
+ doc.undo.push(doc.sculptor.endStroke());
+ corner[k] = microFront(doc, 0.25f, 0.25f) - c0;
+ centre[k] = microFront(doc, 0.001f, 0.002f) - m0;
+ }
+ // Round leaves the square's corner (beyond the radius) alone; the square raises it about as much as the centre.
+ CHECK(centre[0] > 0.005f && centre[1] > 0.005f);
+ CHECK(std::abs(corner[0]) < 0.1f * centre[0]);
+ CHECK(corner[1] > 0.5f * centre[1]);
+}
+
+// #84: a stroke sliding over the edge of a form seen in profile keeps sculpting while the brush still covers it.
+TEST(strokes_catch_the_surface_at_a_silhouette) {
+ Document doc = makeDoc(makeBenchSphere(20000)); // (radius 1 around the origin)
+ // A screen of 100 px per unit, looking down -Z.
+ int casts = 0;
+ auto cast = [&](float x, float y, RayHit& hit) {
+ ++casts;
+ return doc.bvh.raycast(doc.mesh, glm::vec3(x / 100.0f, y / 100.0f, 5.0f), glm::vec3(0, 0, -1), hit);
+ };
+ RayHit hit;
+ CHECK(pickNearCursor(50.0f, 0.0f, 20.0f, cast, hit)); // on the surface: the plain ray, once
+ CHECK(casts == 1 && std::abs(hit.position.x - 0.5f) < 1e-4f);
+ // Just off the edge, the brush still over it: the dab lands on the silhouette.
+ CHECK(pickNearCursor(108.0f, 3.0f, 20.0f, cast, hit));
+ CHECK(glm::length(glm::vec2(hit.position)) > 0.97f);
+ CHECK(glm::distance(glm::vec2(hit.position), glm::vec2(1.08f, 0.03f)) < 0.12f);
+ // Further out than the brush reaches: nothing (the stroke pauses, as before).
+ CHECK(!pickNearCursor(125.0f, 0.0f, 20.0f, cast, hit));
+
+ // A stroke across the profile from inside to outside: every dab within a radius of the edge lands.
+ int plain = 0, caught = 0;
+ for (int i = 0; i <= 20; ++i) {
+ const float x = 90.0f + float(i); // 0.90 .. 1.10
+ RayHit h;
+ if (cast(x, 0.0f, h)) ++plain;
+ if (pickNearCursor(x, 0.0f, 15.0f, cast, h)) ++caught;
+ }
+ CHECK(caught == 21);
+ CHECK(plain < caught);
+}
+
+// #81: Smooth > face group borders only straightens a jagged border and leaves everything else where it was.
+TEST(smooth_straightens_face_group_borders_only) {
+ Document d = makeDoc(makePlane(64, 2.0f));
+ Mesh& m = d.mesh;
+ // A staircase border: group 1 above z = 0 or z = 0.0625, alternating every eighth of a unit along X.
+ std::vector<uint32_t>& groups = m.ensurePolygroups();
+ for (uint32_t t = 0; t < m.triangleCount(); ++t) {
+ const glm::uvec3 tr = m.triangles[t];
+ const glm::vec3 c = (m.positions[tr.x] + m.positions[tr.y] + m.positions[tr.z]) / 3.0f;
+ const float step = (int(std::floor(c.x * 8.0f)) & 1) ? 0.0625f : 0.0f;
+ groups[t] = c.z > step ? 1u : 0u;
+ }
+ auto borderLength = [&]() {
+ double len = 0.0;
+ for (uint32_t v = 0; v < m.vertexCount(); ++v) {
+ if (std::abs(m.positions[v].x) > 0.3f) continue;
+ uint32_t nb[3];
+ const int c = groupBorderNeighbours(m, v, nb);
+ for (int k = 0; k < std::min(c, 2); ++k)
+ if (nb[k] > v && std::abs(m.positions[nb[k]].x) <= 0.3f) len += glm::distance(m.positions[v], m.positions[nb[k]]);
+ }
+ return len;
+ };
+ // On the plane every border vertex has two border neighbours, an inner vertex none.
+ uint32_t nb[3];
+ CHECK(groupBorderNeighbours(m, 0, nb) == 0);
+ const double before = borderLength();
+ const std::vector<glm::vec3> start = m.positions;
+
+ DabParams p;
+ p.center = glm::vec3(0.0f, 0.0f, 0.03f);
+ p.viewDir = glm::vec3(0, -1, 0);
+ p.radius = 0.5f;
+ p.strength = 1.0f;
+ p.groupBorders = true;
+ d.sculptor.beginStroke(m, "Smooth");
+ for (int i = 0; i < 40; ++i) d.sculptor.dab(d.mesh, d.bvh, BrushType::Smooth, p, kNone);
+ d.undo.push(d.sculptor.endStroke());
+
+ CHECK(borderLength() < 0.9 * before); // straighter
+ int movedBorder = 0;
+ for (uint32_t v = 0; v < m.vertexCount(); ++v) {
+ CHECK(std::abs(m.positions[v].y) < 1e-5f); // along the surface (its tangent plane), never off it
+ if (m.positions[v] == start[v]) continue;
+ CHECK(groupBorderNeighbours(m, v, nb) == 2); // only border vertices move
+ ++movedBorder;
+ }
+ CHECK(movedBorder > 10);
+ // Undo puts it all back.
+ CHECK(d.undo.undo(d.mesh, d.bvh));
+ CHECK(m.positions == start);
+}
+
+TEST(colour_tints_the_material) {
+ const glm::vec3 grey = materialTintFor(glm::vec3(0.22f)), black = materialTintFor(glm::vec3(0.0f));
+ CHECK(grey == glm::vec3(1.0f) && black == glm::vec3(1.0f)); // the default colour leaves the material alone
+ const glm::vec3 red = materialTintFor(glm::vec3(0.6f, 0.06f, 0.03f));
+ CHECK(red.x == 1.0f && red.y < 0.2f && red.z < 0.2f);
+ const glm::vec3 white = materialTintFor(glm::vec3(1.0f));
+ CHECK(white == glm::vec3(1.0f));
+}
diff --git a/tests/ui/whats_new.sfui b/tests/ui/whats_new.sfui
index 0e5cf4b3..91d18303 100644
--- a/tests/ui/whats_new.sfui
+++ b/tests/ui/whats_new.sfui
@@ -5,8 +5,9 @@ click "Help##palette.help"
click "What's New##help.whats_new"
expect_value guide_open == 1
expect_guide whats-new.md
+expect_text "Version 0.10.9"
+expect_text "Clay follows Intensity and pressure"
expect_text "Version 0.10.8"
-expect_text "Tablets in mouse mode work again"
expect_text "Version 0.10.7"
expect_text "Version 0.10.6"
expect_text "Version 0.10.5"