1- precision mediump float ;
1+ precision highp float ;
22
3- #pragma glslify : inverse = require("glsl - inverse")
3+ attribute vec2 aHi, aLo, dHi, dLo;
44
5- attribute vec2 a, d;
6-
7- uniform mat3 matrix;
8- uniform vec2 screenShape;
5+ uniform vec2 scaleHi, translateHi, scaleLo, translateLo, screenShape;
96uniform float width;
107
118varying vec2 direction;
129
10+ #pragma glslify: baseProject = require("./baseProject.glsl")
11+ #pragma glslify: dirProject = require("./dirProject.glsl")
12+
1313void main() {
14- vec2 dir = (matrix * vec3 (d, 0 )).xy;
15- vec3 base = matrix * vec3 (a, 1 );
16- vec2 n = 0.5 * width *
17- normalize (screenShape.yx * vec2 (dir.y, - dir.x)) / screenShape.xy;
14+ vec2 p = baseProject(scaleHi, translateHi, scaleLo, translateLo, aHi, aLo);
15+ vec2 dir = dirProject(scaleHi, scaleLo, dHi, dLo);
16+ vec2 n = 0.5 * width * normalize (screenShape.yx * vec2 (dir.y, - dir.x)) / screenShape.xy;
1817 vec2 tangent = normalize (screenShape.xy * dir);
1918 if (dir.x < 0.0 || (dir.x == 0.0 && dir.y < 0.0 )) {
2019 direction = - tangent;
2120 } else {
2221 direction = tangent;
2322 }
24- gl_Position = vec4 (base.xy / base.z + n, 0 , 1 );
25- }
23+ gl_Position = vec4 (p + n, 0.0 , 1.0 );
24+ }
0 commit comments