Scatter plot points visable even if behind a mesh plot

Hi everyone,

I’m encountering different transparency behavior between CairoMakie and GLMakie when combining scatter plots with mesh plots.

Expected behavior: scatter plot points behind a mesh should be hidden (like in GLMakie).

Observed behavior: in CairoMakie, the points behind the mesh remain fully visible.

Is there a way to get the expected behavior though CairoMakie? I need to make the plots on a cluster in which GLMakie is not available.

Example:

using CairoMakie, FileIO, GeometryBasics 
# switch to GLMakie for expected outcome 

mesh = load(assetpath("brain.stl"))  
v = coordinates(mesh)
f = faces(mesh) 

pltrand = v[rand(eachindex(v), 10)]

fig = Figure();
ax = Axis3(fig[1, 1], aspect=:data)

mesh!(ax, v, f, color=:lightblue)
scatter!(ax, pltrand, color=:red)

fig

CairoMakie has no z buffer, like all 2D drawing engines it just layers things on top of each other, one at a time. Sometimes this works for 3D content, sometimes not. You could try WGLMakie if GLMakie doesn’t work, or look into software emulation of a graphics card like xvfb which we also use in Github Actions.