1
$\begingroup$

I was wondering if there was a way to only calculate the things that are currently visible in the frame. My scene has a lot of trees that are slowing down my render times, and these are mostly out of sight. This would be especially efficient especially in my scene.

TL;DR Is there a way to stop things in the background that are out of sight from being processed/ slowing down rendering?

$\endgroup$
  • $\begingroup$ You could try to move them to a different collection and render them seperatly if needed and then combine the layers the compositor $\endgroup$ – DrachenSeele Apr 26 at 12:42
2
$\begingroup$

and these are mostly out of sight

but we can still see them!

Please read How is Cycles different from Blender Internal first.

Most materials [and objects] scatter light, so Cycles needs to account for light bouncing in different directions. How this is done depends on which [Integrator][6] is used.

Objects scatter light even if they are outside of the visible frame.

objects

If you remove them, you will likely receive a different result, even if they weren't directly visible. There are many ways to restrict rendering manually.

You could do a check with python to see if an object is in the cameras frustum. Adapting the code from this reddit post1 we can select all the objects which don't contain points in the frustum. However for a production ready check, we would also have to take edges/faces modifiers and reflections into account.+

import bpy
import bmesh
from mathutils import Vector
from bpy_extras.object_utils import world_to_camera_view


def check_if_vertices_in_frustum(scene, cam, obj):
    mat_world = obj.matrix_world
    cs, ce = cam.data.clip_start, cam.data.clip_end

    for v in obj.data.vertices:
        co_ndc = world_to_camera_view(scene, cam, mat_world * v.co)
        #check wether point is inside frustum
        if (0.0 < co_ndc.x < 1.0 and
            0.0 < co_ndc.y < 1.0 and
             cs < co_ndc.z <  ce):
            return True
    return False



scene = bpy.context.scene
cam = scene.camera

for obj in scene.objects:
    if obj.type == 'MESH':
        if (check_if_vertices_in_frustum(scene, cam, obj)):
            obj.select = False
            # obj.hide_render = False
        else:
            obj.select = True
            # obj.hide_render = True

1 Help with finding whether a vertex is visible from a camera or not

$\endgroup$

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.