epezent / implot

Immediate Mode Plotting
MIT License
4.64k stars 516 forks source link

Pixel gaps in line plots #447

Open nuuSolutions opened 1 year ago

nuuSolutions commented 1 year ago

I'm drawing ImPlot::PlotLineG with a width of about 4 here. At each kink there are small gaps like here: Screenshot_20230208_174355 The problem gets worse when points are very close together (and the gaps flicker on moving) here I draw about 1 point per pixel Screenshot_20230208_180143

As I workaround, I added a scatter plot of points over the lines - see the red line in the last picture - looks much better I wonder if something like this could be done in the original PlotLine

I just checked that the same pixels appear when using the original ImGui::PlotLines with width 4.0f hacked in

BenBE commented 1 year ago

Can you have a look at the list of draw commands and check if the graph lines are individual line segments or if this is drawn as line strides (list of line segments)? If this is individual lines the GPU might opt to "terminate" each line and thus cause these "gaps". The effect should be even more pronounced with even higher widths of e.g. 32.

nuuSolutions commented 1 year ago

I'm using out of the box ImPlot::PlotLine or ImGui::PlotLines which calls ImDrawList::AddLine which calls PathLineTo Not sure what more you want me to check