Skip to content

Conversation

@ffreyer
Copy link
Collaborator

@ffreyer ffreyer commented Jul 29, 2025

Description

Fixes https://discourse.julialang.org/t/unwanted-clipping-at-corners-of-glmakie-3d-plot/131053

Volumes are drawn in a box, where the backside of the box "renders". If fragments (pixels) of this box end up outside the near .. far range, OpenGL/WebGL will clip them. And if they get clipped, the entire ray trace for that pixel gets clipped.

To avoid this, the pr hard-codes clip space z coordinates to 0, which should always pass the clipping test -w <= z <= w. For volume plots that don't write z values during ray tracing (or turn it off with enable_depth = false) this may change the z ordering between volume plots and other elements. If I'm not mistaken volumes should end up in front of things more often. I don't think that matters much, because the z ordering was already wrong to begin with. If it does, we could use z = w to move them to the far plane or z = -w to move them to the near plane, instead of the center.

  • Updated volume plots to use the ray start depth as their depth. This gives better depth ordering than a static z value, but could cause near-plane clipping. So far I haven't noticed any issues in LScene or Axis3 with it.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Checklist

  • Added an entry in CHANGELOG.md (for new features and breaking changes)
  • Added or changed relevant sections in the documentation
  • Added unit tests for new algorithms, conversion methods, etc.
  • Added reference image tests for new plotting functions, recipes, visual options, etc.

@github-project-automation github-project-automation bot moved this to Work in progress in PR review Jul 29, 2025
@MakieBot
Copy link
Collaborator

MakieBot commented Jul 29, 2025

Benchmark Results

SHA: 2829a39d90ac318cdbb92cdf48483ba168a26952

Warning

These results are subject to substantial noise because GitHub's CI runs on shared machines that are not ideally suited for benchmarking.

GLMakie
CairoMakie
WGLMakie

@ffreyer
Copy link
Collaborator Author

ffreyer commented Jul 30, 2025

"Depth Shift" test fails in WGLMakie because it now looks more like GLMakie. (note the bottom corner of the volume)

before after GLMakie
image image image

@ffreyer ffreyer marked this pull request as ready for review July 30, 2025 19:36
@ffreyer ffreyer requested a review from SimonDanisch July 30, 2025 19:36
@ffreyer ffreyer moved this from Work in progress to Ready to review in PR review Aug 4, 2025
@ffreyer ffreyer merged commit 76123f2 into master Aug 6, 2025
24 checks passed
@ffreyer ffreyer deleted the ff/no-clip-volume branch August 6, 2025 16:21
@github-project-automation github-project-automation bot moved this from Ready to review to Merged in PR review Aug 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Merged

Development

Successfully merging this pull request may close these issues.

4 participants