Poor Mesh Plot from Makie - How to fix it?

Minimal example with a dummy mesh

using Makie, GLMakie, FileIO

msh = load("~/TestMesh.stl")


fig = Figure(resolution = (1920,1080))

axe = Axis3(fig[1, 1])


mesh!(msh, transparency = false, overdraw = false, shading = true)

wireframe!(msh, color = :red, transparency = true, overdraw = false)


hidedecorations!(axe)

display(fig)

What I get is the following

Here some weird artifacts are visible.


Actually what I want is similar to the generated file with this Matlab-Code

P = stlread('~/TestMesh.stl');

trimesh(P,'EdgeColor','r')

hold on

trisurf(P,'EdgeColor','none','FaceColor','c')

axis off

lightangle(-45,30)

lighting gouraud

Here the geometry is drawn nicely.

So can this style be adapted in Makie?

Is TestMesh.stl available somewhere?

Set color for the mesh plot to something opaque. The default has some transparency

1 Like

That default was only meant for 2d shapes overlapping. We should think about changing it for meshes, in 3D transparency has a couple problems

2 Likes

Just for your interest - here is the file I’m Testing with

Aw, thats’s unfortunate. But big up for your work so far!

With an opaque cyan and black lines it’s much closer to your matlab example, although the default light doesn’t come from the front anymore:

mesh!(msh, transparency = false, overdraw = false, color = :cyan)

wireframe!(msh, color = :black, linewidth = 0.5)

hidedecorations!(axe)

fig

And if the directional light comes from the front it looks even closer:

fig = Figure()

axe = Axis3(fig[1, 1])
axe.scene.lights[2].direction[] = Vec3f(0, 0, -1)

mesh!(msh, transparency = false, overdraw = false, color = :cyan)

wireframe!(msh, color = :black, linewidth = 0.5)

hidedecorations!(axe)

fig

2 Likes

It seems that Matlab’s mesh lines are much sharper, though.

1 Like

with fxaa = true on the wireframe it seems a bit better, but I still sometimes think our problem is that we draw the lines in a separate pass than the mesh. I assume matlab does it in one go

2 Likes

awesome, this is still looking really nice and is exactly what I want! Thx