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

Clip values of campixel!, depth_shift, and translate! of 2D Scenes #2638

Open
jacobleft opened this issue Jan 29, 2023 · 3 comments
Open

Clip values of campixel!, depth_shift, and translate! of 2D Scenes #2638

jacobleft opened this issue Jan 29, 2023 · 3 comments
Labels
documentation GLMakie This relates to GLMakie.jl, the OpenGL backend for Makie. rendering typically backend specific WGLMakie This relates to WGLMakie.jl, the Web-based WebGL backend for Makie.

Comments

@jacobleft
Copy link

MWE and expected behaviors

According to the scenes_and_subwindows section in the docs, after drawing a 3D scene (with an outline)

using GLMakie, Makie
GLMakie.activate!()
scene = Scene(backgroundcolor=:gray)
subwindow = Scene(scene, px_area=Rect(100, 100, 200, 200), clear=false, backgroundcolor=:white)
cam3d!(subwindow)
meshscatter!(subwindow, rand(Point3f, 10), color=:gray)
center!(subwindow)
relative_space = Makie.camrelative(subwindow)
# this draws a line at the scene window boundary
lines!(relative_space, Rect(0, 0, 1, 1))

a gradient background 2D image can be added by

campixel!(scene)
w, h = size(scene) # get the size of the scene in pixels
# this draws a line at the scene window boundary
image!(scene, [sin(i/w) + cos(j/h) for i in 1:w, j in 1:h])

Then, a translation is needed to make the 2D image stay behind the 3D scene.

translate!(scene.plots[1], 0, 0, -1000)

Results

Workaround

A workaround I found is to adjust the farclip value of campixel!

campixel!(scene; farclip=1)

which gives a desired plot.
image
But I don't exactly know why this works.

@asinghvi17
Copy link
Member

Looks like this may be specific to GLMakie - running

using CairoMakie
scene = Scene(backgroundcolor=:gray)
subwindow = Scene(scene, px_area=Rect(100, 100, 200, 200), clear=false, backgroundcolor=:white)
cam3d!(subwindow)
meshscatter!(subwindow, rand(Point3f, 10), color=:gray)
center!(subwindow)
relative_space = Makie.camrelative(subwindow)
lines!(relative_space, Rect(0, 0, 1, 1))
campixel!(scene)
w, h = size(scene)
image!(scene, [sin(i/w) + cos(j/h) for i in 1:w, j in 1:h])

yields this
iTerm2 SrFObC
which seems fairly accurate.

@jacobleft
Copy link
Author

In your case, the translation is unnecessary. That is also inconsistent with the docs.

@ffreyer ffreyer added documentation GLMakie This relates to GLMakie.jl, the OpenGL backend for Makie. WGLMakie This relates to WGLMakie.jl, the Web-based WebGL backend for Makie. rendering typically backend specific labels Aug 24, 2024
@ffreyer
Copy link
Collaborator

ffreyer commented Aug 24, 2024

#4150 would likely change how this works (at least in GLMakie)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation GLMakie This relates to GLMakie.jl, the OpenGL backend for Makie. rendering typically backend specific WGLMakie This relates to WGLMakie.jl, the Web-based WebGL backend for Makie.
Projects
Status: No status
Development

No branches or pull requests

3 participants