I have different cameras in the scene. I go through the cameras, change the active camera bpy.context.scene.camera to the camera of my choice and obtain a rendering using Blender Internal rendering engine. This is all done in Python. I set up the scene and the cameras as follow:

import bpy

for i in range(numCameras):
    rotateCameraToObj() # this rotates the added camera to focus on the mesh

for i in range(numCameras):
    #bpy.ops.render.render(write_still=True) # If uncommented, things would be fine

However, strangely, for one of the cameras (the last one added) I need to do the rendering twice otherwise the first rendering is going to be always black. I made sure nothing is wrong with my camera and other settings that cause getting a black rendering by following the things mentioned here. All settings seem to be fine so I am confused. I also saved the .blend file and loaded it on my computer and were able to obtain renderings with the same camera without any issues. Does anyone know what could be potentially causing the issue? Could it be a bug in Blender?

  • $\begingroup$ @batFINGER Everything works as expected when I once get two rendering from that specific camera twice. From that onwards I do not have to do two renderings for that camera. I'm sure my code has something that causes this but the code is just an extension of the pseudopod I posted above. It might also be a server issue. I'm running Blender on a server and as a module in Python. $\endgroup$ – Amir Mar 2 '18 at 4:18
  • 2
    $\begingroup$ Without seeing how you are switching cameras etc hard to tell. Could be as simple as a scene.update() And how could anyone check if they have the issue, without writing their own methods to add and set camera? It would not be difficult to set up a test script to run on default cube would it? $\endgroup$ – batFINGER Mar 2 '18 at 4:22
  • $\begingroup$ @batFINGER When I posted this question I was basically waiting for someone to say they have also had a similar/relevant issue and this is how they resolved it. So I didn't expect anyone to replicate everything. You're right but I cannot share my entire code with everyone. However, I'll try to preserve the relevant parts and make it a simple script and post it here later then. $\endgroup$ – Amir Mar 2 '18 at 4:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.