Refactor LineString GLSL & clean up
This commit is contained in:
@@ -22,7 +22,7 @@ uniform float u_pixelRatio;
|
||||
|
||||
void main(void) {
|
||||
mat4 offsetMatrix = u_offsetScaleMatrix * u_offsetRotateMatrix;
|
||||
v_center = vec4(u_projectionMatrix * vec4(a_position, 0., 1.)).xy;
|
||||
v_center = vec4(u_projectionMatrix * vec4(a_position, 0.0, 1.0)).xy;
|
||||
v_pixelRatio = u_pixelRatio;
|
||||
float lineWidth = u_lineWidth * u_pixelRatio;
|
||||
v_halfWidth = lineWidth / 2.0;
|
||||
@@ -45,13 +45,13 @@ void main(void) {
|
||||
offset = vec2(1.0, 1.0);
|
||||
}
|
||||
|
||||
gl_Position = u_projectionMatrix * vec4(a_position + offset * radius, 0., 1.) +
|
||||
offsetMatrix * vec4(offset * lineWidth, 0., 0.);
|
||||
gl_Position = u_projectionMatrix * vec4(a_position + offset * radius, 0.0, 1.0) +
|
||||
offsetMatrix * vec4(offset * lineWidth, 0.0, 0.0);
|
||||
v_offset = vec4(u_projectionMatrix * vec4(a_position.x + a_radius, a_position.y,
|
||||
0., 1.)).xy;
|
||||
0.0, 1.0)).xy;
|
||||
|
||||
if (distance(v_center, v_offset) > 20000.0) {
|
||||
gl_Position = vec4(v_center, 0., 1.);
|
||||
gl_Position = vec4(v_center, 0.0, 1.0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -58,14 +58,14 @@ ol.inherits(ol.render.webgl.circlereplay.defaultshader.Vertex, ol.webgl.Vertex);
|
||||
* @const
|
||||
* @type {string}
|
||||
*/
|
||||
ol.render.webgl.circlereplay.defaultshader.Vertex.DEBUG_SOURCE = 'varying vec2 v_center;\nvarying vec2 v_offset;\nvarying float v_halfWidth;\nvarying float v_pixelRatio;\n\n\nattribute vec2 a_position;\nattribute float a_instruction;\nattribute float a_radius;\n\nuniform mat4 u_projectionMatrix;\nuniform mat4 u_offsetScaleMatrix;\nuniform mat4 u_offsetRotateMatrix;\nuniform float u_lineWidth;\nuniform float u_pixelRatio;\n\nvoid main(void) {\n mat4 offsetMatrix = u_offsetScaleMatrix * u_offsetRotateMatrix;\n v_center = vec4(u_projectionMatrix * vec4(a_position, 0., 1.)).xy;\n v_pixelRatio = u_pixelRatio;\n float lineWidth = u_lineWidth * u_pixelRatio;\n v_halfWidth = lineWidth / 2.0;\n if (lineWidth == 0.0) {\n lineWidth = 2.0 * u_pixelRatio;\n }\n vec2 offset;\n // Radius with anitaliasing (roughly).\n float radius = a_radius + 3.0 * u_pixelRatio;\n // Until we get gl_VertexID in WebGL, we store an instruction.\n if (a_instruction == 0.0) {\n // Offsetting the edges of the triangle by lineWidth / 2 is necessary, however\n // we should also leave some space for the antialiasing, thus we offset by lineWidth.\n offset = vec2(-1.0, 1.0);\n } else if (a_instruction == 1.0) {\n offset = vec2(-1.0, -1.0);\n } else if (a_instruction == 2.0) {\n offset = vec2(1.0, -1.0);\n } else {\n offset = vec2(1.0, 1.0);\n }\n\n gl_Position = u_projectionMatrix * vec4(a_position + offset * radius, 0., 1.) +\n offsetMatrix * vec4(offset * lineWidth, 0., 0.);\n v_offset = vec4(u_projectionMatrix * vec4(a_position.x + a_radius, a_position.y,\n 0., 1.)).xy;\n\n if (distance(v_center, v_offset) > 20000.0) {\n gl_Position = vec4(v_center, 0., 1.);\n }\n}\n\n\n';
|
||||
ol.render.webgl.circlereplay.defaultshader.Vertex.DEBUG_SOURCE = 'varying vec2 v_center;\nvarying vec2 v_offset;\nvarying float v_halfWidth;\nvarying float v_pixelRatio;\n\n\nattribute vec2 a_position;\nattribute float a_instruction;\nattribute float a_radius;\n\nuniform mat4 u_projectionMatrix;\nuniform mat4 u_offsetScaleMatrix;\nuniform mat4 u_offsetRotateMatrix;\nuniform float u_lineWidth;\nuniform float u_pixelRatio;\n\nvoid main(void) {\n mat4 offsetMatrix = u_offsetScaleMatrix * u_offsetRotateMatrix;\n v_center = vec4(u_projectionMatrix * vec4(a_position, 0.0, 1.0)).xy;\n v_pixelRatio = u_pixelRatio;\n float lineWidth = u_lineWidth * u_pixelRatio;\n v_halfWidth = lineWidth / 2.0;\n if (lineWidth == 0.0) {\n lineWidth = 2.0 * u_pixelRatio;\n }\n vec2 offset;\n // Radius with anitaliasing (roughly).\n float radius = a_radius + 3.0 * u_pixelRatio;\n // Until we get gl_VertexID in WebGL, we store an instruction.\n if (a_instruction == 0.0) {\n // Offsetting the edges of the triangle by lineWidth / 2 is necessary, however\n // we should also leave some space for the antialiasing, thus we offset by lineWidth.\n offset = vec2(-1.0, 1.0);\n } else if (a_instruction == 1.0) {\n offset = vec2(-1.0, -1.0);\n } else if (a_instruction == 2.0) {\n offset = vec2(1.0, -1.0);\n } else {\n offset = vec2(1.0, 1.0);\n }\n\n gl_Position = u_projectionMatrix * vec4(a_position + offset * radius, 0.0, 1.0) +\n offsetMatrix * vec4(offset * lineWidth, 0.0, 0.0);\n v_offset = vec4(u_projectionMatrix * vec4(a_position.x + a_radius, a_position.y,\n 0.0, 1.0)).xy;\n\n if (distance(v_center, v_offset) > 20000.0) {\n gl_Position = vec4(v_center, 0.0, 1.0);\n }\n}\n\n\n';
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {string}
|
||||
*/
|
||||
ol.render.webgl.circlereplay.defaultshader.Vertex.OPTIMIZED_SOURCE = 'varying vec2 a;varying vec2 b;varying float c;varying float d;attribute vec2 e;attribute float f;attribute float g;uniform mat4 h;uniform mat4 i;uniform mat4 j;uniform float k;uniform float l;void main(void){mat4 offsetMatrix=i*j;a=vec4(h*vec4(e,0.,1.)).xy;d=l;float lineWidth=k*l;c=lineWidth/2.0;if(lineWidth==0.0){lineWidth=2.0*l;}vec2 offset;float radius=g+3.0*l;if(f==0.0){offset=vec2(-1.0,1.0);}else if(f==1.0){offset=vec2(-1.0,-1.0);}else if(f==2.0){offset=vec2(1.0,-1.0);}else{offset=vec2(1.0,1.0);}gl_Position=h*vec4(e+offset*radius,0.,1.)+offsetMatrix*vec4(offset*lineWidth,0.,0.);b=vec4(h*vec4(e.x+g,e.y,0.,1.)).xy;if(distance(a,b)>20000.0){gl_Position=vec4(a,0.,1.);}}';
|
||||
ol.render.webgl.circlereplay.defaultshader.Vertex.OPTIMIZED_SOURCE = 'varying vec2 a;varying vec2 b;varying float c;varying float d;attribute vec2 e;attribute float f;attribute float g;uniform mat4 h;uniform mat4 i;uniform mat4 j;uniform float k;uniform float l;void main(void){mat4 offsetMatrix=i*j;a=vec4(h*vec4(e,0.0,1.0)).xy;d=l;float lineWidth=k*l;c=lineWidth/2.0;if(lineWidth==0.0){lineWidth=2.0*l;}vec2 offset;float radius=g+3.0*l;if(f==0.0){offset=vec2(-1.0,1.0);}else if(f==1.0){offset=vec2(-1.0,-1.0);}else if(f==2.0){offset=vec2(1.0,-1.0);}else{offset=vec2(1.0,1.0);}gl_Position=h*vec4(e+offset*radius,0.0,1.0)+offsetMatrix*vec4(offset*lineWidth,0.0,0.0);b=vec4(h*vec4(e.x+g,e.y,0.0,1.0)).xy;if(distance(a,b)>20000.0){gl_Position=vec4(a,0.0,1.0);}}';
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -22,8 +22,8 @@ void main(void) {
|
||||
if (a_rotateWithView == 1.0) {
|
||||
offsetMatrix = u_offsetScaleMatrix * u_offsetRotateMatrix;
|
||||
}
|
||||
vec4 offsets = offsetMatrix * vec4(a_offsets, 0., 0.);
|
||||
gl_Position = u_projectionMatrix * vec4(a_position, 0., 1.) + offsets;
|
||||
vec4 offsets = offsetMatrix * vec4(a_offsets, 0.0, 0.0);
|
||||
gl_Position = u_projectionMatrix * vec4(a_position, 0.0, 1.0) + offsets;
|
||||
v_texCoord = a_texCoord;
|
||||
v_opacity = a_opacity;
|
||||
}
|
||||
|
||||
@@ -58,14 +58,14 @@ ol.inherits(ol.render.webgl.imagereplay.defaultshader.Vertex, ol.webgl.Vertex);
|
||||
* @const
|
||||
* @type {string}
|
||||
*/
|
||||
ol.render.webgl.imagereplay.defaultshader.Vertex.DEBUG_SOURCE = 'varying vec2 v_texCoord;\nvarying float v_opacity;\n\nattribute vec2 a_position;\nattribute vec2 a_texCoord;\nattribute vec2 a_offsets;\nattribute float a_opacity;\nattribute float a_rotateWithView;\n\nuniform mat4 u_projectionMatrix;\nuniform mat4 u_offsetScaleMatrix;\nuniform mat4 u_offsetRotateMatrix;\n\nvoid main(void) {\n mat4 offsetMatrix = u_offsetScaleMatrix;\n if (a_rotateWithView == 1.0) {\n offsetMatrix = u_offsetScaleMatrix * u_offsetRotateMatrix;\n }\n vec4 offsets = offsetMatrix * vec4(a_offsets, 0., 0.);\n gl_Position = u_projectionMatrix * vec4(a_position, 0., 1.) + offsets;\n v_texCoord = a_texCoord;\n v_opacity = a_opacity;\n}\n\n\n';
|
||||
ol.render.webgl.imagereplay.defaultshader.Vertex.DEBUG_SOURCE = 'varying vec2 v_texCoord;\nvarying float v_opacity;\n\nattribute vec2 a_position;\nattribute vec2 a_texCoord;\nattribute vec2 a_offsets;\nattribute float a_opacity;\nattribute float a_rotateWithView;\n\nuniform mat4 u_projectionMatrix;\nuniform mat4 u_offsetScaleMatrix;\nuniform mat4 u_offsetRotateMatrix;\n\nvoid main(void) {\n mat4 offsetMatrix = u_offsetScaleMatrix;\n if (a_rotateWithView == 1.0) {\n offsetMatrix = u_offsetScaleMatrix * u_offsetRotateMatrix;\n }\n vec4 offsets = offsetMatrix * vec4(a_offsets, 0.0, 0.0);\n gl_Position = u_projectionMatrix * vec4(a_position, 0.0, 1.0) + offsets;\n v_texCoord = a_texCoord;\n v_opacity = a_opacity;\n}\n\n\n';
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {string}
|
||||
*/
|
||||
ol.render.webgl.imagereplay.defaultshader.Vertex.OPTIMIZED_SOURCE = 'varying vec2 a;varying float b;attribute vec2 c;attribute vec2 d;attribute vec2 e;attribute float f;attribute float g;uniform mat4 h;uniform mat4 i;uniform mat4 j;void main(void){mat4 offsetMatrix=i;if(g==1.0){offsetMatrix=i*j;}vec4 offsets=offsetMatrix*vec4(e,0.,0.);gl_Position=h*vec4(c,0.,1.)+offsets;a=d;b=f;}';
|
||||
ol.render.webgl.imagereplay.defaultshader.Vertex.OPTIMIZED_SOURCE = 'varying vec2 a;varying float b;attribute vec2 c;attribute vec2 d;attribute vec2 e;attribute float f;attribute float g;uniform mat4 h;uniform mat4 i;uniform mat4 j;void main(void){mat4 offsetMatrix=i;if(g==1.0){offsetMatrix=i*j;}vec4 offsets=offsetMatrix*vec4(e,0.0,0.0);gl_Position=h*vec4(c,0.0,1.0)+offsets;a=d;b=f;}';
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -20,96 +20,119 @@ uniform mat4 u_offsetRotateMatrix;
|
||||
uniform float u_lineWidth;
|
||||
uniform float u_miterLimit;
|
||||
|
||||
bool nearlyEquals(in float value, in float ref) {
|
||||
float epsilon = 0.000000000001;
|
||||
return value >= ref - epsilon && value <= ref + epsilon;
|
||||
}
|
||||
|
||||
void alongNormal(out vec2 offset, in vec2 nextP, in float turnDir, in float direction) {
|
||||
vec2 dirVect = nextP - a_position;
|
||||
vec2 normal = normalize(vec2(-turnDir * dirVect.y, turnDir * dirVect.x));
|
||||
offset = u_lineWidth / 2.0 * normal * direction;
|
||||
}
|
||||
|
||||
void miterUp(out vec2 offset, out float round, in bool isRound, in float direction) {
|
||||
float halfWidth = u_lineWidth / 2.0;
|
||||
vec2 tangent = normalize(normalize(a_nextPos - a_position) + normalize(a_position - a_lastPos));
|
||||
vec2 normal = vec2(-tangent.y, tangent.x);
|
||||
vec2 dirVect = a_nextPos - a_position;
|
||||
vec2 tmpNormal = normalize(vec2(-dirVect.y, dirVect.x));
|
||||
float miterLength = abs(halfWidth / dot(normal, tmpNormal));
|
||||
offset = normal * direction * miterLength;
|
||||
round = 0.0;
|
||||
if (isRound) {
|
||||
round = 1.0;
|
||||
} else if (miterLength > u_miterLimit + u_lineWidth) {
|
||||
offset = halfWidth * tmpNormal * direction;
|
||||
}
|
||||
}
|
||||
|
||||
bool miterDown(out vec2 offset, in vec4 projPos, in mat4 offsetMatrix, in float direction) {
|
||||
bool degenerate = false;
|
||||
vec2 tangent = normalize(normalize(a_nextPos - a_position) + normalize(a_position - a_lastPos));
|
||||
vec2 normal = vec2(-tangent.y, tangent.x);
|
||||
vec2 dirVect = a_lastPos - a_position;
|
||||
vec2 tmpNormal = normalize(vec2(-dirVect.y, dirVect.x));
|
||||
vec2 longOffset, shortOffset, longVertex;
|
||||
vec4 shortProjVertex;
|
||||
float halfWidth = u_lineWidth / 2.0;
|
||||
if (length(a_nextPos - a_position) > length(a_lastPos - a_position)) {
|
||||
longOffset = tmpNormal * direction * halfWidth;
|
||||
shortOffset = normalize(vec2(dirVect.y, -dirVect.x)) * direction * halfWidth;
|
||||
longVertex = a_nextPos;
|
||||
shortProjVertex = u_projectionMatrix * vec4(a_lastPos, 0.0, 1.0);
|
||||
} else {
|
||||
shortOffset = tmpNormal * direction * halfWidth;
|
||||
longOffset = normalize(vec2(dirVect.y, -dirVect.x)) * direction * halfWidth;
|
||||
longVertex = a_lastPos;
|
||||
shortProjVertex = u_projectionMatrix * vec4(a_nextPos, 0.0, 1.0);
|
||||
}
|
||||
//Intersection algorithm based on theory by Paul Bourke (http://paulbourke.net/geometry/pointlineplane/).
|
||||
vec4 p1 = u_projectionMatrix * vec4(longVertex, 0.0, 1.0) + offsetMatrix * vec4(longOffset, 0.0, 0.0);
|
||||
vec4 p2 = projPos + offsetMatrix * vec4(longOffset, 0.0, 0.0);
|
||||
vec4 p3 = shortProjVertex + offsetMatrix * vec4(-shortOffset, 0.0, 0.0);
|
||||
vec4 p4 = shortProjVertex + offsetMatrix * vec4(shortOffset, 0.0, 0.0);
|
||||
float denom = (p4.y - p3.y) * (p2.x - p1.x) - (p4.x - p3.x) * (p2.y - p1.y);
|
||||
float firstU = ((p4.x - p3.x) * (p1.y - p3.y) - (p4.y - p3.y) * (p1.x - p3.x)) / denom;
|
||||
float secondU = ((p2.x - p1.x) * (p1.y - p3.y) - (p2.y - p1.y) * (p1.x - p3.x)) / denom;
|
||||
float epsilon = 0.000000000001;
|
||||
if (firstU > epsilon && firstU < 1.0 - epsilon && secondU > epsilon && secondU < 1.0 - epsilon) {
|
||||
shortProjVertex.x = p1.x + firstU * (p2.x - p1.x);
|
||||
shortProjVertex.y = p1.y + firstU * (p2.y - p1.y);
|
||||
offset = shortProjVertex.xy;
|
||||
degenerate = true;
|
||||
} else {
|
||||
float miterLength = abs(halfWidth / dot(normal, tmpNormal));
|
||||
offset = normal * direction * miterLength;
|
||||
}
|
||||
return degenerate;
|
||||
}
|
||||
|
||||
void squareCap(out vec2 offset, out float round, in bool isRound, in vec2 nextP,
|
||||
in float turnDir, in float direction) {
|
||||
round = 0.0;
|
||||
vec2 dirVect = a_position - nextP;
|
||||
vec2 firstNormal = normalize(dirVect);
|
||||
vec2 secondNormal = vec2(turnDir * firstNormal.y * direction, -turnDir * firstNormal.x * direction);
|
||||
vec2 hypotenuse = normalize(firstNormal - secondNormal);
|
||||
vec2 normal = vec2(turnDir * hypotenuse.y * direction, -turnDir * hypotenuse.x * direction);
|
||||
float length = sqrt(v_halfWidth * v_halfWidth * 2.0);
|
||||
offset = normal * length;
|
||||
if (isRound) {
|
||||
round = 1.0;
|
||||
}
|
||||
}
|
||||
|
||||
void main(void) {
|
||||
bool degenerate = false;
|
||||
float direction = float(sign(a_direction));
|
||||
float miterLimit = u_miterLimit + u_lineWidth;
|
||||
mat4 offsetMatrix = u_offsetScaleMatrix * u_offsetRotateMatrix;
|
||||
vec2 offset;
|
||||
vec4 projPos = u_projectionMatrix * vec4(a_position, 0., 1.);
|
||||
vec4 projPos = u_projectionMatrix * vec4(a_position, 0.0, 1.0);
|
||||
bool round = nearlyEquals(mod(a_direction, 2.0), 0.0);
|
||||
|
||||
v_round = 0.0;
|
||||
v_halfWidth = u_lineWidth / 2.0;
|
||||
v_roundVertex = projPos.xy;
|
||||
|
||||
if (mod(a_direction, 3.0) == 0.0 || mod(a_direction, 17.0) == 0.0) {
|
||||
vec2 dirVect = a_nextPos - a_position;
|
||||
vec2 normal = normalize(vec2(-dirVect.y, dirVect.x));
|
||||
offset = v_halfWidth * normal * direction;
|
||||
} else if (mod(a_direction, 5.0) == 0.0 || mod(a_direction, 13.0) == 0.0) {
|
||||
vec2 dirVect = a_lastPos - a_position;
|
||||
vec2 normal = normalize(vec2(dirVect.y, -dirVect.x));
|
||||
offset = v_halfWidth * normal * direction;
|
||||
} else if (mod(a_direction, 19.0) == 0.0 || mod(a_direction, 23.0) == 0.0) {
|
||||
vec2 dirVect = a_nextPos - a_position;
|
||||
vec2 tmpNormal = normalize(vec2(-dirVect.y, dirVect.x));
|
||||
vec2 tangent = normalize(normalize(a_nextPos - a_position) + normalize(a_position - a_lastPos));
|
||||
vec2 normal = vec2(-tangent.y, tangent.x);
|
||||
float miterLength = abs(v_halfWidth / dot(normal, tmpNormal));
|
||||
if (mod(a_direction, 23.0) == 0.0) {
|
||||
offset = normal * direction * miterLength;
|
||||
if (mod(a_direction, 2.0) == 0.0) {
|
||||
v_round = 1.0;
|
||||
} else if (miterLength > miterLimit) {
|
||||
offset = tmpNormal * direction * v_halfWidth;
|
||||
}
|
||||
} else {
|
||||
dirVect = a_lastPos - a_position;
|
||||
vec2 longOffset, shortOffset, longVertex;
|
||||
vec4 shortProjVertex;
|
||||
if (length(a_nextPos - a_position) > length(a_lastPos - a_position)) {
|
||||
longOffset = tmpNormal * direction * v_halfWidth;
|
||||
shortOffset = normalize(vec2(dirVect.y, -dirVect.x)) * direction * v_halfWidth;
|
||||
longVertex = a_nextPos;
|
||||
shortProjVertex = u_projectionMatrix * vec4(a_lastPos, 0., 1.);
|
||||
} else {
|
||||
shortOffset = tmpNormal * direction * v_halfWidth;
|
||||
longOffset = normalize(vec2(dirVect.y, -dirVect.x)) * direction * v_halfWidth;
|
||||
longVertex = a_lastPos;
|
||||
shortProjVertex = u_projectionMatrix * vec4(a_nextPos, 0., 1.);
|
||||
}
|
||||
//Intersection algorithm based on theory by Paul Bourke (http://paulbourke.net/geometry/pointlineplane/).
|
||||
vec4 p1 = u_projectionMatrix * vec4(longVertex, 0., 1.) + offsetMatrix * vec4(longOffset, 0., 0.);
|
||||
vec4 p2 = projPos + offsetMatrix * vec4(longOffset, 0., 0.);
|
||||
vec4 p3 = shortProjVertex + offsetMatrix * vec4(-shortOffset, 0., 0.);
|
||||
vec4 p4 = shortProjVertex + offsetMatrix * vec4(shortOffset, 0., 0.);
|
||||
float denom = (p4.y - p3.y) * (p2.x - p1.x) - (p4.x - p3.x) * (p2.y - p1.y);
|
||||
float epsilon = 0.000000000001;
|
||||
float firstU = ((p4.x - p3.x) * (p1.y - p3.y) - (p4.y - p3.y) * (p1.x - p3.x)) / denom;
|
||||
float secondU = ((p2.x - p1.x) * (p1.y - p3.y) - (p2.y - p1.y) * (p1.x - p3.x)) / denom;
|
||||
if (firstU > epsilon && firstU < 1.0 - epsilon && secondU > epsilon && secondU < 1.0 - epsilon) {
|
||||
gl_Position = shortProjVertex;
|
||||
gl_Position.x = p1.x + firstU * (p2.x - p1.x);
|
||||
gl_Position.y = p1.y + firstU * (p2.y - p1.y);
|
||||
degenerate = true;
|
||||
} else {
|
||||
offset = normal * direction * miterLength;
|
||||
}
|
||||
}
|
||||
} else if (mod(a_direction, 7.0) == 0.0 || mod(a_direction, 11.0) == 0.0) {
|
||||
vec2 normal;
|
||||
if (mod(a_direction, 7.0) == 0.0) {
|
||||
vec2 dirVect = a_position - a_nextPos;
|
||||
vec2 firstNormal = normalize(dirVect);
|
||||
vec2 secondNormal = vec2(firstNormal.y * direction, -firstNormal.x * direction);
|
||||
vec2 hypotenuse = normalize(firstNormal - secondNormal);
|
||||
normal = vec2(hypotenuse.y * direction, -hypotenuse.x * direction);
|
||||
} else {
|
||||
vec2 dirVect = a_position - a_lastPos;
|
||||
vec2 firstNormal = normalize(dirVect);
|
||||
vec2 secondNormal = vec2(-firstNormal.y * direction, firstNormal.x * direction);
|
||||
vec2 hypotenuse = normalize(firstNormal - secondNormal);
|
||||
normal = vec2(-hypotenuse.y * direction, hypotenuse.x * direction);
|
||||
}
|
||||
float length = sqrt(v_halfWidth * v_halfWidth * 2.0);
|
||||
offset = normal * length;
|
||||
if (mod(a_direction, 2.0) == 0.0) {
|
||||
v_round = 1.0;
|
||||
}
|
||||
if (nearlyEquals(mod(a_direction, 3.0), 0.0) || nearlyEquals(mod(a_direction, 17.0), 0.0)) {
|
||||
alongNormal(offset, a_nextPos, 1.0, direction);
|
||||
} else if (nearlyEquals(mod(a_direction, 5.0), 0.0) || nearlyEquals(mod(a_direction, 13.0), 0.0)) {
|
||||
alongNormal(offset, a_lastPos, -1.0, direction);
|
||||
} else if (nearlyEquals(mod(a_direction, 23.0), 0.0)) {
|
||||
miterUp(offset, v_round, round, direction);
|
||||
} else if (nearlyEquals(mod(a_direction, 19.0), 0.0)) {
|
||||
degenerate = miterDown(offset, projPos, offsetMatrix, direction);
|
||||
} else if (nearlyEquals(mod(a_direction, 7.0), 0.0)) {
|
||||
squareCap(offset, v_round, round, a_nextPos, 1.0, direction);
|
||||
} else if (nearlyEquals(mod(a_direction, 11.0), 0.0)) {
|
||||
squareCap(offset, v_round, round, a_lastPos, -1.0, direction);
|
||||
}
|
||||
if (!degenerate) {
|
||||
vec4 offsets = offsetMatrix * vec4(offset, 0., 0.);
|
||||
vec4 offsets = offsetMatrix * vec4(offset, 0.0, 0.0);
|
||||
gl_Position = projPos + offsets;
|
||||
} else {
|
||||
gl_Position = vec4(offset, 0.0, 1.0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -13,7 +13,7 @@ uniform mat4 u_offsetScaleMatrix;
|
||||
uniform mat4 u_offsetRotateMatrix;
|
||||
|
||||
void main(void) {
|
||||
gl_Position = u_projectionMatrix * vec4(a_position, 0., 1.);
|
||||
gl_Position = u_projectionMatrix * vec4(a_position, 0.0, 1.0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -58,14 +58,14 @@ ol.inherits(ol.render.webgl.polygonreplay.defaultshader.Vertex, ol.webgl.Vertex)
|
||||
* @const
|
||||
* @type {string}
|
||||
*/
|
||||
ol.render.webgl.polygonreplay.defaultshader.Vertex.DEBUG_SOURCE = '\n\nattribute vec2 a_position;\n\nuniform mat4 u_projectionMatrix;\nuniform mat4 u_offsetScaleMatrix;\nuniform mat4 u_offsetRotateMatrix;\n\nvoid main(void) {\n gl_Position = u_projectionMatrix * vec4(a_position, 0., 1.);\n}\n\n\n';
|
||||
ol.render.webgl.polygonreplay.defaultshader.Vertex.DEBUG_SOURCE = '\n\nattribute vec2 a_position;\n\nuniform mat4 u_projectionMatrix;\nuniform mat4 u_offsetScaleMatrix;\nuniform mat4 u_offsetRotateMatrix;\n\nvoid main(void) {\n gl_Position = u_projectionMatrix * vec4(a_position, 0.0, 1.0);\n}\n\n\n';
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {string}
|
||||
*/
|
||||
ol.render.webgl.polygonreplay.defaultshader.Vertex.OPTIMIZED_SOURCE = 'attribute vec2 a;uniform mat4 b;uniform mat4 c;uniform mat4 d;void main(void){gl_Position=b*vec4(a,0.,1.);}';
|
||||
ol.render.webgl.polygonreplay.defaultshader.Vertex.OPTIMIZED_SOURCE = 'attribute vec2 a;uniform mat4 b;uniform mat4 c;uniform mat4 d;void main(void){gl_Position=b*vec4(a,0.0,1.0);}';
|
||||
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user