Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WGLMakie performance bug with Volume #1454

Open
SimonDanisch opened this issue Nov 17, 2021 · 0 comments
Open

WGLMakie performance bug with Volume #1454

SimonDanisch opened this issue Nov 17, 2021 · 0 comments
Assignees
Labels
WGLMakie This relates to WGLMakie.jl, the Web-based WebGL backend for Makie.

Comments

@SimonDanisch
Copy link
Member

Somehow, this WGLMakie example makes everything stutter like crazy, even on a fast PC:

using WGLMakie, FileIO, NIfTI, ImageTransformations
WGLMakie.activate!()

brain = restrict(niread(Makie.assetpath("brain.nii.gz")).raw)
mini, maxi = extrema(brain)
cube_with_holes = Float32.((brain .- mini) ./ (maxi - mini))

function labeled_slider(r, name, start=first(r))
    s = JSServe.Slider(r)
    s.value[] = start
    return DOM.div(name, s, map(x-> string(round(x, digits=2)), s.value)), s
end

App() do session
    levelsd, levels = labeled_slider(2:10, "levels")
    absorptiond, absorption = labeled_slider(range(0, stop=5, step=0.5), "absorption", 3.0)
    isovalued, isovalue = labeled_slider(range(0, stop=1, step=0.1), "isovalue", 0.5)
    alphad, alpha = labeled_slider(range(0, stop=1, step=0.1), "alpha", 0.5)

    fig = Figure(resolution=(800, 800))
    # Make a colormap, with the first value being transparent
    colormap = RGBAf.(to_colormap(:plasma), 1.0)
    colormap[1] = RGBAf(0,0,0,0)

    volume!(LScene(fig[1, 2], show_axis=false), cube_with_holes, algorithm = :absorption, absorption=absorption, colormap=colormap)
    volume!(LScene(fig[1, 2], show_axis=false), cube_with_holes, algorithm = :mip, colormap=colormap)

    colgap!(fig.layout, 0)
    rowgap!(fig.layout, 0)

    return JSServe.record_states(session, DOM.div(absorptiond, isovalued, levelsd, alphad, fig))
end
@SimonDanisch SimonDanisch added the WGLMakie This relates to WGLMakie.jl, the Web-based WebGL backend for Makie. label Nov 17, 2021
@SimonDanisch SimonDanisch self-assigned this Nov 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
WGLMakie This relates to WGLMakie.jl, the Web-based WebGL backend for Makie.
Projects
Status: No status
Development

No branches or pull requests

1 participant