Not sure if here is the correct place to ask a question. I also posted the question here
I have two objects (in collections) in the scene and I want to render only one of them programmatically (from Python). When I measure the rendering time, there is always overhead of Depsgraph build time.
import time
import bpy
bpy.app.debug_depsgraph_time = True
start = time.time()
print("Start: ",start, "s")
bpy.data.collections['B747'].hide_render=False
bpy.data.collections['B757'].hide_render=True
bpy.ops.render.render(animation=True)
end = time.time()
print("End: ", end, "s")
print("Duration: ",end -start)
Start: 1687435725.4579306 s
Depsgraph built in 0.105444 seconds.
Depsgraph updated in 0.009703 seconds.
Depsgraph evaluation FPS: 0.020573
Saved: '/tmp/output0001.exr'
Time: 00:00.14 (Saving: 00:00.02)
Depsgraph updated in 0.008152 seconds.
Depsgraph evaluation FPS: 0.023989
End: 1687435725.734076 s
Duration: 0.27614545822143555
As you can see, rendering + saving takes only 0.14 seconds while the whole duration of the code is 0.27 seconds.
When I comment out hide_render
, there is no such overhead.
# bpy.data.collections['B747'].hide_render=False
# bpy.data.collections['B757'].hide_render=True
Start: 1687435918.4967954 s
Depsgraph built in 0.000358 seconds.
Depsgraph updated in 0.001326 seconds.
Depsgraph evaluation FPS: -nan
Saved: '/tmp/output0001.exr'
Time: 00:00.16 (Saving: 00:00.02)
Depsgraph updated in 0.008340 seconds.
Depsgraph evaluation FPS: 0.020629
End: 1687435918.680713 s
Duration: 0.18391752243041992
Here, we observe 0.02s overhead which is fine.
Now, I want to avoid this Depsgraph build time overhead due to hide_render
.
What I tried is:
- Move away method
- Leave all the objects to be rendered and do not configure
hide_render
in the code. - Move the object away from the camera that I do not want to render in the image.
- Leave all the objects to be rendered and do not configure
=> It still loads the textures of all the objects for each rendering, so the rendering takes more time.
- Visibility method
- Don’t touch
hide_render
. - Turn off all the visibility parameters to False e.g. visible_camera, and so on
- Don’t touch
=> Same as 1.
Is there a way that I do not reload all the objects per rendering without setting hide_render
?