Artisticrender is supported by its audience. When you purchase through links on our site, we may earn an affiliate commission.  Learn more

Blender version: 2.8x

ToC

How view layers can help you render large scenes with less memory in Blender

Sometimes the scenes we work with in Blender are so large that they don’t even fit into memory. In those cases, we get an “out of memory” error when we render in Blender. There are multiple ways to deal with this, but one way that does not have us trade away quality is view layers.

The components needed to separate a scene are the view layers and collections. Turn off a collection for the current view layer with the checkbox next to its name in the outliner. Make sure you have transparent background turned on in your render settings and composite each layer together with an alpha over node to get your finished scene.

Let’s see how we can use view layers to separate our scenes into manageable pieces and combine them later.

How view layers work in Blender

Before we get to the setup, there are some concepts we need to understand. First view layers.

The view layers in Blender 2.8 and later were previously was called render layers in 2.79 and earlier.

If we start with a blend file, it can have one or more scenes. Each scene then has one or more view layers, and each view layer may include one or more collections.

To begin with, we care about the view layers and the collections. Let’s start with view layers.

A scene has collections and for each view layer each collection has some settings that tell Blender how that collection is going to be handled for the view layer.

We can create, rename, and remove view layers. In the application header to the far right, you can see a drop-down menu for scenes and view layers. On the right side of the view layer drop-down there are two buttons. The left one creates view layers and the right one delete the selected view layer.

You need to have at least one view layer to be able to render at all.

View layers have their own tab in the properties panel. However, this panel mostly contains render engine specific settings. Except for the view layer section at the top.

In this section, we have two check boxes. The “use for rendering” checkbox will render the selected view layer when we press F12 and render. This setting is local for every view layer. We can have some view layers that we render and some that we don’t.

The second checkbox, called “Render single layer” will override the first checkbox. This is a global setting that affects all view layers. Having this checked says, “Render only the currently selected layer no matter what other settings are in effect.”

Here is an example: Suppose we have 3 view layers created, but we decided that we didn’t need one of them, then we can deselect the “Use for rendering” checkbox so we don’t waste render time on this layer.

Then we rendered the other two layers by pressing F12 and once those layers where done we could see that the last layer was needed after all.

We can then press “render single layer”, go to the non-rendered view layer and render that separately.

The alternative would have been to check “use for rendering” for the missing layer and uncheck this setting on both the previously rendered view layers.

Much simpler to just check one box. Imagine if you had a hundred view layers that you had to uncheck this checkbox for.

That is essentially all we need to know about the view layers for now. Most of the magic happens with the collections.

Collections and their relation to view layers

All settings that we use to separate a scene into collections can be accessed through the outliner.

Each collection has a few settings that can be set for each view layer.

Some of these settings are hidden by default. To enable them, we need to go to the filter options and enable all the “restriction toggles”.

The settings in the outliner, specific for each view layer are:

The exclude checkbox to the left of the collection name
The eye icon that controls viewport display. This is what we toggle with “H” and “ALT+H” in the 3D viewport. An object hidden in the 3D viewport like this is still visible in the final render.

There are two more settings that by default are hidden that are view layer specific. These are “holdout” represented by a circle and “indirect only” represented by a bouncing arrow.

The only setting that has an effect on memory usage is the exclusion toggle. By disabling a collection from the view layer.

If we divide up a render into two view layers and just exclude half the collections in one of them and do the opposite in the other collection to have them combined afterwards, we most likely will run into some issues.

An excluded collection is truly excluded. This means we miss out on indirect effects on an excluded objects neighbouring objects.

An excluded object does not give any indirect light or reflections. It is like the object was never there.

Because of this we have to intelligently select groups of objects in our scene depending on how close, they are to each other.

A simple example would be to have a collection for foreground objects, another for midground objects and a third for the background and exclude them from each other.

However some of the midground objects may be affecting the shadows and reflections on objects in the forground and the background.

In those cases we might want to include some of the midground objects in the foreground collection and similar for the background collection.

This is where holdout and indirect only come into play.

The indirect only will not render the objects in the collection, but all indirect effects on surrounding objects will be visible.

The holdout flag will leave an alpha transparent hole on the pixels where these objects would have been. This is also what we want because these objects are rendered in full on some other view layer and can then be combined through the “alpha over” node in the compositor.

How to separate a scene with view layers with collections in Blender

Now that you have some theory behind you, let’s look at a practical example of how we can render scenes larger than our memory capacity.

For demonstration purposes we will take a much simpler scene and divide it up. We will start by dividing up a scene using Cycles only. Then we will divide up a scene that uses some Cycles elements together with some Eevee elements.

We will use a simple scene that will easily fit into a computer’s memory, but it will show the principles and techniques.

Spectacular! Right?

We have a few objects that are divided up into groups. These groups will represent our foreground and mid-ground objects. The background will be our world skybox with a solid grey color. We also have a plane below that catches shadows and bounce light back on to our objects.

The greater the impact an object has on another, the more we want them on the same view layer.

Here it makes sense to let each group of objects, front, back left and back right be 3 separate groups.

However, we have to take the ground plane into account for two reasons. Shadows, and indirect light. The ground will influence all groups that is significant enough to want to keep its influence available for all groups.

Let’s start by organizing the scene. I create a collection for each group of objects.

Note: For larger scenes, we may already have some kind of organization with our collections based on types of objects instead of position. This is not a problem, since an object can be a member of multiple collections. We can create a new collection and within it, we create additional collections to represent each group of objects based on position. Then we disable all other collections for rendering.

Then I create two additional view layers and name them like this:

  • Front
  • Back left
  • Back right

Next we go to the filter icon and enable the buttons for “holdout” and “indirect only”.

Now we need to make sure we exclude something from each view layer. To save memory the group we remove the least geometry from will be the threshold for how much memory we save.

Now we will configure the view layers. Starting with the “back right” group. Select it from the view layer drop down.

Here I left the plane included together with the “back right” group.

But I want to render the shadow on the plane from the “back left” group, so I keep it included and check “holdout” and “indirect only”. Then I exclude the front group since I don’t need the shadow from that group on the plane.

In the “back left” view layer I excluded the “front” and “back right” groups, but left the “ground” group in there with “holdout” and “indirect only” enabled. This way we keep the bounce light from the plane on the group to light up the underside somewhat.

For the “front” view layer, I excluded the “back left” and “back right” groups since they contributed little to the front group. I again set the plane to “holdout” and “indirect only” so we get the bounce light on the front of the objects.

Before we can render we need to set the background as transparent or it will cover the background elements when we combine them together in the compositor.

Go to the render tab in the properties panel and find the “film” section. Here enable the “Transparent” checkbox.

If you need the background as part of the output, you can go to the view layer tab in the properties panel. Find the “pass” section and in the subsection “light” enable “environment”.

This will render the sky to a separate channel that we can access in the compositor.

Compositing the view layers together

To composite the view layers together, we will need a view layer node for each view layer.

Since we add each layer on top of the previous one we need to start from the back.

Therefore, we start with the “back left” layer and pipe it to the top input socket of an “alpha over” node. Then we plug the “back right” into the lower socket.

The output from the first alpha over node is then piped as input to the top socket in another alpha over node. The bottom socket then gets the “front” group as input.

The last socket can then take the environment pass as input if it is visible in the shot. Here I just input a color that is close enough to the original background color.

Let’s now add some volumetric fog into this scene using Eevee and composite it on top.

Final thoughts

In this article we looked at how to separate a scene into multiple view layers with the goal to render larger scenes that otherwise would fit in our computer’s memory. We can use the technique in other scenarios. For instance, when combining elements from different scenes, or when we want to apply different effects to different parts of an image.

This method of separating a scene into view layers may sometimes be the only way to render a scene on lower end hardware. However, as software and hardware evolve this method becomes less and less useful for this use case. But separating and combining view layers will always be useful.

Thanks for your time.

Get our free workflow cheatsheet!

Join our newsletter and get updates of our news and content as well as our 3D modelling workflow cheat sheet.

More to explore

Blender Eevee Motion Blur guide

For quite some time I have encountered forum threads and twitter accounts asking about motion blur in Eevee. With the 2.90 release

6 Responses

  1. This was a very useful article for me Erik !!! Most tutorials on View Layers explain only the object separation to collections, and compositing with Alpha Over node later. They don’t talk about the missed out lighting and shadow effects of nearby objects, and using “smart isolation of objects”, indirect lighting, holdout, etc. to fix the issue. This confirmed my suspicion, and helped me solved the issue. Thank you !!

  2. The article is useful, though my crit is that in the post beginning view layers are called as view layers, collections as collections; further on – not so much:
    “Starting with the “back right” group. Select it from the view layer drop down…” – here “back right” group is considered as view layer. At least from the context.

    “Here I left the plane included together with the “back right” group…” – and here “back right” group is considered to be a collection which should be included into view layer to be rendered.
    This kinda confuses, although the general idea of the article is still clear.

    My question would be then – what’s the point in view layers if you need to enable collection to have light bouncing and shadows appearing? You mentioned in the beginning of the article that only Exclude checkbox affects the memory amount the result will require to be rendered. And you do check it for almost all collections in all view layers if you want to have correct and realistic result, especially if you have a scene where objects are next to each other and all are lit up from the light bouncing from the side and giving shadow on all of them (like for a room). You then will have to enable collections in view layers to have light bouncing correctly.

    1. Hi

      I use the word “group” to refer to just the objects by themselves, separate from collections and view layers or anything else. I just refer to the objects as “the bunch of objects in the back right” by using the word group instead of using “collection” or “view layer”. The objects themselves can be part of multiple collections that are nested within each other and those collections can be part of different view layers. Hope that makes sense.

      The idea here is as Anant Rao Kandikuppa put it in an earlier comment, to use “smart isolation of objects”. If your scene is complex enough so that it is a problem to hold everything in memory, you can use some smart exclusion to exclude and separate those objects that contribute the least to each other’s look. In the end you can have a result that the viewer can’t tell is rendered in different passes and stitched together in post-production if done right and your scene allows.

      This is not perfect. The perfect solution would be infinite RAM. But this can be a useful route if you can’t squeeze everything into memory. Not for all scenes, but many. I agree that interior scenes will likely be harder.

      I also just rediscovered this article that I think may shed some light on the view layer vs collection thing.

      https://code.blender.org/2017/09/view-layers-and-collections/

      I hope that answers the question and thanks for your comment and feedback!

      /Erik

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.