Fix #137958: Overlay: Lines are too thick

Caused by b8f591c348.
The copy pasted code was not the same everywere.
Invert the result only for the grid shader as it
used to be.
This commit is contained in:
Clément Foucault
2025-04-24 15:20:25 +02:00
parent 0f72fffac3
commit 438f8930cc
2 changed files with 5 additions and 4 deletions

View File

@@ -400,6 +400,7 @@ BLI_STATIC_ASSERT_ALIGN(BoneStickData, 16)
*/
#define M_1_SQRTPI 0.5641895835477563f /* `1/sqrt(pi)`. */
#define DISC_RADIUS (M_1_SQRTPI * 1.05f)
#define LINE_SMOOTH_START (0.5f + DISC_RADIUS)
#define LINE_SMOOTH_END (0.5f - DISC_RADIUS)
#define LINE_SMOOTH_START (0.5f - DISC_RADIUS)
#define LINE_SMOOTH_END (0.5f + DISC_RADIUS)
/* Returns 0 before LINE_SMOOTH_START and 1 after LINE_SMOOTH_END. */
#define LINE_STEP(dist) smoothstep(LINE_SMOOTH_START, LINE_SMOOTH_END, dist)

View File

@@ -26,7 +26,7 @@ float get_grid(float2 co, float2 fwidthCos, float2 grid_scale)
grid_domain /= fwidthCos;
/* Collapse waves. */
float line_dist = min(grid_domain.x, grid_domain.y);
return LINE_STEP(line_dist - grid_buf.line_size);
return 1.0 - LINE_STEP(line_dist - grid_buf.line_size);
}
float3 get_axes(float3 co, float3 fwidthCos, float line_size)
@@ -35,7 +35,7 @@ float3 get_axes(float3 co, float3 fwidthCos, float line_size)
/* Modulate by the absolute rate of change of the coordinates
* (make line have the same width under perspective). */
axes_domain /= fwidthCos;
return LINE_STEP(axes_domain - (line_size + grid_buf.line_size));
return 1.0 - LINE_STEP(axes_domain - (line_size + grid_buf.line_size));
}
#define linearstep(p0, p1, v) (clamp(((v) - (p0)) / abs((p1) - (p0)), 0.0f, 1.0f))