-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[wip] Circles support #1241
[wip] Circles support #1241
Conversation
Basic support to allow circle in v8 styles. Both the circle_bucket and draw_circle need to be implemented. This stub will not draw circles, but is sufficient to keep from failing when it encounters a circle in a stylesheet.
I'm grabbing this branch and working on it today/tomorrow |
CIRCLES! This branch is ready for review: it draws circles of various colors, with blurring. I assume we'll merge this into the v8 branch if it passes muster? |
|
||
void main(void) { | ||
v_extrude = a_extrude; | ||
vec4 extrude = u_exmatrix * vec4(a_extrude * u_size / 2.0 * sqrt(2.0), 0, 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you switch from a rotated square to an axis aligned square with vertices ((-1, -1), (1, -1), (1, 1), (-1, 1)) you should be able to remove the sqrt(2.0) here
We can reduce the size of circle vertex buffers by half if we pack the position and extrude together into 4 bytes. If we switch to a square, there will be only two possible extrude component values: -1 and 1. Each component of the extrude only needs a single byte. Each position component has 16 bytes but doesn't need all of them. The x position and x extrude could be combined into a single short with something like this: They would need to be unpacked in the vertex shader. We do something similar for lines: buffer, vertex shader. |
Remaining issue
|
👀 |
The circle needs to be antialiased. Something needs to be added here so that 1px is always blurred. Also, what are the units for |
// unencode the extrusion vector that we snuck into the a_pos vector | ||
v_extrude = vec2( | ||
mod(a_pos.x, 2.0) * 2.0 - 1.0, | ||
mod(a_pos.y, 2.0) * 2.0 - 1.0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most glsl operations can work with vectors, so this can be written as v_extrude = vec2(mod(a_pos, 2.0) * 2.0 - 1.0);
Done
It's relative to the radius of the circle... blur: 1 is "fully blurred" afaik, where the gradient from center to outside is linear |
@ansis @jfirebaugh - I've added anti-aliasing and expanded the documentation of the blur parameter in the v8 style spec. Anything else remaining? |
|
I think we should not pick one: relative blur makes sense for circles and their use cases, and line-blur as pixels makes sense for lines. Let's keep this as-is. |
Yes! looks good |
This is a manual redo of #1241 on top of the v8 branch.
Merged in 59c7af4 |
\o/ |
1 similar comment
\o/ |
This is a manual redo of #1241 on top of the v8 branch.
This is a manual redo of #1241 on top of the v8 branch.
Basic support to allow circle in v8 styles. Both the circle_bucket and
draw_circle need to be implemented.
This stub will not draw circles, but is sufficient to keep from failing
when it encounters a circle in a stylesheet.
The maximum size of a circle appears to be 64 https://developer.apple.com/opengl/capabilities/
With that limitation, we'll need to use triangles