-
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
Some dashed lines render crooked #967
Comments
@ansis How are you interpolating the texture coords in the line triangles? |
Yeah, this has been around for a while. I don't think this would have gotten worse with the recent dash work because the part that causes the problem hasn't changed. @nickidlugash the best workaround is to use The tessellated line looks something like this: A fragment's position in the dash pattern is calculated using the fragment's distance along the line. It would be nice to default to |
@ansis you sure you can't correct the skew in the shader? If you know the y texture coord, then you might be able to adjust x to account for the different lengths. |
@ljbade you would need to skew in different directions based on which side of the corner you are on. If the vertex is shared between triangles on both sides you can't do this. So you'd have to use separate vertices, which might be ok, but it would double the number of vertices. |
Ah I see. |
Hey @ansis, I'm just really trying to understand this issue in more detail. If we tessellate the lines like this, we can still make tristrips out of them and we can know each fragment's position along the line because vertices exist along the centerline in each grouping of 4 triangles. It does increase the # of vertices, but tristrips are fast. Would this fix the issue? |
@bhousel I don't think that would, because the extra middle vertex wouldn't help you know the "real" distance along the line at the corners. The value at the middle of the line is already correct |
Do you think there is a way we could solve the problem by adding an additional attribute to each vertex? |
On top of adding another attribute (or finding a way to pack it into existing attributes) we'd have to add more vertices. The corner vertices are shared between segments, but if the slant is fixed the corner vertices need to be separate because the need to set different "distance along the line" varying values. This would fix the slant but would create potential artifacts at corners since the "distance along the line" would only be continuous in the middle of the line. It's hard to explain with words. I should try drawing it out It's hard to make dashed lines look nice at corners even conceptually. |
I'm not sure exactly what the issue is, but some dashed lines that have sharp angles in the geometry look like this (click image for larger view):
This style looks fine for straight lines:
Here's the written style:
This issue existed before the big line-dash refactor, but it seems a bit worse now. @ansis Any ideas?
The text was updated successfully, but these errors were encountered: