fix(render): give degenerate segments area, pin font bit order, clarify vertex_count
This commit is contained in:
1 parent
7cbc1c9955
commit
b4e88fe0c1
5 files changed
+76
-15
No files matched your search
+11
-6
@@ -25,15 +25,20 @@ void main() {
|
||||
vec2 p1 = a_p1 * u_scale + u_offset;
|
||||
vec2 d = p1 - p0;
|
||||
float len = length(d);
|
||||
// A degenerate segment has no direction: pin the normal so the quad stays
|
||||
// finite and the instance draws as a dot instead of NaN geometry.
|
||||
vec2 n = len > 1e-6 ? vec2(-d.y, d.x) / len : vec2(0.0, 1.0);
|
||||
float half_w = u_width * 0.5 + 1.0; // + one pixel of AA fringe
|
||||
// A degenerate segment has no direction: pin the normal, and give the quad
|
||||
// area by stretching its two ends apart along x. Collapsing all four corners
|
||||
// onto p0 would rasterise nothing, and a flat trace staged as p == p (the
|
||||
// dense path's min == max buckets) would then silently vanish. When
|
||||
// len > 1e-6 the two ends are p0 and p1 exactly as before.
|
||||
vec2 n = len > 1e-6 ? vec2(-d.y, d.x) / len : vec2(0.0, 1.0);
|
||||
vec2 e0 = len > 1e-6 ? p0 : p0 - vec2(half_w, 0.0);
|
||||
vec2 e1 = len > 1e-6 ? p1 : p0 + vec2(half_w, 0.0);
|
||||
|
||||
// gl_VertexID picks the corner: 0,1 are the sides of a_p0 and 2,3 of a_p1,
|
||||
// which is the order GL_TRIANGLE_STRIP expects.
|
||||
// gl_VertexID picks the corner: 0,1 are the sides of the segment's start and
|
||||
// 2,3 of its end, which is the order GL_TRIANGLE_STRIP expects.
|
||||
float side = (gl_VertexID & 1) == 0 ? -1.0 : 1.0;
|
||||
vec2 base = (gl_VertexID & 2) == 0 ? p0 : p1;
|
||||
vec2 base = (gl_VertexID & 2) == 0 ? e0 : e1;
|
||||
vec2 px = base + n * (side * half_w);
|
||||
|
||||
// Rect is top-left origin, GL is bottom-left: flip y once, here, and never
|
||||
|
||||
Reference in new issue
Block a user