Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Transparency and depth issues when displaying a mesh and a volume #5290

@touste

Description

@touste

I'm trying to display a mesh together with a volume, see the following MWE.

I cannot make the two display correctly together (here the sphere ends up either behind or in front of the volume, but not half inside and half outside as it should be). It's hard to see on the pictures, but try the MWE and rotate the figure to see what I mean.

using GLMakie
using NIfTI

# From the example given in the mesh docs
brain = niread(Makie.assetpath("brain.nii.gz")).raw
mini, maxi = extrema(brain)
normed = Float32.((brain .- mini) ./ (maxi - mini))

fig = Figure(size=(1000, 450))
ax = Axis3(fig[1, 1])

# Make a colormap, with the first value being transparent
colormap = to_colormap(:plasma)
colormap[1] = RGBAf(0, 0, 0, 0)
volume!(ax, normed, algorithm=:absorption, absorption=4f0, colormap=colormap)

# Add a sphere (make it half inside, half outside the brain)
s = Sphere(Point3f(100, 100, 100), 100f0)

mesh!(ax, s)
wireframe!(ax, s)

fig

I guess it's due to the absorption algorithm that does not take the mesh into account. I tried playing with various options such as transparency or depth shift to no avail. Is this the expected behaviour? If so, is there a way to achieve this kind of visualization?

Image Image

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions