Stereoscopic rendering for addon

Hi,
I’m interested in appleseed being able to use stereoscopic rendering. I’ve added the control panels and the 3D viewport works correctly however when I render it only renders the left image and then stops. This happens regardless of the camera or output settings. Am I missing some variable in the render operator or the export stage? The online docs don’t show anything.

I don’t think there’s any documentation for it, but the render engine is expected to fill in all the views in the render result.
https://docs.blender.org/api/master/bpy.types.RenderResult.html?highlight=renderresult#bpy.types.RenderResult.views

If you set the active view in the engine, you can get the camera shift and matrices for that view.
https://docs.blender.org/api/master/bpy.types.RenderEngine.html#bpy.types.RenderEngine.active_view_set
https://docs.blender.org/api/master/bpy.types.RenderEngine.html#bpy.types.RenderEngine.camera_shift_x

Hey Brecht. I managed to retrieve the X-offset for the cameras but I’m not sure where to pull the matrices from for any rotations (none of the camera matrices change with a different view_set). I’m playing around with camera_model_matrix but I can’t get it to work, nor am I sure that’s even the right option.

camera_model_matrix is not working for me at all. Here’s what I’m feeding the addon for testing:

self.active_view_set(view=“right”)
print(scene.camera.matrix_world)
matrix = mathutils.Matrix()
self.camera_model_matrix(scene.camera, False, matrix)
print(matrix)

Here’s what I get:

<Matrix 4x4 (0.7077, -0.2579, 0.6578, 7.4811)
(0.7065, 0.2583, -0.6588, -6.5076)
(0.0000, 0.9310, 0.3650, 5.3437)
(0.0000, 0.0000, 0.0000, 1.0000)>
-0.0808030441403389
<Matrix 4x4 (1.0000, 0.0000, 0.0000, 0.0000)
(0.0000, 1.0000, 0.0000, 0.0000)
(0.0000, 0.0000, 1.0000, 0.0000)
(0.0000, 0.0000, 0.0000, 1.0000)>

So camera_model_matrix doesn’t do anything to the matrix I feed into it, even with stereoscopic off. Am I using it wrong or is it broken?

It seems to be broken indeed, I’ve committed a fix.
https://developer.blender.org/rB894a2162521ceaa3347e311e47091ce2fbbeb83d

Now this should work:

def render(self, scene):
    for view in scene.render.views:        
        self.active_view_set(view=view.name)
        
        camera = self.camera_override if self.camera_override else scene.camera
        
        shift_x = self.camera_shift_x(camera, False)
        matrix = self.camera_model_matrix(camera, False)

        print(shift_x)
        print(matrix)

Thanks Brecht! I have to rebuild appleseed for python 3.6 before I can try it out but I’ll keep you posted.

Hi Brecht. I can retrieve the matrices now. Thank you for the fix!