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

3D axis broken in GLMakie v0.10.13 #3979

Closed
juliohm opened this issue Jun 20, 2024 · 8 comments · Fixed by #3984
Closed

3D axis broken in GLMakie v0.10.13 #3979

juliohm opened this issue Jun 20, 2024 · 8 comments · Fixed by #3984
Labels
bug CairoMakie This relates to CairoMakie, the vector backend for Makie based on Cairo. GLMakie This relates to GLMakie.jl, the OpenGL backend for Makie.

Comments

@juliohm
Copy link
Member

juliohm commented Jun 20, 2024

The 3D axis is floating randomly in the latest stable release:

image

You can see in the screenshot that tick labels are far away from the axis. Any rotation, zoom moves the labels around.

@juliohm juliohm added the bug label Jun 20, 2024
@asinghvi17
Copy link
Member

Is this common across all backends, and do you have an MWE?

@juliohm
Copy link
Member Author

juliohm commented Jun 20, 2024

Data: https://gist.github.com/juliohm/ca6ddae1995a5916c987282875ccadae

MWE:

using GLMakie
using DelimitedFiles

X = readdlm("data.csv", ',')

xyz = Tuple.(eachrow(X))

scatter(xyz)

@asinghvi17
Copy link
Member

I can replicate this on GLMakie and CairoMakie, but WGLMakie seems to give the correct result.

@asinghvi17
Copy link
Member

GLMakie
Screenshot 2024-06-20 at 11 36 38 AM

CairoMakie
iTerm2 OhCvv5

WGLMakie
Screenshot 2024-06-20 at 11 37 11 AM

@asinghvi17 asinghvi17 added GLMakie This relates to GLMakie.jl, the OpenGL backend for Makie. CairoMakie This relates to CairoMakie, the vector backend for Makie based on Cairo. labels Jun 20, 2024
@ffreyer
Copy link
Collaborator

ffreyer commented Jun 20, 2024

This is not a new issue. I checked Makie 0.21, 0.20 and 0.19 and they all have it. Weird that it's backend specific...

@asinghvi17
Copy link
Member

Could this be a float precision issue then? The numbers are in that range...

@ffreyer
Copy link
Collaborator

ffreyer commented Jun 20, 2024

Probably, but why is it not happening in WGLMakie?

@ffreyer
Copy link
Collaborator

ffreyer commented Jun 20, 2024

Seems to be

Makie.clip_to_space(scene.camera, markerspace) *
Makie.space_to_clip(scene.camera, space) *
Makie.f32_convert_matrix(scene.float32convert, space) *
model *
to_ndim(Point4d, to_ndim(Point3d, p, 0), 1)

If you add a parenthesis that include at least model * to_ndim(...) things work. Without them *(a, b, c, xs...) from Base runs, with
*(A::AbstractMatrix, B::AbstractMatrix, C::AbstractMatrix, x::AbstractVector) from LinearAlegbra. The former does a foldl, i.e. it multiplies the first two matrices first, the latter goes right to left. And the first two matrices are risky in terms of Float32 precision

WGLMakie computes the matrix product of the first two matrices directly as well, but in Javascript. I'm guessing it uses double precision.

Going left to right is quite a bit faster on it's own (14.9ns vs 20.7ns) and also useful for optimizing projections like [M1 * M2 * p for p in ps] to T = M1 * M2; [T * p for p in ps], so I think it would be best to just replace the camera matrices with Mat4d and convert to Mat4f as late as possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug CairoMakie This relates to CairoMakie, the vector backend for Makie based on Cairo. GLMakie This relates to GLMakie.jl, the OpenGL backend for Makie.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants