SBCV / Blender-Addon-Photogrammetry-Importer

Addon to import different photogrammetry formats into Blender
MIT License
890 stars 79 forks source link

Joint Rendering of the GPU Shader Module and Viewport #15

Open SBCV opened 4 years ago

SBCV commented 4 years ago

Currently, this addon uses the GPU Shader Module, i.e.

import gpu
from gpu_extras.batch import batch_for_shader

to draw point clouds in the 3D Viewport.

Unfortunately, it is not possible to render this content using Blender's default OpengGL renderer. See this question for more information.

Therefore, I'm looking for an alternative way to jointly render point clouds and other Blender elements (such as cameras, image planes) with correct occlusion.

Drawing cameras and image planes with the GPU module is theoretically possible. However, I can imagine that there are cleaner approaches to solve this issue.

SBCV commented 4 years ago

Update: Following potential options did NOT work for me:

GPU Module https://docs.blender.org/api/current/gpu.html The GPU Module has no access to other render buffers. When using offscreen.draw_view3d() there is no possibilty to acess the depth buffer, which is required to compute correct occlusions of the Blender environment (including camera cones etc) and the point cloud.

Custom Renderengine (https://docs.blender.org/api/current/bpy.types.RenderEngine.html): The render engine itself does not draw the cameras (thus, can not be used to export the corresponding results).

SBCV commented 4 years ago

Update: According to this thread, there will be a new point cloud object type.

Another reference here: https://developer.blender.org/T75717

SBCV commented 4 years ago

https://developer.blender.org/T73324

SBCV commented 3 years ago

bpy.ops.screen.screenshot provides a reasonable workaround. See this commit for more details.

mquantin commented 3 years ago

About that issue of joint rendering, I'm not sure I understood the proposed workaround. Is it the export screenshot option of the openGL Panel ? Is there a way to screeshot nothing of blender's GUI (panes, grid, axes, background color, etc) BUT the 3D objects (ie pointCloud and Mesh) ?

Or maybe a way to render blender elements through the GPU Shader Module, so they'll be included in the renderings of the pointCloud?

SBCV commented 3 years ago

About that issue of joint rendering, I'm not sure I understood the proposed workaround. Is it the export screenshot option of the openGL Panel?

Yes, the screenshot option is the current workaround.

Is there a way to screeshot nothing of blender's GUI (panes, grid, axes, background color, etc) BUT the 3D objects (ie pointCloud and Mesh) ?

Yes, you can configure the view port overlay options - see the following image.

viewport_overlays_annotations

Or maybe a way to render blender elements through the GPU Shader Module, so they'll be included in the renderings of the pointCloud?

As far as I know, it is not possible to render the Blender elements with GPU Shader Module (however, I could be mistaken here). If you have any experience regarding this issue, please let me know.

Alternatively, one could use the reconstructed camera properties to visualize the camera cones using a set of lines with a reasonable amount of work. However, I do not know if adding image planes / background images is possible at all.

mquantin commented 3 years ago

Thanks for your help. Great addon by the way. Thank you for the advice. Now my 3D scene is much clearer: no more axes, grids etc. Still remains the panes panes I unticked this option region overlap in preferences. option Then I got a clean image inside a frame. frame

From this point, i can crope the frames in a batch process.... well it's a workaround!

SBCV commented 3 years ago

Thank you for posting this - I didn't know that this option existed. I think we should add this information to the documentation!