fix render to depth image on Apple Retina displays #7001
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Type
Motivation and Context
Many users have encountered the issue that an active high resolution Retina display, e.g. an open MacBook screen, causes
render_to_depth_image
to only save the lower left quarter of the depth image.This also happens if an external monitor is connected. The only workaround is to close the MacBook display, i.e. not having an active retina display, and having an external monitor as the primary monitor.
Example:
Here is a small example to recreate the issue (credit to @jerome-godbout-lychens from #6999 ).
Checklist:
python util/check_style.py --apply
to apply Open3D code styleto my code.
updated accordingly.
results (e.g. screenshots or numbers) here.
Description
At first glance, this seems very similar to pixel coordinate scaling issues on high resolution displays on MacOS, similar to GLFW framebuffer issues. However,
render_to_image()
works correctly, it is onlyrender_to_depth_image()
that has this issue.Most of the rendering process is very similar between the two functions. One of the few differences is that the depth version calls
ConfigureForColorPicking
.Open3D/cpp/open3d/visualization/rendering/filament/FilamentRenderToBuffer.cpp
Lines 136 to 148 in 5f148f2
, which disables a lot of the post processing that is used for RGB rendering, as it's not required for depth rendering:
Open3D/cpp/open3d/visualization/rendering/filament/FilamentView.cpp
Lines 287 to 293 in 5f148f2
Surprisingly, it turns out that activating shadowing again for the depth rendering fixes the scaling issue and the depth image saves correctly. I was not able to find any obvious cause for this in Open3D code, so for now I am assuming that
setShadowingEnabled
inOpen3D/cpp/open3d/visualization/rendering/filament/FilamentView.cpp
Line 199 in 5f148f2
has some unknown side effect in Filament.
Results of turning shadowing on in
FilamentRenderToBuffer::CopySettings
ifdepth_image_
:As far as I can tell, this has no negative effect on the depth image result.
Additionally, turning on shadowing again in
FilamentRenderToBuffer::CopySettings
could be guarded by#if __APPLE__
, but I omitted it for now.Looking forward to feedback. Would also be thankful if someone else can validate that this fix works for them. Thanks!