0

am attempting to access the pixel information for a viewport render, but sadly, I'm coming up short...

Getting that information using Python would be ideal, because it would allow me to update Blender, and still maintain that functionality. Worst case scenario would be to alter source code for that specific feature. I’m not shy of getting my hands dirty, I’m currently in my Masters degree in Informatics Engineering, but again, this would not be ideal.

I can’t use either the write_still = True or the save_render(filepath), because writing to file takes too long to do (it costs around 70ms on my machine, meaning it doubles my times).

So far what I tried was accessing the Render Result in bpy.data.images, only to find it empty. I used the trick described here. Long story short, you dynamically add a Render Layer Node in the compositor and connect it to a Viewer Node, and there you can access the pixel information.

This works… for renders only. I am bound to using viewport rendering because it is the only way I can get remotely acceptable times for the task I was assigned. For viewport rendering, the Render Layer Node is always empty.

I can visually see in the image editor that the Render Result has finished, and the render is successful. However, the Python API from everything that I researched doesn’t allow me to access those pixels… Anyone have any guesses?

Even if you don't have an answer, thanks for taking the time to read this!

  • Could you use the workbench engine instead of viewport render? – Robert Gützkow Aug 08 '19 at 08:59
  • @rjg Afraid not, it really has to be a final render. However, are you familiar with a way to fix this problem using the workbench engine? It could give me a new avenue to further explore this issue. – veryprofessionaldodo Aug 08 '19 at 09:12
  • Not sure how why you consider workbench render is less final than the viewport render, can elaborate? Both aren't high quality renders, just simple rasterizers. With the workbench engine you can also access it through the viewer node. – Robert Gützkow Aug 08 '19 at 09:19
  • Oh sure, I forgot to add, this has to be done using Eevee. It's the same as if clicking on View > Viewport Render Image. The only exception is that I should bypass the need to write to file, and access the pixels of the Render Result. – veryprofessionaldodo Aug 08 '19 at 09:27
  • The viewport render doesn't trigger the compositor, that is why the trick doesn't work. You may be able to accomplish what you want by accessing the OpenGL wrapper, I've never done this but it might be suitable for your needs. (https://docs.blender.org/api/current/bgl.html?highlight=glreadbuffer). Perhaps you can add more information about what you're trying to accomplish with the renders so we can give other suggestions, that may be more suitable? – Robert Gützkow Aug 08 '19 at 09:51
  • Sure! What I want is to access the pixel information of a given render result. I want to run a script and have a 360 capture of an object. I currently have a script that rotates the mesh correctly, and the render output verifies it. All I need now is to access the pixels so I can send them through a web socket without writing to file, removing I/O times. And thanks for the help so far! – veryprofessionaldodo Aug 08 '19 at 10:04

0 Answers0