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

CairoMakie has issues plotting 3D Rects with poly #4693

Closed
3 tasks
ranocha opened this issue Dec 28, 2024 · 2 comments
Closed
3 tasks

CairoMakie has issues plotting 3D Rects with poly #4693

ranocha opened this issue Dec 28, 2024 · 2 comments
Labels
bug CairoMakie This relates to CairoMakie, the vector backend for Makie based on Cairo. maybe wontfix TODO: review mesh (and poly) rendering typically backend specific

Comments

@ranocha
Copy link
Contributor

ranocha commented Dec 28, 2024

The code

julia> using CairoMakie

julia> poly(
               [
                       Rect(0.0, 0, 0, 1, 1, 2.5),
                       Rect(1.0, 0, 0, 1, 1, 1),
                       Rect(0.0, 1, 0, 1, 1, 1),
                       Rect(1.0, 1, 0, 1, 1, 1),
               ],
               color = 1:4
       )

produces the plot

Image

The 3D rectangles are not shown correctly. I would have expected something like I get with a smaller size of the big one:

julia> poly(
               [
                       Rect(0.0, 0, 0, 1, 1, 2.4),
                       Rect(1.0, 0, 0, 1, 1, 1),
                       Rect(0.0, 1, 0, 1, 1, 1),
                       Rect(1.0, 1, 0, 1, 1, 1),
               ],
               color = 1:4
       )

Image

  • what version of Makie are you running? (]st -m Makie)
(jl_oQJ1ul) pkg> st -m Makie CairoMakie
  [13f3f980] CairoMakie v0.12.18
  [ee78f7c6] Makie v0.21.18
  • can you reproduce the bug with a fresh environment ? (]activate --temp; add Makie)

Yes

  • What platform + GPU are you on?

Julia 1.10.7, Apple M2

@ranocha ranocha added the bug label Dec 28, 2024
@t-bltg t-bltg added the CairoMakie This relates to CairoMakie, the vector backend for Makie based on Cairo. label Dec 31, 2024
@ffreyer ffreyer added maybe wontfix TODO: review rendering typically backend specific mesh (and poly) labels Jan 18, 2025
@ffreyer
Copy link
Collaborator

ffreyer commented Jan 18, 2025

This is more or less expected. We can't do depth sorting per pixel in Cairo, so we do it per triangle using the average z value of the involved vertices. With that it can be the case that a triangle that is partially behind another ends up in front because its mostly closer to the camera/viewer.

You can work around this by making multiple plots and ordering them yourself:

f,a,p = poly(
    Rect(0.0, 0, 0, 1, 1, 2.5),
    color = 1, colorrange = (1, 4)
)
poly!(a,
    [
        Rect(1.0, 0, 0, 1, 1, 1),
        Rect(0.0, 1, 0, 1, 1, 1),
        Rect(1.0, 1, 0, 1, 1, 1),
    ],
    color = 2:4, colorrange = (1, 4)
)
f

(This currently doesn't work on 0.22, see #4738)

@ffreyer ffreyer closed this as completed Jan 18, 2025
@ranocha
Copy link
Contributor Author

ranocha commented Jan 19, 2025

Thanks for the answer

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. maybe wontfix TODO: review mesh (and poly) rendering typically backend specific
Projects
None yet
Development

No branches or pull requests

3 participants