-
Notifications
You must be signed in to change notification settings - Fork 91
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
LineTexBucket: fix out of short range (#220, #529) #532
Conversation
I rethought my implementation and found a solution which works without additional |
// use linelength mod texture step (mod is always positiv) | ||
vec4 c = texture2D(tex, vec2(mod(v_st.s, step), (v_st.t + 1.0) * 0.5)); | ||
float fuzz = fwidth(c.a); | ||
gl_FragColor = (c * u_color) * smoothstep(0.5 - fuzz, 0.5 + fuzz, c.a); |
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.
Quick comment: please let's keep any formatting changes separately in own PR.
It's important to be able to review now and in the future any core changes easily.
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.
You mean the spaces I added?
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.
Yeah, any improvements in format, refactor, names, comments can perfectly exist separately.
In the future (and now) when we come back to search for a commit's changes, it's very important to see the commit's changes for its specific purpose and only them, not searching in many diffs where exactly is the actual code that changed map rendering.
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.
Agreed. I'm a bit lazy in such matters.
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.
A few comments I added were needed to understand what's going on. Next time I'll try to add the not affected ones separately.
I'll add formatting PR when this is merged.
# Conflicts: # vtm/resources/assets/shaders/linetex_layer_tex.glsl
Don't like the result inside maps where the functionality is more important than overlays. |
I merged the PR in branch issue_532 rebased on |
float step = 2.0; | ||
if (u_mode == 2.0) { // dashed texture | ||
step = 1.0; | ||
} | ||
vec4 c = texture2D(tex, vec2(abs(mod(v_st.s + 1.0, step)), (v_st.t + 1.0) * 0.5)); | ||
// use linelength mod texture step (mod is always positiv) | ||
vec4 c = texture2D(tex, vec2(mod(v_st.s, step), (v_st.t + 1.0) * 0.5)); |
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.
Why the remove of the "+ 1.0" in mod?
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.
The better question is, why there was a "+ 1.0" ?
v_st.s
is the interpolated lineLength
value between two vertices, which is divided with u_pscale
.
Theoretically v_st.s
can have a range from -∞
to +∞
. So it makes no sense to add 1 as it is taken modulo anyway and then has (dependent on dash flag) a range from 0
to 1
or 2
.
The only reason could be that texture is shifted so it looks better at the beginning, but I didn't noticed any better look. If leaving + 1.0
we should comment that it has no further meaning.
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.
Seems the answer is found in #536. 🙂
Valid objection: The reason is that we now start to count |
I tried that before above comment and the result is a bit strange. |
BTW there is not anything about "objections" here, just that each and every change needs extensive testing in all library uses so that not break any existing functionality. |
I'm not a native speaker as you can see 😜 |
The PR concept is certainly nice and seems to solve the "reverse" issue and probably others. So here since the map textures didn't seem to have issues (?) because of native tiling, we need to not affect them with that change that seems more relevant to overlays. |
This is the reason of
It could have, if
It wouldn't be affected, if reverting |
See #536 |
Very nice, with #536 the regression inside map textures seems fixed! |
Thanks, all seem working now! |
@devemux86: Thank you for reviewing and bring out the bugs! |
That's the magic of open source projects: users cooperation. 🙂 |
As I mentioned in #220 the lineLength often was out of
Short
range.So shapes weren't displayed correctly or reversed.
I added adistance
value to shader, which now replaces the position calculations of texture.lineLength
is further needed to avoid minor artifacts at vertices.In rarely special cases the
distance
could have a value greater than theShort
s range as it's an euclidean distance out of twoShort
values. So I added a workaround to split line in those cases.Works fine with #529, too.