MeshPainter: Kugel-Brush statt Box, cornerGuard entfernt
Stamp testet den Brush wieder als 3D-Kugel (du²+dv²+dn² = r²) statt als Box (|du|,|dv|,|dn| = r) — konsistent über CPU, GPU-Brush und Preview. Die Box reichte diagonal bis r·√3 und spannte einen 2r-dicken Slab entlang der Normale, wodurch an Nähten/Kanten/dünner Geometrie auf die Gegenseite/Nachbarinseln gemalt wurde. Die Kugel reicht in jede Richtung exakt r und überbrückt echte 3D-Nähte weiterhin, greift aber nicht mehr über r hinaus. cornerGuard war nur ein Pflaster gegen genau diesen Box-Übergriff und ist damit überflüssig: Config-Felder, Suppress-Check und Helper (DabWrapsAroundCorner, CornerWrapFraction, InBrushBox, SquareReach) entfernt. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
1 parent
2195427e6c
commit
1f42c990fb
5 files changed
+27
-131
No files matched your search
@@ -5,8 +5,9 @@
|
||||
// passed through to the fragment shader. There, per texel, the offset to the brush
|
||||
// center (_BrushCenter, in local mesh space) is projected onto the stamp's tangent
|
||||
// frame: _BrushU (right), _BrushV (up) and _BrushNormal. The texel is painted only
|
||||
// if it lies inside the box (|du|,|dv|,|dn| <= _BrushRadius); the brush mask
|
||||
// (_MaskTex, sampled along du/dv) then provides the per-texel OPACITY:
|
||||
// if it lies inside the brush SPHERE (du²+dv²+dn² <= _BrushRadius²) - isotropic reach
|
||||
// like the original circle brush, so the dab never bleeds across a seam / around a
|
||||
// corner. The mask (_MaskTex, sampled along du/dv) then provides the per-texel OPACITY:
|
||||
// opacity = luma(mask.rgb) * mask.a * _BrushColor.a
|
||||
// and the color is alpha-blended over the existing paint (source-over). So a mask
|
||||
// gray value of 0.5 paints at 50%, white = full, black/transparent = nothing.
|
||||
@@ -86,13 +87,11 @@ Shader "Hidden/MeshPaintBrush"
|
||||
float dv = dot(d, _BrushV);
|
||||
float dn = dot(d, _BrushNormal);
|
||||
|
||||
// Square stamp in the tangent plane + depth bound (keeps the seam-
|
||||
// bridging 3D behavior while preventing bleed to far surfaces).
|
||||
clip(_BrushRadius - abs(du));
|
||||
clip(_BrushRadius - abs(dv));
|
||||
clip(_BrushRadius - abs(dn));
|
||||
// Brush sphere: isotropic reach r in every direction, so the dab bridges seams
|
||||
// (both sides of a 3D edge) yet never bleeds onto far/adjacent surfaces past r.
|
||||
clip(_BrushRadius * _BrushRadius - (du * du + dv * dv + dn * dn));
|
||||
|
||||
// Mask -> opacity. du/dv in [-r,r] -> uv in [0,1].
|
||||
// Mask -> opacity. The sphere guarantees |du|,|dv| <= r -> uv in [0,1].
|
||||
float2 muv = float2(du, dv) / _BrushRadius * 0.5 + 0.5;
|
||||
fixed4 m = tex2D(_MaskTex, muv);
|
||||
float luma = dot(m.rgb, fixed3(0.299, 0.587, 0.114));
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// WITHOUT painting. Two modes, selected via _PreviewMode:
|
||||
//
|
||||
// 0 = On-surface: the baked mesh is drawn again (object transform) and each
|
||||
// fragment runs the SAME box + mask test as the paint shader, in local mesh
|
||||
// fragment runs the SAME sphere + mask test as the paint shader, in local mesh
|
||||
// space (_BrushCenter/_BrushU/_BrushV/_BrushNormal/_BrushRadius). So the
|
||||
// preview wraps over curvature and across UV seams exactly like the paint
|
||||
// would land. Depth test (LEqual) + a slight polygon offset keep it glued to
|
||||
@@ -74,14 +74,12 @@ Shader "Hidden/MeshPaintPreview"
|
||||
float2 muv;
|
||||
if (_PreviewMode < 0.5)
|
||||
{
|
||||
// On-surface: same square box test as the paint shader, in local space.
|
||||
// On-surface: same brush-sphere test as the paint shader, in local space.
|
||||
float3 d = i.local - _BrushCenter;
|
||||
float du = dot(d, _BrushU);
|
||||
float dv = dot(d, _BrushV);
|
||||
float dn = dot(d, _BrushNormal);
|
||||
clip(_BrushRadius - abs(du));
|
||||
clip(_BrushRadius - abs(dv));
|
||||
clip(_BrushRadius - abs(dn));
|
||||
clip(_BrushRadius * _BrushRadius - (du * du + dv * dv + dn * dn));
|
||||
muv = float2(du, dv) / _BrushRadius * 0.5 + 0.5;
|
||||
}
|
||||
else
|
||||
|
||||
Reference in new issue
Block a user