-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Prototype pixel snapping icons with GL_LINEAR #8738
Conversation
src/shaders/symbol_icon.vertex.glsl
Outdated
vec2 result = fract(value); | ||
if (result.x > 0.5) result.x -= 1.0; | ||
if (result.y > 0.5) result.y -= 1.0; | ||
return result; |
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.
Shorter way to write it return fract(value) - vec2(greaterThan(value, vec2(0.5)));
. Shouldn't matter, though.
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.
I can try, but many OpenGL implementations I tested are very picky about subtle changes like this and perform rounding differently.
src/shaders/symbol_icon.vertex.glsl
Outdated
v_tex = a_tex / u_texsize; | ||
v_tex = a_tex; | ||
if (u_crisp && (segment_angle + symbol_rotation == 0.0)) { | ||
// move texture loopup to snap to the pixel grid |
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.
loopup/lookup
src/shaders/symbol_icon.vertex.glsl
Outdated
// move texture loopup to snap to the pixel grid | ||
vec4 icon_pos = u_coord_matrix * vec4(projected_pos.xy / projected_pos.w, 0.0, 1.0); | ||
v_tex += absfract((icon_pos.xy + 1.0) * u_canvas_size * vec2(1.0, -1.0) / 2.0); | ||
v_tex += fract(a_offset / 32.0 * fontScale * u_device_pixel_ratio); |
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.
Is there a need to multiply this by u_coord_matrix before fract, as it is in gl_Position calculation?
d65b1c4
to
8b30b46
Compare
Is this going to be fixed in release-c? Really looking for seing this fixed :) Thanks. |
Closing this as stale |
Implements #8730.
We're currently switching between pixel-grid aligned icons in a binary way. In a follow-up patch, we could implement a gradual switch by making
u_crisp
a float, and scaling it between 0 and 1 whenever the user interacts with the map.