Skip to content
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

Fix lines #2843

Merged
merged 9 commits into from Apr 25, 2023
Merged

Fix lines #2843

merged 9 commits into from Apr 25, 2023

Conversation

ffreyer
Copy link
Collaborator

@ffreyer ffreyer commented Apr 5, 2023

Description

Fixes #2842. The issue is what I wrote in the issue - due to extending the linesegments with AA borders without adjusting the depth values of the those translated vertices, the depth values become slightly off across the line. This then causes the line to dip behind the mesh in the issue. To fix this we just need to consider depth for adjustments along the line directions.

Fixes #2826 which is a result of the fix for #1129. See below.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Checklist

  • Added an entry in NEWS.md (for new features and breaking changes)
  • Added or changed relevant sections in the documentation
  • Added unit tests for new algorithms, conversion methods, etc.
  • Added reference image tests for new plotting functions, recipes, visual options, etc.

@MakieBot
Copy link
Collaborator

MakieBot commented Apr 5, 2023

Compile Times benchmark

Note, that these numbers may fluctuate on the CI servers, so take them with a grain of salt. All benchmark results are based on the mean time and negative percent mean faster than the base branch. Note, that GLMakie + WGLMakie run on an emulated GPU, so the runtime benchmark is much slower. Results are from running:

using_time = @ctime using Backend
# Compile time
create_time = @ctime fig = scatter(1:4; color=1:4, colormap=:turbo, markersize=20, visible=true)
display_time = @ctime Makie.colorbuffer(display(fig))
# Runtime
create_time = @benchmark fig = scatter(1:4; color=1:4, colormap=:turbo, markersize=20, visible=true)
display_time = @benchmark Makie.colorbuffer(display(fig))
using create display create display
GLMakie 44.01s (43.58, 44.74) 0.43+- 20.97s (20.56, 21.31) 0.22+- 19.41s (18.73, 20.29) 0.48+- 13.02ms (12.78, 13.47) 0.27+- 163.43ms (160.50, 165.42) 1.76+-
master 43.95s (43.32, 44.30) 0.35+- 20.84s (20.60, 20.97) 0.12+- 19.26s (18.92, 19.83) 0.31+- 12.90ms (12.69, 13.24) 0.19+- 164.17ms (159.74, 167.41) 2.92+-
evaluation +0.13%, 0.06s invariant (0.14d, 0.79p, 0.39std) +0.64%, 0.13s invariant (0.74d, 0.20p, 0.17std) +0.74%, 0.14s invariant (0.36d, 0.52p, 0.40std) +0.91%, 0.12ms invariant (0.51d, 0.36p, 0.23std) -0.46%, -0.75ms invariant (-0.31d, 0.57p, 2.34std)
CairoMakie 39.75s (39.61, 39.94) 0.13+- 20.61s (20.45, 20.78) 0.12+- 2.97s (2.94, 3.00) 0.02+- 14.67ms (14.36, 14.88) 0.16+- 5.89ms (5.73, 6.37) 0.22+-
master 39.73s (39.46, 39.97) 0.19+- 20.63s (20.45, 20.81) 0.13+- 2.99s (2.95, 3.08) 0.05+- 14.71ms (14.45, 14.92) 0.16+- 6.15ms (6.04, 6.38) 0.11+-
evaluation +0.05%, 0.02s invariant (0.11d, 0.84p, 0.16std) -0.11%, -0.02s invariant (-0.18d, 0.75p, 0.13std) -0.70%, -0.02s invariant (-0.57d, 0.32p, 0.03std) -0.22%, -0.03ms invariant (-0.20d, 0.71p, 0.16std) -4.36%, -0.26ms faster ✓ (-1.44d, 0.02p, 0.17std)
WGLMakie 46.79s (46.34, 47.20) 0.31+- 23.65s (23.25, 24.14) 0.35+- 24.20s (23.57, 24.58) 0.35+- 17.72ms (16.23, 19.60) 1.08+- 866.85ms (843.64, 884.60) 17.15+-
master 46.92s (46.33, 47.54) 0.41+- 23.69s (22.89, 24.40) 0.48+- 24.01s (22.76, 25.50) 0.90+- 17.56ms (15.87, 18.92) 1.03+- 854.87ms (784.42, 898.79) 37.33+-
evaluation -0.30%, -0.14s invariant (-0.38d, 0.49p, 0.36std) -0.16%, -0.04s invariant (-0.09d, 0.87p, 0.42std) +0.78%, 0.19s invariant (0.27d, 0.62p, 0.62std) +0.89%, 0.16ms invariant (0.15d, 0.78p, 1.05std) +1.38%, 11.98ms invariant (0.41d, 0.46p, 27.24std)

@ffreyer ffreyer marked this pull request as draft April 8, 2023 13:44
@ffreyer ffreyer changed the title Ff/fix lines Fix lines Apr 8, 2023
@ffreyer
Copy link
Collaborator Author

ffreyer commented Apr 8, 2023

I'm also trying to fix #2826 and #1129 here (or at least not make it worse again) but I keep finding issues with my solutions. The last I tried was adjusting the number vertices/triangles used in the line segment.

Screenshot from 2023-04-09 01-32-11

This helps with overdraw somewhat, but when the inner triangle inverts you get some overdraw at each corner:

Screenshot from 2023-04-09 01-32-24

The fix for #2842 should be fine as is.

@ffreyer
Copy link
Collaborator Author

ffreyer commented Apr 12, 2023

I pushed the above now. It's decent enough for reducing overdraw I think, and I don't think I can come up with a better solution atm. So maybe we just take this as is for now?

Full scale of #1129:
Screenshot from 2023-04-12 15-42-17

Detail of #1129:
Screenshot from 2023-04-12 15-43-01

Full scale of #2826:
Screenshot from 2023-04-12 15-43-50

Detail of #2826:
Screenshot from 2023-04-12 15-44-02

And here:s another chunk of code to simulate line join issues: https://gist.github.com/ffreyer/0875fceb4ba80c6779f5ff14b5f24f2d

@ffreyer ffreyer marked this pull request as ready for review April 12, 2023 14:04
@ffreyer ffreyer marked this pull request as draft April 13, 2023 09:40
@ffreyer
Copy link
Collaborator Author

ffreyer commented Apr 13, 2023

Ok nvm, I think I have a better solution now. I still need to test with patterned lines and shallow corners again though. Once I'm done I'll mark this ready again.

The approach I've switched to now uses 4 vertices/2 triangles in the normal case again, but splits the segment into 2 independent triangles (6 vertices) when it starts drawing over itself. For the triangle at p1 I'm adding p2 as an AA border, and vice versa. That should stop the triangles from drawing outside other triangles.

Screenshot from 2023-04-13 11-39-16
Screenshot from 2023-04-13 11-39-27
Screenshot from 2023-04-13 11-39-35

#1129 now looks like this when overdrawing occurs: (this is a ⨅ corner)
Screenshot from 2023-04-13 11-47-21

#2826 now looks like this:
Screenshot from 2023-04-13 11-35-25
Screenshot from 2023-04-13 11-49-26

@ffreyer
Copy link
Collaborator Author

ffreyer commented Apr 13, 2023

Things get a bit fuzzy when points get super dense, but I think that's fine. (Starts at around 2^18 ~ 260k points)

Screenshot from 2023-04-13 17-50-44
Screenshot from 2023-04-13 17-51-25

For fun, this is the before for solid lines (dashed is similarly fuzzy, dot is fine in either. Probably because it doesn't try to bend around corners.)
Screenshot from 2023-04-13 17-54-00

@ffreyer ffreyer marked this pull request as ready for review April 13, 2023 15:56
@ffreyer ffreyer mentioned this pull request Apr 13, 2023
@ffreyer
Copy link
Collaborator Author

ffreyer commented Apr 13, 2023

Closes #2855 as well.

Line start/ends in corners now fill out the corner in GLMakie:

line_ends.mp4

Not sure if that's the best way to handle this, but I think it at least looks cleaner than before. CairoMakie doesn't deal with this well either, but I'm not gonna bother with it here

line_ends_cm.mp4

@SimonDanisch SimonDanisch merged commit 13e1d84 into master Apr 25, 2023
14 checks passed
@SimonDanisch SimonDanisch deleted the ff/fix_lines branch April 25, 2023 12:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants