get point shader to work on ios
This commit is contained in:
@@ -17,6 +17,7 @@ public:
|
||||
int32_t u_world;
|
||||
int32_t u_linewidth;
|
||||
int32_t u_color;
|
||||
int32_t u_size;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -311,7 +311,13 @@ void Painter::renderLine(LineBucket& bucket, const std::string& layer_name, cons
|
||||
glUniform4fv(linejoinShader->u_color, 1, color.data());
|
||||
glUniform2f(linejoinShader->u_world, transform.fb_width / 2, transform.fb_height / 2);
|
||||
glUniform2f(linejoinShader->u_linewidth, (outset - 0.25) * transform.pixelRatio, (inset - 0.25) * transform.pixelRatio);
|
||||
|
||||
#if defined(GL_ES_VERSION_2_0)
|
||||
glUniform1f(linejoinShader->u_size, ceil(transform.pixelRatio * outset * 2.0));
|
||||
#else
|
||||
glPointSize(ceil(transform.pixelRatio * outset * 2.0));
|
||||
#endif
|
||||
|
||||
bucket.drawPoints(*linejoinShader);
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ LinejoinShader::LinejoinShader()
|
||||
u_world = glGetUniformLocation(program, "u_world");
|
||||
u_linewidth = glGetUniformLocation(program, "u_linewidth");
|
||||
u_color = glGetUniformLocation(program, "u_color");
|
||||
u_size = glGetUniformLocation(program, "u_size");
|
||||
}
|
||||
|
||||
void LinejoinShader::bind(char *offset) {
|
||||
|
||||
@@ -2,11 +2,12 @@ attribute vec2 a_pos;
|
||||
|
||||
uniform mat4 u_matrix;
|
||||
uniform vec2 u_world;
|
||||
uniform float u_size;
|
||||
|
||||
varying vec2 v_pos;
|
||||
|
||||
void main() {
|
||||
gl_Position = u_matrix * vec4(floor(a_pos / 2.0), 0.0, 1.0);
|
||||
v_pos = (gl_Position.xy + 1.0) * u_world;
|
||||
gl_PointSize = u_linewidth.s * 2.0;
|
||||
gl_PointSize = u_size;
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ const shader_source llmr::shaders[SHADER_COUNT] = {
|
||||
"uniform float u_debug;\nuniform vec2 u_linewidth;\nuniform vec4 u_color;\n\nuniform vec2 u_dasharray;\n\nvarying vec2 v_normal;\nvarying float v_linesofar;\n\nvoid main() {\n // Calculate the distance of the pixel from the line in pixels.\n float dist = length(v_normal) * u_linewidth.s;\n\n // Calculate the antialiasing fade factor. This is either when fading in\n // the line in case of an offset line (v_linewidth.t) or when fading out\n // (v_linewidth.s)\n float alpha = clamp(min(dist - (u_linewidth.t - 1.0), u_linewidth.s - dist), 0.0, 1.0);\n\n // Calculate the antialiasing fade factor based on distance to the dash.\n // Only affects alpha when line is dashed\n float pos = mod(v_linesofar, u_dasharray.x + u_dasharray.y);\n alpha *= max(step(0.0, -u_dasharray.y), clamp(min(pos, u_dasharray.x - pos), 0.0, 1.0));\n\n if (u_debug > 0.0) {\n gl_FragColor = u_color;\n } else {\n gl_FragColor = u_color * alpha;\n }\n}",
|
||||
},
|
||||
{
|
||||
"attribute vec2 a_pos;\n\nuniform mat4 u_matrix;\nuniform vec2 u_world;\n\nvarying vec2 v_pos;\n\nvoid main() {\n gl_Position = u_matrix * vec4(floor(a_pos / 2.0), 0.0, 1.0);\n v_pos = (gl_Position.xy + 1.0) * u_world;\n}\n",
|
||||
"attribute vec2 a_pos;\n\nuniform mat4 u_matrix;\nuniform vec2 u_world;\nuniform float u_size;\n\nvarying vec2 v_pos;\n\nvoid main() {\n gl_Position = u_matrix * vec4(floor(a_pos / 2.0), 0.0, 1.0);\n v_pos = (gl_Position.xy + 1.0) * u_world;\n gl_PointSize = u_size;\n}\n",
|
||||
"uniform vec4 u_color;\nuniform vec2 u_linewidth;\n\nvarying vec2 v_pos;\n\nvoid main() {\n float dist = length(v_pos - gl_FragCoord.xy);\n\n // Calculate the antialiasing fade factor. This is either when fading in\n // the line in case of an offset line (v_linewidth.t) or when fading out\n // (v_linewidth.s)\n float alpha = clamp(min(dist - (u_linewidth.t - 1.0), u_linewidth.s - dist), 0.0, 1.0);\n gl_FragColor = u_color * alpha;\n}\n",
|
||||
},
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user