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.

Viewport: matte Soft Clay default material on a charcoal vignette; brush thumbnails as one icon set

islandmedf18cc9b56b37
diff --git a/docs/ui-design.md b/docs/ui-design.md
index d352c7f3..e51fc6e5 100644
--- a/docs/ui-design.md
+++ b/docs/ui-design.md
@@ -130,7 +130,7 @@ CanvasRect canvasRect() const; // from Layout, recomputed ev
- `pick`, `onMouseDown/Move`, the brush cursor, `onScreen`, `hide_rect` and polygroup overlays all convert window -> canvas coordinates in one helper.
- Mouse events outside the canvas never start strokes or orbits, even when ImGui doesn't capture them (e.g. on gaps between shelf items).
- Recording, `--render`, demos and `hideUi_` keep using the full window (`canvasRect()` returns the whole viewport when `hideUi_` is set).
-- The area outside the canvas is cleared to `shellBg`. The canvas itself keeps the current gradient background and gets a 1 px `#0e0e10` border.
+- The area outside the canvas is cleared to `shellBg`. The canvas itself has a neutral charcoal background with a soft radial vignette (no coloured gradient) and gets a 1 px `#0e0e10` border.
---
@@ -305,10 +305,10 @@ Each tab shows a "Built-in" and a "User" folder at its root, as ZBrush shows Max
`ThumbnailCache` gives every visual asset an `ImTextureID`:
-- **Meshes and projects**: rendered offscreen. Use `Renderer::renderToImage`, or a new `Renderer::renderMeshThumbnail(const Mesh&, matcap, size, rgba&)` if `renderToImage` is tied to the synced scene. Size 192x192 (displayed at 96, crisp on HiDPI), studio material, transparent background, camera framed on the bounds from a 3/4 front view (yaw 30, pitch 15).
+- **Meshes and projects**: rendered offscreen. Use `Renderer::renderToImage`, or a new `Renderer::renderMeshThumbnail(const Mesh&, matcap, size, rgba&)` if `renderToImage` is tied to the synced scene. Size 192x192 (displayed at 96, crisp on HiDPI), the default material (Soft Clay), transparent background, camera framed on the bounds from a 3/4 front view (yaw 30, pitch 15).
- Mesh loading uses the existing importers on a worker thread. GL rendering happens on the main thread, **at most 2 thumbnails per frame**.
- Projects: `saveProject` also writes `thumbnail.png` (256x256, current camera) into the `.sfproj` ZIP. The LightBox reads that instead of loading the whole project. Older projects without it are loaded on the worker and rendered once.
-- **Brushes**: on a worker, sculpt one S-curve stroke with the brush on a fresh `makePlane(96)` (or an icosphere sdiv 4 for Inflate/Pinch-type brushes) using the same `Sculptor`/recipe code as real strokes. Then render it with clay material, side-lit. Key = brush type or recipe JSON hash.
+- **Brushes**: on a worker, sculpt one S-curve stroke (or a ridge crossed by the brush, for Smooth/Flatten/Trim/Nudge) on the front of a fresh clay ball (icosphere sdiv 6) using the same `Sculptor`/recipe code as real strokes. Every brush, Paint included, is the same ball, camera and material (Soft Clay), so the shelf reads as one icon set. Key = brush type or recipe JSON hash plus `kThumbnailVersion` (bump it whenever thumbnails are made differently, so stale disk-cached ones are remade).
- **Alphas**: the alpha's grayscale samples straight into a texture.
- **Materials**: a sphere rendered with that matcap.
- **Images**: stb-decoded, downscaled to 192.
@@ -489,7 +489,7 @@ Keep the existing orange accent. Make it denser and greyer, like ZBrush. Put thi
| `text` / `textDim` | `#d8d8d8` / `#8c8c90` | |
| `border` | `#121214` | 1 px between regions |
| `danger` | `#e5604a` | errors |
-| canvas | the existing gradient; 1 px `#0e0e10` frame | |
+| canvas | neutral charcoal, soft radial vignette (`kBgFS`); 1 px `#0e0e10` frame; default material Soft Clay (matte warm grey) | |
Style:
- Rounding: `WindowRounding 0` (shells), `PopupRounding 6`, `FrameRounding 3`, `GrabRounding 2`.
diff --git a/src/app/AssetLibrary.h b/src/app/AssetLibrary.h
index 2c51f75c..2aeb4133 100644
--- a/src/app/AssetLibrary.h
+++ b/src/app/AssetLibrary.h
@@ -112,7 +112,7 @@ private:
// --- Thumbnail cache keys (spec: fnv1a64(kind|absPath|size|mtime|version)) ---
-constexpr int kThumbnailVersion = 1; // bump when thumbnails are rendered differently
+constexpr int kThumbnailVersion = 2; // bump when thumbnails are rendered differently
uint64_t fnv1a64(std::string_view data, uint64_t seed = 0xcbf29ce484222325ull);
std::string hex64(uint64_t v); // 16 lower-case hex digits
// Key of a file's thumbnail: changes when the file is rewritten (size or time) or the renderer changes.
diff --git a/src/app/Thumbnails.cpp b/src/app/Thumbnails.cpp
index f626aea4..b34ab7a7 100644
--- a/src/app/Thumbnails.cpp
+++ b/src/app/Thumbnails.cpp
@@ -67,22 +67,35 @@ std::unique_ptr<Mesh> sceneMesh(Document& doc) {
return out;
}
-// Paths for brush previews: an S across a plane at y = 0 (seen from above), or across the front of a sphere.
-std::vector<glm::vec3> planeCurve() {
+// Every brush preview is the same clay ball, sculpted on its front and shot from the same camera with the
+// same material, so the shelf and the pickers read as one icon set.
+constexpr float kBallRadius = 0.9f;
+constexpr int kBallDetail = 6; // ~82k triangles: fine enough for crisp strokes at preview size
+constexpr float kBallPitch = -8.0f; // degrees; a touch from above
+constexpr float kBallFill = 0.84f; // the ball's share of the tile's height
+
+// Brush previews: the camera distance at which the ball fills kBallFill of the tile.
+float ballDistance() {
+ const float fovY = Camera().fovY;
+ return kBallRadius / (kBallFill * std::tan(fovY * 0.5f));
+}
+
+// An S across the front of the ball, as stroke points in front of it (strokes look along -z).
+std::vector<glm::vec3> frontCurve(float width = 1.0f) {
std::vector<glm::vec3> pts;
for (int i = 0; i <= 8; ++i) {
const float u = float(i) / 8.0f;
- pts.emplace_back(-0.66f + 1.32f * u, 1.0f, 0.28f * std::sin(u * 6.2831853f));
+ pts.emplace_back((-0.56f + 1.12f * u) * width, 0.24f * std::sin(u * 6.2831853f), 2.0f);
}
return pts;
}
std::vector<glm::vec3> line(glm::vec3 a, glm::vec3 b) { return {a, b}; }
-void stroke(Document& d, const BrushRecipe* recipe, BrushType type, std::vector<glm::vec3> pts, glm::vec3 view,
- float radius, float strength, bool curve = true) {
+void stroke(Document& d, const BrushRecipe* recipe, BrushType type, std::vector<glm::vec3> pts, float radius,
+ float strength, bool curve = true) {
PathStroke st;
st.points = std::move(pts);
- st.view = view;
+ st.view = glm::vec3(0.0f, 0.0f, -1.0f);
st.radius = radius;
st.strength = strength;
st.curve = curve;
@@ -90,88 +103,74 @@ void stroke(Document& d, const BrushRecipe* recipe, BrushType type, std::vector<
strokePath(d, recipe, type, st, err);
}
-// Sculpts the preview of a brush (a recipe when given, else `type`) with the same code real strokes use.
-std::unique_ptr<Mesh> sculptBrushPreview(const BrushRecipe* recipe, int type, float& pitch, float& zoom,
- float& distance) {
- Document d;
- const glm::vec3 down(0.0f, -1.0f, 0.0f), front(0.0f, 0.0f, -1.0f);
- // A close-up of the stroke from above at an angle; the plane's edges stay outside the tile.
- pitch = -46.0f;
- distance = 2.15f;
+// Sculpts the preview of a brush (a recipe when given, else `type`) with the same code real strokes use,
+// on the shared ball (see kBallRadius).
+std::unique_ptr<Mesh> sculptBrushPreview(const BrushRecipe* recipe, int type) {
if (type == kPaintBrush) {
- // Polypaint: a coloured S on a clay sphere.
- Mesh m = makeIcosphere(5, 0.9f);
- m.ensureColors(glm::vec3(0.62f, 0.60f, 0.58f));
+ // Polypaint: a coloured S on the ball; white elsewhere, so the material shows as on the others.
+ Mesh m = makeIcosphere(kBallDetail, kBallRadius);
+ m.ensureColors(glm::vec3(1.0f));
for (uint32_t v = 0; v < m.vertexCount(); ++v) {
const glm::vec3 p = m.positions[v];
- const float curve = 0.32f * std::sin(p.x * 3.4f);
+ const float curve = 0.24f * std::sin((p.x / 0.56f + 1.0f) * 3.14159265f);
const float d2 = std::abs(p.y - curve);
- if (p.z > 0.0f && d2 < 0.16f) {
- const float t = std::clamp((0.16f - d2) / 0.05f, 0.0f, 1.0f);
- m.colors[v] = glm::mix(m.colors[v], glm::vec3(0.85f, 0.18f, 0.06f), t);
+ if (p.z > 0.0f && std::abs(p.x) < 0.6f && d2 < 0.12f) {
+ const float t = std::clamp((0.12f - d2) / 0.04f, 0.0f, 1.0f);
+ m.colors[v] = glm::mix(m.colors[v], glm::vec3(0.78f, 0.16f, 0.06f), t);
}
}
- pitch = -12.0f;
- distance = 0.0f;
return std::make_unique<Mesh>(std::move(m));
}
- const auto bt = BrushType(type);
- const bool sphere = !recipe && (bt == BrushType::Move || bt == BrushType::SnakeHook || bt == BrushType::Inflate);
- if (sphere) {
- d.setMesh(makeIcosphere(5, 0.9f));
- pitch = -12.0f;
- distance = 0.0f;
- if (bt == BrushType::Move)
- stroke(d, nullptr, bt, line({-0.1f, 0.0f, 2.0f}, {0.5f, 0.32f, 2.0f}), front, 0.6f, 1.0f, false);
- else if (bt == BrushType::SnakeHook) {
- // SnakeHook pulls out along the stroke; the path heads out of the surface to the side.
- stroke(d, nullptr, bt, line({0.15f, 0.15f, 2.0f}, {0.9f, 0.55f, 2.0f}), front, 0.28f, 1.0f, false);
- } else {
- std::vector<glm::vec3> pts;
- for (glm::vec3 p : planeCurve())
- pts.emplace_back(p.x * 0.8f, p.z * 1.4f, 2.0f);
- stroke(d, nullptr, bt, pts, front, 0.2f, 0.8f);
- }
- return sceneMesh(d);
- }
- d.setMesh(makePlane(220, 3.0f));
- const float r = 0.19f;
+ Document d;
+ d.setMesh(makeIcosphere(kBallDetail, kBallRadius));
+ const float r = 0.17f;
if (recipe) {
- stroke(d, recipe, BrushType::Standard, planeCurve(), down, r, 0.9f);
+ stroke(d, recipe, BrushType::Standard, frontCurve(), r, 0.9f);
return sceneMesh(d);
}
+ const auto bt = BrushType(type);
switch (bt) {
+ case BrushType::Move:
+ stroke(d, nullptr, bt, line({-0.1f, -0.1f, 2.0f}, {0.45f, 0.38f, 2.0f}), 0.45f, 1.0f, false);
+ break;
+ case BrushType::SnakeHook:
+ // SnakeHook pulls out along the stroke; the path heads out past the silhouette to the side.
+ stroke(d, nullptr, bt, line({0.2f, 0.12f, 2.0f}, {0.72f, 0.4f, 2.0f}), 0.24f, 1.0f, false);
+ break;
+ case BrushType::Inflate:
+ stroke(d, nullptr, bt, frontCurve(), 0.2f, 0.8f);
+ break;
case BrushType::Smooth:
case BrushType::Flatten:
case BrushType::Trim:
case BrushType::Nudge: {
// These change existing form: raise a ridge first, then cross it with the brush.
- const auto ridge = line({-0.9f, 1.0f, 0.0f}, {0.9f, 1.0f, 0.0f});
- stroke(d, nullptr, BrushType::Standard, ridge, down, 0.26f, 1.0f, false);
- stroke(d, nullptr, BrushType::Clay, ridge, down, 0.26f, 1.0f, false);
- const auto across = bt == BrushType::Nudge ? line({-0.15f, 1.0f, -0.35f}, {0.15f, 1.0f, 0.35f})
- : line({0.0f, 1.0f, -0.8f}, {0.0f, 1.0f, 0.8f});
+ const auto ridge = line({-0.75f, 0.0f, 2.0f}, {0.75f, 0.0f, 2.0f});
+ stroke(d, nullptr, BrushType::Standard, ridge, 0.22f, 1.0f, false);
+ stroke(d, nullptr, BrushType::Clay, ridge, 0.22f, 1.0f, false);
+ const auto across = bt == BrushType::Nudge ? line({-0.12f, -0.3f, 2.0f}, {0.12f, 0.3f, 2.0f})
+ : line({0.0f, -0.65f, 2.0f}, {0.0f, 0.65f, 2.0f});
const float strength = bt == BrushType::Nudge ? 0.05f : bt == BrushType::Trim ? 0.5f : 1.0f;
const int passes = bt == BrushType::Smooth ? 3 : 1;
for (int pass = 0; pass < passes; ++pass)
- stroke(d, nullptr, bt, across, down, bt == BrushType::Nudge ? 0.26f : 0.22f, strength, false);
+ stroke(d, nullptr, bt, across, bt == BrushType::Nudge ? 0.22f : 0.2f, strength, false);
break;
}
case BrushType::Pinch:
- stroke(d, nullptr, BrushType::Standard, planeCurve(), down, r * 1.2f, 0.9f);
- stroke(d, nullptr, bt, planeCurve(), down, r * 1.2f, 1.0f);
+ stroke(d, nullptr, BrushType::Standard, frontCurve(), r * 1.2f, 0.9f);
+ stroke(d, nullptr, bt, frontCurve(), r * 1.2f, 1.0f);
break;
case BrushType::ClayBuildup:
- stroke(d, nullptr, bt, planeCurve(), down, r, 0.12f);
+ stroke(d, nullptr, bt, frontCurve(), r, 0.12f);
break;
case BrushType::Layer:
- stroke(d, nullptr, bt, planeCurve(), down, 0.34f, 1.0f); // its height scales with the radius
+ stroke(d, nullptr, bt, frontCurve(), 0.38f, 1.0f); // its height scales with the radius
break;
case BrushType::Vdm: // one stamp of the built-in Horn
- stroke(d, nullptr, bt, {glm::vec3(0.0f, 1.0f, 0.1f)}, down, 0.5f, 0.5f, false);
+ stroke(d, nullptr, bt, {glm::vec3(0.0f, -0.05f, 2.0f)}, 0.45f, 0.5f, false);
break;
default:
- stroke(d, nullptr, bt, planeCurve(), down, r, 1.0f);
+ stroke(d, nullptr, bt, frontCurve(), r, 1.0f);
break;
}
return sceneMesh(d);
@@ -260,9 +259,11 @@ ImTextureID ThumbnailCache::brush(int brushType) {
hex64(fnv1a64(key)),
[brushType] {
Result r;
- r.mesh = sculptBrushPreview(nullptr, brushType, r.pitch, r.zoom, r.distance);
+ r.mesh = sculptBrushPreview(nullptr, brushType);
r.label = "brush-" + std::to_string(brushType);
r.yaw = 0.0f;
+ r.pitch = kBallPitch;
+ r.distance = ballDistance();
r.polypaint = brushType == kPaintBrush;
return r;
},
@@ -275,9 +276,11 @@ ImTextureID ThumbnailCache::recipe(const BrushRecipe& recipe) {
hex64(fnv1a64(key)),
[recipe] {
Result r;
- r.mesh = sculptBrushPreview(&recipe, 0, r.pitch, r.zoom, r.distance);
+ r.mesh = sculptBrushPreview(&recipe, 0);
r.label = "recipe-" + recipe.name;
r.yaw = 0.0f;
+ r.pitch = kBallPitch;
+ r.distance = ballDistance();
return r;
},
true);
@@ -300,8 +303,14 @@ ImTextureID ThumbnailCache::vdm(const std::shared_ptr<const VectorDisplacement>&
Document d;
d.setMesh(makePlane(200, 2.6f));
d.brushVdm = vdm;
- stroke(d, nullptr, BrushType::Vdm, {glm::vec3(0.0f, 1.0f, 0.0f)}, glm::vec3(0.0f, -1.0f, 0.0f), 0.62f,
- 0.5f, false);
+ PathStroke st;
+ st.points = {glm::vec3(0.0f, 1.0f, 0.0f)};
+ st.view = glm::vec3(0.0f, -1.0f, 0.0f);
+ st.radius = 0.62f;
+ st.strength = 0.5f;
+ st.curve = false;
+ std::string err;
+ strokePath(d, nullptr, BrushType::Vdm, st, err);
r.mesh = sceneMesh(d);
r.pitch = -40.0f;
r.yaw = 20.0f;
diff --git a/src/app/Thumbnails.h b/src/app/Thumbnails.h
index 07907a02..0f7e81b2 100644
--- a/src/app/Thumbnails.h
+++ b/src/app/Thumbnails.h
@@ -5,15 +5,16 @@
// cached in memory and on disk. Calls never block: they return 0 until the
// image is ready, and pump() does a little work each frame.
//
-// Workers sculpt the brush previews (one S-stroke with the real brush code on a
-// fresh plane or sphere), load meshes and decode images; the main thread then
-// renders at most two meshes per frame. Finished thumbnails are written to
+// Workers sculpt the brush previews (one S-stroke with the real brush code on the
+// front of a fresh clay ball, every brush framed and lit alike), load meshes and
+// decode images; the main thread then renders at most two meshes per frame. Finished thumbnails are written to
// <cache dir>/<fnv1a64 key>.png, and at most 256 textures stay in GPU memory.
#pragma once
#include "core/BrushAlpha.h"
#include "core/BrushRecipe.h"
#include "core/Image.h"
+#include "core/Matcap.h"
#include "core/Mesh.h"
#include "core/Vdm.h"
@@ -62,7 +63,7 @@ private:
struct Result {
Image image; // ready to upload (cache hit, image file, alpha, project thumbnail)
std::unique_ptr<Mesh> mesh; // needs a render
- int matcap = -1;
+ int matcap = defaultMatcap(); // -1 = Studio
float yaw = 30.0f, pitch = -15.0f; // degrees
float zoom = 0.92f; // camera distance relative to framing the whole mesh
float distance = 0.0f; // > 0: this camera distance from the origin instead
diff --git a/src/core/Matcap.cpp b/src/core/Matcap.cpp
index f3742112..a42b2b0a 100644
--- a/src/core/Matcap.cpp
+++ b/src/core/Matcap.cpp
@@ -24,18 +24,23 @@ struct MatcapStyle {
glm::vec3 rim;
float metal; // 0 = dielectric, 1 = pure environment reflection
float roughness; // blurs the environment for metals
- bool sculpt = false; // the readability-first sculpting light (shadeSculpt) instead of the shared model
+ // The shared model (shade), or a light of its own: shadeSculpt (readability first) or shadeSoftClay.
+ enum class Light { Shared, Sculpt, SoftClay } light = Light::Shared;
MatcapCavity cavity{};
};
const MatcapStyle kStyles[] = {
- {"Sculpt", {0.56f, 0.44f, 0.36f}, 0.0f, {0.0f, 0.0f, 0.0f}, 0.0f, 0.0f, {0.0f, 0.0f, 0.0f}, 0.0f, 0.0f, true, {0.8f, 0.35f}},
+ {"Sculpt", {0.56f, 0.44f, 0.36f}, 0.0f, {0.0f, 0.0f, 0.0f}, 0.0f, 0.0f, {0.0f, 0.0f, 0.0f}, 0.0f, 0.0f,
+ MatcapStyle::Light::Sculpt, {0.8f, 0.35f}},
{"Red Wax", {0.50f, 0.045f, 0.03f}, 0.55f, {0.55f, 0.06f, 0.03f}, 0.55f, 70.0f, {0.25f, 0.08f, 0.06f}, 0.0f, 0.0f},
{"Clay", {0.46f, 0.38f, 0.33f}, 0.25f, {0.05f, 0.03f, 0.02f}, 0.06f, 10.0f, {0.10f, 0.10f, 0.11f}, 0.0f, 0.0f},
{"Skin", {0.68f, 0.38f, 0.28f}, 0.6f, {0.6f, 0.16f, 0.08f}, 0.16f, 28.0f, {0.22f, 0.16f, 0.15f}, 0.0f, 0.0f},
{"Chrome", {0.95f, 0.96f, 1.0f}, 0.0f, {0.0f, 0.0f, 0.0f}, 0.0f, 1.0f, {0.0f, 0.0f, 0.0f}, 1.0f, 0.05f},
{"White", {0.78f, 0.78f, 0.76f}, 0.3f, {0.04f, 0.04f, 0.05f}, 0.3f, 45.0f, {0.12f, 0.13f, 0.15f}, 0.0f, 0.0f},
{"Bronze", {0.80f, 0.50f, 0.25f}, 0.0f, {0.0f, 0.0f, 0.0f}, 0.0f, 1.0f, {0.0f, 0.0f, 0.0f}, 1.0f, 0.35f},
+ // The default (defaultMatcap()). Last, so the indices of the others stay put.
+ {"Soft Clay", {0.50f, 0.455f, 0.41f}, 0.0f, {0.0f, 0.0f, 0.0f}, 0.0f, 0.0f, {0.0f, 0.0f, 0.0f}, 0.0f, 0.0f,
+ MatcapStyle::Light::SoftClay, {0.62f, 0.3f}},
};
constexpr int kStyleCount = int(sizeof kStyles / sizeof kStyles[0]);
@@ -79,8 +84,29 @@ glm::vec3 shadeSculpt(const MatcapStyle& m, const glm::vec3& n) {
return m.albedo * light + glm::vec3(spec) + glm::vec3(0.8f, 0.85f, 0.95f) * (fillSpec + rim);
}
+// The default: matte studio clay, a warm light grey. One broad key from the upper left wrapped far round
+// the form, a cool fill and a sky/ground ambient so nothing goes black, and only a wide, faint sheen: no
+// hot spot to blow out, so the form reads from the shading gradient and the cavity term (kStyles).
+glm::vec3 shadeSoftClay(const MatcapStyle& m, const glm::vec3& n) {
+ const glm::vec3 v(0.0f, 0.0f, 1.0f);
+ const glm::vec3 key = glm::normalize(glm::vec3(-0.45f, 0.6f, 0.7f));
+ const glm::vec3 fill = glm::normalize(glm::vec3(0.8f, -0.2f, 0.5f));
+ const float k = std::max((glm::dot(n, key) + 0.2f) / 1.2f, 0.0f);
+ const float diff = std::pow(k, 1.7f); // falls off steadily, so slopes and strokes read everywhere
+ const float fd = std::max(glm::dot(n, fill), 0.0f);
+ const float up = 0.5f + 0.5f * n.y;
+ const glm::vec3 ambient = glm::mix(glm::vec3(0.05f, 0.046f, 0.043f), glm::vec3(0.11f, 0.115f, 0.125f), up);
+ const glm::vec3 light = 1.2f * diff * glm::vec3(1.0f, 0.97f, 0.93f) + 0.2f * fd * fd * glm::vec3(0.8f, 0.86f, 1.0f) + ambient;
+ const float nh = std::max(glm::dot(n, glm::normalize(key + v)), 0.0f);
+ const float sheen = 0.05f * std::pow(nh, 8.0f);
+ // Grazing angles fall off a little, like a dry surface, which keeps the silhouette crisp on dark grey.
+ const float edge = 1.0f - 0.18f * std::pow(1.0f - std::max(n.z, 0.0f), 2.0f);
+ return (m.albedo * light + glm::vec3(sheen)) * edge;
+}
+
glm::vec3 shade(const MatcapStyle& m, const glm::vec3& n) {
- if (m.sculpt) return shadeSculpt(m, n);
+ if (m.light == MatcapStyle::Light::Sculpt) return shadeSculpt(m, n);
+ if (m.light == MatcapStyle::Light::SoftClay) return shadeSoftClay(m, n);
const glm::vec3 v(0.0f, 0.0f, 1.0f);
const float nv = std::max(n.z, 0.0f);
if (m.metal > 0.0f) {
@@ -115,6 +141,11 @@ std::string squash(const std::string& s) {
int matcapCount() { return kStyleCount; }
+int defaultMatcap() {
+ static const int index = findMatcap("Soft Clay");
+ return index;
+}
+
const char* matcapName(int index) { return index >= 0 && index < kStyleCount ? kStyles[index].name : ""; }
MatcapCavity matcapCavity(int index) { return index >= 0 && index < kStyleCount ? kStyles[index].cavity : MatcapCavity{}; }
diff --git a/src/core/Matcap.h b/src/core/Matcap.h
index bc0c5a6f..bd0d89ec 100644
--- a/src/core/Matcap.h
+++ b/src/core/Matcap.h
@@ -17,6 +17,8 @@ int matcapCount();
const char* matcapName(int index);
// Case-insensitive; also accepts names without spaces ("redwax"). -1 if unknown.
int findMatcap(const std::string& name);
+// The material new documents (and thumbnails) start with: Soft Clay, a matte warm clay.
+int defaultMatcap();
// How strongly the viewport darkens creases and lifts ridges on top of this matcap (the
// curvature term in the mesh shader); the Sculpt material leans on it more than the others.
diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp
index 66162f2e..2ea14a48 100644
--- a/src/render/Renderer.cpp
+++ b/src/render/Renderer.cpp
@@ -292,12 +292,16 @@ void main() {
const char* kBgFS = R"(#version 330 core
in vec2 vUv;
out vec4 fragColor;
+// Neutral charcoal, lightest a little above the middle (behind the model) and falling off in a soft
+// radial vignette, so the model reads against it without a coloured cast. A little noise hides banding.
void main() {
- vec3 top = vec3(0.20, 0.21, 0.24);
- vec3 bottom = vec3(0.08, 0.08, 0.09);
- float d = length(vUv - vec2(0.5, 0.55));
- vec3 c = mix(bottom, top, clamp(vUv.y, 0.0, 1.0)) * (1.0 - 0.35 * d);
- fragColor = vec4(c, 1.0);
+ vec3 centre = vec3(0.215, 0.215, 0.222);
+ vec3 edge = vec3(0.075, 0.075, 0.08);
+ float d = length((vUv - vec2(0.5, 0.56)) * vec2(1.0, 1.15));
+ float t = smoothstep(0.05, 0.85, d);
+ vec3 c = mix(centre, edge, t);
+ float noise = fract(sin(dot(gl_FragCoord.xy, vec2(12.9898, 78.233))) * 43758.5453);
+ fragColor = vec4(c + (noise - 0.5) / 255.0, 1.0);
}
)";
@@ -1968,7 +1972,7 @@ void Renderer::draw(const Camera& camera, int targetWidth, int targetHeight, con
}
const int fbWidth = inset ? viewport.w : targetWidth, fbHeight = inset ? viewport.h : targetHeight;
if (thumbnailPass_) gl::ClearColor(0.0f, 0.0f, 0.0f, 0.0f); // renderMeshThumbnail: transparent background
- else gl::ClearColor(0.1f, 0.1f, 0.11f, 1.0f);
+ else gl::ClearColor(0.075f, 0.075f, 0.08f, 1.0f);
gl::Clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
gl::Enable(GL_MULTISAMPLE);
struct ScissorOff {
@@ -1978,7 +1982,7 @@ void Renderer::draw(const Camera& camera, int targetWidth, int targetHeight, con
}
} scissorOff{inset};
- // Background gradient.
+ // Background: charcoal with a radial vignette.
gl::Disable(GL_DEPTH_TEST);
gl::UseProgram(bgProgram_);
gl::BindVertexArray(emptyVao_);
diff --git a/src/render/Renderer.h b/src/render/Renderer.h
index f8b52bf0..87e5c294 100644
--- a/src/render/Renderer.h
+++ b/src/render/Renderer.h
@@ -2,6 +2,7 @@
// SPDX-License-Identifier: GPL-3.0-or-later
#pragma once
+#include "core/Matcap.h"
#include "core/Mesh.h"
#include "core/Splats.h"
#include "core/UploadOrder.h"
@@ -22,7 +23,7 @@ struct RenderSettings {
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)
- int matcap = 0; // built-in MatCap material (core/Matcap.h), 0 = Sculpt; -1 = studio clay lighting
+ int matcap = defaultMatcap(); // built-in MatCap material (core/Matcap.h), Soft Clay; -1 = studio clay lighting
bool showMesh = true;
bool showSplats = true;
float splatOpacity = 1.0f; // global fade for using a capture as reference
diff --git a/tests/test_polypaint.cpp b/tests/test_polypaint.cpp
index 9e3b0264..833c1796 100644
--- a/tests/test_polypaint.cpp
+++ b/tests/test_polypaint.cpp
@@ -306,7 +306,7 @@ TEST(matcap_builtin_materials) {
// Deterministic.
CHECK(generateMatcap(findMatcap("Chrome"), size) == chrome);
- // Sculpt, the default material, comes first: a neutral warm clay with a strong key from the upper
+ // Sculpt, the readability-first material, comes first: a neutral warm clay with a strong key from the upper
// left (a clear light-to-shadow range, so slopes read), and the deepest cavity shading of them all.
CHECK(findMatcap("sculpt") == 0);
const std::vector<uint8_t> sculpt = generateMatcap(0, size);
@@ -314,6 +314,17 @@ TEST(matcap_builtin_materials) {
CHECK(sc.x >= sc.z && sc.x - sc.z < 60);
CHECK(pixel(sculpt, size / 4, size * 3 / 4).x > pixel(sculpt, size * 3 / 4, size / 4).x + 60);
for (int i = 1; i < matcapCount(); ++i) CHECK(matcapCavity(0).crease > matcapCavity(i).crease);
+
+ // Soft Clay, the default (last, so the others keep their indices): a matte warm light grey, lit
+ // from the upper left, with no highlight anywhere near white.
+ CHECK(defaultMatcap() == findMatcap("soft clay") && defaultMatcap() == matcapCount() - 1);
+ const std::vector<uint8_t> clay = generateMatcap(defaultMatcap(), size);
+ const glm::ivec4 cl = pixel(clay, size / 2, size / 2);
+ CHECK(cl.x >= cl.z && cl.x - cl.z < 30 && cl.x > 120);
+ CHECK(pixel(clay, size / 4, size * 3 / 4).x > pixel(clay, size * 3 / 4, size / 4).x + 40);
+ int brightest = 0;
+ for (size_t k = 0; k < clay.size(); k += 4) brightest = std::max(brightest, int(clay[k]));
+ CHECK(brightest < 225);
CHECK(matcapCavity(-1).crease > 0.0f && matcapCavity(matcapCount()).crease == matcapCavity(-1).crease);
}