Overlapping 3d lines in glmakie not drawing as expected

using GLMakie

GLMakie.activate!()

function mwe_segments(step_size)
    fig = Figure()
    ax = Axis3(fig[1,1],viewmode = :fit, aspect = (1.0,1.0,1.0))
   
    for y in -10:step_size:10
        lines!(ax,[SVector(0.0,y,0.0),SVector(10.0,y,0.0)], color = "black")
    end
    display(fig)
end

set step_size to one and you get a set of nicely spaced black lines.

Set step_size to .1 and you get this:

Set step_size to .01 and you get this:

As the lines overlap more and more I would expect to see an area of solid black. But instead this area is now almost white. It’s opaque as well; objects behind the lines won’t show through. This looks like an anitaliasing problem, or perhaps a zbuffer precision problem.

I tried setting fxaa both true and false but it doesn’t make a difference. Is there a way to fix this?

Try transparency=true … It may give you other artifacts, but that makes the aa “border” truly transparent, while with transparency=false it will be opaque to lines behind it.
Also, really use linesegments!… lines! is incredibly slow for many separate 2 point lines.

function mwe_segments(step_size)
    fig = Figure()
    ax = Axis3(fig[1,1],viewmode = :fit, aspect = (1.0,1.0,1.0))
    segments = Point3f[]
    for y in -10:step_size:10
        append!(segments, [Point3f(0.0,y,0.0),Point3f(10.0,y,0.0)])
    end
    linesegments!(ax, segments, color = "black", transparency=true)
    display(fig)
end
1 Like

Thanks, that looks much better.