MakieOrg / Makie.jl

Interactive data visualizations and plotting in Julia
https://docs.makie.org/stable
MIT License
2.41k stars 313 forks source link

Unable to pass strokewidth vector into GLMakie for varying outline sizes #4331

Open ericchenanpt opened 2 months ago

ericchenanpt commented 2 months ago
using GLMakie

fig = Figure()
Axis(fig[1,1])
kwargs = (; markersize = 30, strokecolor = :tomato)
scatter!(fig[1, 1], 1:3; kwargs..., strokewidth = 3)
Axis(fig[1,2])
scatter!(fig[1, 2], 1:3; kwargs..., strokewidth = [0,3,6])
fig

Error & Stacktrace ⚠️

┌ Error: Exception while generating log record in module GLMakie.GLAbstraction at C:\Users\eric.chen\.julia\packages\GLMakie\GK1PF\src\GLAbstraction\GLRender.jl:88
│   exception =
│    uniform stroke_width doesn't work with value Observable([0, 3, 6])
│    Stacktrace:
│      [1] error(s::String)
│        @ Base .\error.jl:35
│      [2] macro expansion
│        @ .\logging.jl:372 [inlined]
│      [3] render(renderobject::GLMakie.GLAbstraction.RenderObject{GLMakie.GLAbstraction.StandardPrerender}, vertexarray::GLMakie.GLAbstraction.GLVertexArray{Observable{Int64}})
│        @ GLMakie.GLAbstraction C:\Users\eric.chen\.julia\packages\GLMakie\GK1PF\src\GLAbstraction\GLRender.jl:88
│      [4] render(renderobject::GLMakie.GLAbstraction.RenderObject{GLMakie.GLAbstraction.StandardPrerender})
│        @ GLMakie.GLAbstraction C:\Users\eric.chen\.julia\packages\GLMakie\GK1PF\src\GLAbstraction\GLRender.jl:71
│      [5] render(filter_elem_func::GLMakie.var"#157#161", screen::GLMakie.Screen{GLFW.Window})
│        @ GLMakie C:\Users\eric.chen\.julia\packages\GLMakie\GK1PF\src\rendering.jl:124
│      [6] render_frame(screen::GLMakie.Screen{GLFW.Window}; resize_buffers::Bool)
│        @ GLMakie C:\Users\eric.chen\.julia\packages\GLMakie\GK1PF\src\rendering.jl:72
│      [7] render_frame
│        @ C:\Users\eric.chen\.julia\packages\GLMakie\GK1PF\src\rendering.jl:29 [inlined]
│      [8] on_demand_renderloop(screen::GLMakie.Screen{GLFW.Window})
│        @ GLMakie C:\Users\eric.chen\.julia\packages\GLMakie\GK1PF\src\screen.jl:983
│      [9] renderloop(screen::GLMakie.Screen{GLFW.Window})
│        @ GLMakie C:\Users\eric.chen\.julia\packages\GLMakie\GK1PF\src\screen.jl:1007
│     [10] (::GLMakie.var"#68#69"{GLMakie.Screen{GLFW.Window}})()
│        @ GLMakie C:\Users\eric.chen\.julia\packages\GLMakie\GK1PF\src\screen.jl:867
└ @ GLMakie.GLAbstraction C:\Users\eric.chen\.julia\packages\GLMakie\GK1PF\src\GLAbstraction\GLRender.jl:88

This error also shows up with LScene or Axis3, far as I can find.

Any insight would be helpful! Thank you.

asinghvi17 commented 2 months ago

This works fine in CairoMakie: iTerm2 qxyTaS

but not in the GL backends. On WGLMakie I get

Type Vector{Int32} not supported 
Stacktrace: 
[1] error(s::String) @ Base ./error.jl:35 
[2] type_string(context::WGLMakie.WebGL, t::Type) @ ShaderAbstractions ~/.julia/packages/ShaderAbstractions/20WwW/src/uniforms.jl:142 
[3] type_string(context::WGLMakie.WebGL, x::Vector{Int32}) @ ShaderAbstractions ~/.julia/packages/ShaderAbstractions/20WwW/src/uniforms.jl:114 
[4] type_string(context::WGLMakie.WebGL, t::Observable{Vector{Int32}}) @ ShaderAbstractions ~/.julia/packages/ShaderAbstractions/20WwW/src/uniforms.jl:140 
[5] (::ShaderAbstractions.var"#27#29"{WGLMakie.WebGL, Dict{Symbol, Any}, Dict{Symbol, Any}})(io::IOBuffer) @ ShaderAbstractions ~/.julia/packages/ShaderAbstractions/20WwW/src/program.jl:109 
[6] sprint(::Function; context::Nothing, sizehint::Int64) @ Base ./strings/io.jl:114 
[7] sprint @ ./strings/io.jl:107 [inlined] 
[8] Program @ ~/.julia/packages/ShaderAbstractions/20WwW/src/program.jl:103 [inlined] 
[9] ShaderAbstractions.InstancedProgram(context::WGLMakie.WebGL, vertshader::String, fragshader::String, instance::GeometryBasics.Mesh{2, Float32, GeometryBasics.TriangleP{2, Float32, GeometryBasics.PointWithUV{2, Float32}}, GeometryBasics.FaceView{GeometryBasics.TriangleP{2, Float32, GeometryBasics.PointWithUV{2, Float32}}, GeometryBasics.PointWithUV{2, Float32}, GeometryBasics.NgonFace{3, GeometryBasics.OffsetInteger{-1, UInt32}}, StructArrays.StructVector{GeometryBasics.PointWithUV{2, Float32}, @NamedTuple{position::Vector{Point{2, Float32}}, uv::Vector{Vec{2, Float32}}}, Int64}, Vector{GeometryBasics.NgonFace{3, GeometryBasics.OffsetInteger{-1, UInt32}}}}}, per_instance::ShaderAbstractions.VertexArray{@NamedTuple{pos::Point{2, Float32}}, StructArrays.StructVector{@NamedTuple{pos::Point{2, Float32}}, @NamedTuple{pos::ShaderAbstractions.Buffer{Point{2, Float32}, Vector{Point{2, Float32}}}}, CartesianIndex{1}}}, uniforms::Dict{Symbol, Any}) @ ShaderAbstractions ~/.julia/packages/ShaderAbstractions/20WwW/src/program.jl:58 
[10] scatter_shader(scene::Scene, attributes::Dict{Symbol, Observable}, plot::Scatter{Tuple{Vector{Point{2, Float64}}}}) @ WGLMakie ~/.julia/dev/Makie/WGLMakie/src/particles.jl:241 
[11] create_shader(scene::Scene, plot::Scatter{Tuple{Vector{Point{2, Float64}}}}) @ WGLMakie ~/.julia/dev/Makie/WGLMakie/src/particles.jl:262 
[12] serialize_three(scene::Scene, plot::AbstractPlot) @ WGLMakie ~/.julia/dev/Makie/WGLMakie/src/serialization.jl:335