Home Creators Posts Import Register Favorites Logout

Content

There are some tricks to getting the best results out of Cycles in Gaffer. Let's have a look!

CPU vs GPU

Cycles CPU was the main version of Cycles for a long time, but at this point it's fair to consider it primarily a GPU renderer. There is feature parity between the two modes and the look is identical. GPU produces quick results while CPU is generally quite slow.

To start, let's have a look at one image rendered with both CPU and GPU to compare render time and look.

In this case, GPU took about 5 minutes and CPU took 22. That's in line with my expectations. I find that CPU being about 4 times slower than GPU is a good rule of thumb.

Here's a difference blending mode showing how the two images compare, brightened significantly to accentuate the results:

The main source of the difference is simply a different random sampling seed, especially noticeable in the fur. Perceptually, the look is identical, or nearly so.

To be fair to Cycles CPU, 22 minutes is certainly decent. It's in the ballpark with what you might expect from RenderMan RIS or Karma or Arnold in CPU mode. That being said, the majority of the time it's preferable to use Cycles GPU. It works brilliantly for both lookdev and final frame rendering.

The only case where you might prefer CPU is when sending your renders to a CPU-only farm, or in the case of very high memory requirements. A large scene with a huge number of meshes and textures sometimes simply won't fit in typical GPU memory.

Sampling

As with most renderers, it's preferable to turn on Cycles' Adaptive Sampling mode.

Adaptive sampling lets the renderer decide what areas of the image need refinement and which are "done," according to your specifications.

When enabling adaptive sampling the first step is to set a maximum number of samples, 3000 in the image above. This is a failsafe number that will end the render even if it technically needs further refinement.

The main setting you'll use to control the quality of the image is the Adaptive Threshold. I find that 0.008 often works well for final frames. It produces clean images and doesn't take excessively long.

Another great benefit to adaptive sampling is that it makes for much better animations. Cycles will attempt to bring the entire image to the same noise level and as a result the noise across every frame of an animation is perceptually congruous. Non-adaptive sampling can lead to areas of the image that are consistently either cleaner or noisier than others, sticking out like a sore thumb.

Bounces

Some renders might benefit from adjusting the number of bounces for a given light path. For example, interior architectural scenes will likely need a greater number of diffuse bounces to avoid excessive darkness and noise. Similarly, a scene with a lot of glass would look better with increased glossy and transmissive bounces. In the images below we can see the effect of different kinds of bounces on the final image.

Glossy 1 bounce:

Glossy 8 bounces:

Transmission 2 bounces:

Transmission 8 bounces:

Generally speaking, increasing bounces shouldn't affect render time too much. The render time on each of the above images was within 2-3 seconds of each other.

Caustics

It's critical to turn on caustics in most renders. Enabling them will add nice colored shadows and reflections.

Plus, assets such as eyes require caustics in order to keep the iris bright under a transmissive cornea. Without refractive caustics the iris here is black.

Displacement

Most of the time we'll want to use a CyclesAttributes node to set the Displacement Method to True on all our meshes. This will perturb the surface of the mesh and gives the most photorealistic result.

It's worth falling back to Bump for anything that won't be close to the camera since bump is much, mush faster. If your scene has any elements that you're confident will never be seen in closeup, by all means set those meshes to bump only.

Tessellation

Gaffer includes support for Cycles native rendertime subdivision, but it's slow, prone to crashing, and can cause ugly UV artifacts.

Fortunately, Gaffer comes with its own subdivsion solution, a node called MeshTessellate.

For now, we'll be using manually-controlled subdivision. It's not the absolute most optimal solution, but it works. Ultimately what we want is adaptive subdivision, but it's not available in Gaffer... yet! It's on the roadmap and should be coming sooner rather than later.

The general idea is you want to increase the Divisions in your meshes just enough to support the detail you want to see in your displacement. Let's have a look at a bee eye to see the effects of different tessellation levels. Scenes load more and more slowly and use more and more memory the more we tessellate, so there is great value in finding the line between too little and too much.

Not tessellating the mesh at all leads to low resolution displacement that doesn't accurately represent our displacement texture. We start to see diminishing returns after a certain number of divisions. I found that 4 was a good number in this case. Going higher uses more and more VRAM with zero visual benefit.

Time to first pixel increased from 29 seconds at 1 division to 35 seconds at 4 divisions.

While we wait for adaptive tessellation to arrive, for now the best thing to do is manually set tessellation levels throughout the assets in your scene. We can use Gaffer's path filters and groups features to easily control what parts of the scene get how much tessellation.

I also like to use a spreadsheet and a context variable to simply turn off tessellation altogether. When doing lookdev we don't want to load highly subdivided, dense meshes since it will slow everything to a crawl. It's helpful to set the tessellation to either off or very low, then have a spreadsheet set up to enable high divisions for final frame rendering.

Conclusion

In this article we took a detailed look at how to optimize Cycles when doing lookdev and final frame rendering in Gaffer. Use GPU whenever possible, dial in adaptive sampling to suit your needs, turn on caustics, and carefully manage subdivision using Gaffer's tessellation tools. Keeping all this in mind will lead to a smooth workflow and beautiful results!

Files

Comments

No comments found for this post.