In https://docs.blender.org/api/current/bpy.types.RenderEngine.html the example shown loops over depsgraph.ids followed by looping over depsgraph.object_instances to get the initial scene.
def view_update(self, context, depsgraph):
if not self.scene_data:
# First time initialization
self.scene_data = []
first_time = True
# Loop over all datablocks used in the scene.
for datablock in depsgraph.ids:
pass
else:
first_time = False
# Test which datablocks changed
for update in depsgraph.updates:
print("Datablock updated: ", update.id.name)
# Test if any material was added, removed or changed.
if depsgraph.id_type_updated('MATERIAL'):
print("Materials updated")
# Loop over all object instances in the scene.
if first_time or depsgraph.id_type_updated('OBJECT'):
for instance in depsgraph.object_instances:
pass
However, what I’m seeing in my tests is that all scene objects are included in depsgraph.object_instances independent of the .hide_render value set on the object. How to make sure that the initial scene only contains the objects that actually need to be rendered? object_instance.show_self doesn’t help as it’s always True it seems.
When handling a final render the depsgraph passed to RenderEngine.render() will only have objects in object_instances that actually need to be rendered. Is there an easy equivalent for interactive renders?