Skip to content

Commit 174d716

Browse files
committed
Bring 2.0 stroke ordering fixes to 1.x
1 parent 6e024b4 commit 174d716

File tree

5 files changed

+21
-3
lines changed

5 files changed

+21
-3
lines changed

src/webgl/shaders/line.frag

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
precision mediump int;
1+
precision highp int;
2+
precision highp float;
23

34
uniform vec4 uMaterialColor;
45
uniform int uStrokeCap;

src/webgl/shaders/line.vert

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818

1919
#define PROCESSING_LINE_SHADER
2020

21-
precision mediump int;
21+
precision highp int;
22+
precision highp float;
2223

2324
uniform mat4 uModelViewMatrix;
2425
uniform mat4 uProjectionMatrix;
@@ -116,7 +117,7 @@ void main() {
116117

117118
// Moving vertices slightly toward camera when far away
118119
// https://github.com/processing/p5.js/issues/6956
119-
float zOffset = mix(-0.00045, -1., facingCamera);
120+
float zOffset = mix(0., -1., facingCamera);
120121
float dynamicZAdjustment = mix(0.0, zOffset, distanceFactor); // Closer = less zAdjustment, farther = more
121122

122123
posp.z -= dynamicZAdjustment;

test/unit/visual/cases/webgl.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,4 +128,17 @@ visualSuite('WebGL', function() {
128128
}
129129
);
130130
});
131+
132+
visualSuite('Strokes', function() {
133+
visualTest('Strokes do not cut into fills in ortho mode', (p5, screenshot) => {
134+
p5.createCanvas(50, 50, p5.WEBGL);
135+
p5.background(220);
136+
p5.stroke(8);
137+
p5.ortho();
138+
p5.rotateX(p5.PI/4);
139+
p5.rotateY(p5.PI/4);
140+
p5.box(30);
141+
screenshot();
142+
});
143+
});
131144
});
558 Bytes
Loading
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"numScreenshots": 1
3+
}

0 commit comments

Comments
 (0)