I'm currently attempting to reach the pixel information of a Render Result. For performance reasons I do not want to save the file, only to render it, using Viewport Rendering. The Render Result image in the UV Editor correctly displays the result. Accessing that information however is proving to be quite difficult.
I've gone through several approaches:
- Creating a Render Result Node and connecting it to a Viewer Node in the Python Script. This works, only if it is a "full" render, not a viewport one.
- Adding a Image Node pointing to the bpy.data.images["Render Result"] and connecting it to a Viewer Node, but the Viewer Node continues to show nothing there.
- Using GPU Offscreen to render the viewport and then storing that information, but I have several problems with this one:
- Does draw_view3d already take into account the scene's samples settings? It's important that it uses that number.
- I could only call draw_view3d from an added handler, which significantly cut performance, and still didn't give me access to the pixels.
- Calling draw_view3d from within an
with offscreen.bind()always results in a segmentation fault, most likely due to the way I access the "View 3D" context. For this I iterate through all the areas, and when the type is "View 3D" I keep that value, and I call it in draw_view3d(...)
I could edit the source code to have access to those pixels, but this is meant to be used in a company, and maintainability is a big thing. If I can't update Blender in the future without re-editing the source code, that's a big negative. Using the Python API would be ideal because it would allow us to always use the same code throughout Blender 2.8.
If anyone has any suggestions, please lend a hand! Thank you for reading!