RenderEngine - Render buffer is upside down


This is consistent with Blender 2.79 and 2.80.

I am integrating an external rendering engine implementing bpy.types.RenderEngine. I am also integrating the same engine into another package (Rhino 3d).

What I’m noticing is that, when I get the render data - a raw float array, corresponding to [r, g, b, a], [r, g, b, a], ... for width x height pixels or a (width, height, 4) shape - and assigning it to the render result, it is displayed upside-down in Blender. This means that the order of the rows is reversed: the bottom row is at the top, and the top row is at the bottom. In other packages and image libraries, the first row is at the top, but it seems to be the reverse in Blender.

Am I interpreting this wrong? Is there an option to switch this? Currently, I’m forced to copy the buffer and flip the rows myself before sending them to the render result. It just seems like strange behavior.

Thanks in advance for any comments / hints / tips!

1 Like


This gives strange, unexpected results, for some reason. It messes up the order of the rows somehow too, and I’m not sure why yet…

I can’t find back the reference, but Cycles expects image data in bottom-to-top scanline order (just like an OpenGL texture buffer). So if you arrange your float array in that order it should display fine again.

Easy check: render an image in Blender using Cycles. In the image editor hold the right mouse button over the pixels of the image and check the X,Y coordinates in the bottom left: the bottom-left pixel has coordinates (0,0)