Thoughts on Optimizing Your Cycles Renders (Patreon)
Content
[This is written specifically for Blender's "Cycles" path tracer, but I assume a lot of the same logic applies to other path tracers? Also, I mention below, but if you have a render with crazy fireflies, feel free to post a link in a comment, and maybe we can identify the problem area]
Hey hey! So- I keep seeing folks using the Cycles path-tracer with, like, 2,000-3,000 samples (or more??), and personally I rarely go over 200 or so, and while there's nothing wrong with making sure you get a super clean render, a lot of times fireflies are caused by just one little thing in the scene somewhere, and if you avoid having those things, you can skate by on a fraction of the render times.
One of the best things about rendering in cycles is that they keep optimizing it. Scenes render significantly faster now than they did 8 years ago, on the same machine, because they keep optimizing how the samples are used- and I think they still have some more tricks coming in the near future.
Mostly I'm talking about rendering for animation here. For stills, I mean sure, blast the samples to 2000 and just wait a couple hours. But a couple hours per-frame is pretty intense for the average person.
DENOISING
Video tutorial on:
HOW TO QUICKLY SET UP DENOISING
First getting this out of the way, the Optix Denoiser (both in real-time and final renders) is a game changer, and I can't wait for the point where we all have a card that can implement it (if you do, but you don't, you should! I didn't think I'd be into it, but it's so nice; like a middle ground between eevee and cycles). UNTIL THEN, though, definitely take advantage of the regular AI denoising features! (You used to have to install an intel library or something to do this- I don't think you have to anymore??)
Lots of folks think denoising makes renders "creamy" or too smooth- that's just because basically every demonstration of denoising does it with ridiculously few samples to show it off (just like *cough* I'll be doing in a second, here). And even if I DO push it too far, if I slip a little post-grain over the top, it totally negates the "creamy" feeling (I can't overstate much useful grain is for eliminating that "denoised" look).
Just for reference, here's a render with a thousand samples, Raw, Denoised.
So, at this point in time, Blender has- ack, is it 3 denoising options? They aren't labeled particularly well.
All of these sample renders were done with 25 samples to highlight artifacts:
Regular Denoising
Basically compares groups nearby pixels to eliminate fireflies- you can see it can give a very blotchy look if you don't have enough samples, and it has that trademark artifacting around the highlights (the silver rail towards the back)
Intel AI Denoising
I think that's what it's called? Darn good! Look how well it treats that gradient and preserves details. I could use this in a project, for sure.
Optix Denoising
Nice! And super quick. With a little grain over the top, I'd happily use this in a final project.
FIREFLIES
One of the reasons the denoisers work so well in these instances is they aren't having to deal with fireflies, which are the big enemy of path tracers. Fireflies are those super bright points caused by anomalous light paths.
A Huge Thing to Keep In Mind: if you have fireflies in your scene, again, often it's just from one or two random elements in your scene. So all you only have to figure out is that one thing. How to cheat it, do it some other way, or render it separately.
Don't have geometry intersect the light- that's a GREAT way to get fireflies. In fact, keep your geometry a bit away from the lights, if you can. Otherwise you end up with really bright bounced light. Both of the following renders use 5 samples. The only thing that's changed is the location of the monkey relative to the light:
You see that? Still noise, but not really fireflies (particularly look in the darker area to the right of the image).
This comes into play a lot when you're putting practical light sources in your scene. For example, if you model a headlight (or lantern or something), and try to "make it work" by sticking a super bright little light in there, you're inevitably going to get a ton of fireflies as the light paths bounce around trying to escape. It's not the most physics accurate, but usually I'll try to add just enough light to make the headlight look right, then I'll stick a spotlight in front of it, shining un-blocked onto the street.
And refraction and caustics- turn those off unless you need them.
Also! Limiting indirect light! I don't tend to do this, because it can fundamentally change the feeling of the render in some cases, but here's where the settings are.
This is it set to 10 (the default, not particularly clamped)
And now set to .2 (very clamped, for demonstration. I'd usually suggest not going below 1, personally.)
I'm hoping not too much of this info is out of date (they keep updating everything!) For example, having lots of lamps in your scene used to really increase the render time, but I feel like that's not as much of an issue any more? I keep adding more and more lights to scenes and don't seem to be punished for it these days.
Normal/bump maps! Try to keep them fairly minimal. A glossy surface with a really intense normal map can take a long time to resolve.
The time added by motion blur seems faaairly negligible, unless you have a TON of it. The longest render times I've ever had involved massive amounts of motion blur- a big spinning blade. Just slowing it down a little bit changed the render time from 2 hours to 15 minutes.
Dark materials just absorb light, so if you're properly trying to see things, you'll need a ton of it. I've seen scenes made entirely of dark materials, and they can be tricky to light, for sure! And if everything is dark, that means the few bright things'll be super bright and blasting out fireflies like crazy. If I were doing a cave scene, I'd rather have a lighter-colored cave I could illuminate with less light than a dark cave I just had to blast with light.
If you're really trying to optimize, give your light a way to "escape". All light paths are just bouncing around looking for a light source to call home (counter-intuitively, light paths start in the camera, shoot to the object, then bounce around till they find what's lighting it). The more exits available to it, the sooner it can find a light source and be done. If you can ever delete a wall or a ceiling to let it escape (without changing the look of the render), do it!
Exterior scenes tend to render faster than interior, because typically light paths can find their way from the camera to a light source (the sky) with just one little bounce off a piece of geometry.
On that note, what about interiors? The first thing people did with cycles when it showed up is set up a room with a window and blast a sun in it to see the light bounce around. That's because before that, light didn't bounce, it just went straight from the camera to the object to the light, and if anything got in the way, it resulted in 100% shadow. Multiple bounces was wild!
But that's also one of the trickiest ways for cycles to light a scene, because you're lighting almost everything with indirect light. Every path has to bounce twice. You're not just tracing from the camera to the object to the light, but from the camera to the object to the floor to the wall to the light, which means you need a lot more bounces. And it's great to use secondary bounces as fill lights- that's the great thing that cycles can do- but you're signing yourself up for longer render times if you're using that as the primary light source.
It's not a rule really, but a good tip- your render times'll be significantly faster if you can light with direct light instead of indirect. That's why HDRIs are so rad. They can easily simulate indirect light (like, any of the light bouncing up from the ground or nearby walls), while still counting as a direct light.
Here's an example. Both of these scenes have 5 samples, but one's lit with direct light (a light from inside the room), and the other with indirect (the light shining in from outside and bouncing around).
Or- take a look at this one:
In this case, I replaced the whole back wall behind the camera with an emission plane. Now all the light doesn't have to bounce around until it finds its way out the window, it just has to hit the back wall. Maybe not 100% as realistic, but it's giving almost decent results for 5 samples. I dunno. Just throwing around ideas. Sometimes I'll pre-render a back wall (or just use a random image of a wall) and use it as an emission material for unseen walls, to help optimize the render times.
I suspect that's the core of why folks have so much trouble getting good render times with interiors, mostly because they tend to be trying more to light indirectly. Although, obviously sometimes that's the look you want and you dont' want to cheat it and you'll just eat the render times- but it's good to know.
Volumetric haze in cycles? Sometimes it renders quick, but sometimes it makes render times take foreeeeeever (haven't really discovered why that is, yet, just seems correlated to scene complexity). Scenes that'll otherwise render in a couple minutes can sometimes easily take 20 before the noise starts to clean up. BUT eevee has pretty darn nice volumetric rendering, so if you can combine an eevee haze pass with a cycles beauty pass, you could save yourself days of render time.
OH JEEZ AND THE GLASS SHADER. So- here's the scene with the light outside and a pane of glass in the window, using the glass shader (with the roughness turned down). That's a very reasonable thing to do. Lots of people do it. Except look:
No light will penetrate the Crucible of Glass. I don't even know why it's this bad. It's madness. (Notably, I turned the refractive caustics on, or it's even worse)
So instead, I mix together a transparent and glossy shader, like this (the mix factor setting is fairly arbitrary (okay well maybe not from a physics perspective, but what I'm saying is I just put it somewhere)):
And get a result that looks like this (still crazy noisy- this is only 5 samples, after all- but at least it's permeable to light).
Lots of people have talked a lot about glass, and I suspect my solution is super hamfisted, but it's a starting point. And if you want you can use an add shader instead of a mix shader, and you'll get 100% of the light entering the room. It's not totally physics-accurate, but man sometimes you gotta get that light in there!
Another Important Note- Emissive Materials
Emissive materials are GREAT! But if you're using emissive materials to light your scene, make sure they're big enough! A big glowing billboard casting light on nearby objects is rad, but trying to light a whole room with a few tiny emissive bulbs isn't great (remember, it's just bouncing paths around the room until it happens to find your little bulb). Try to stick an actual lamp (slightly larger, if you can- remember, the bigger it is, the "easier to find"!)) nearby to supplement. Likewise, strings of christmas lights, or little candles- you're going to have a hard time!
I had a little bit of trouble writing this, because a lot of these things are things I've just learned to avoid over the past 8 years, to the point where I don't even recognize I'm doing it now, so if you happen to have any renders you're having trouble cleaning up, feel free to post them below and maybe we can identify some problem areas!
Also- I don't know the math behind a lot of this, it's just me messing around, so if anyone has any Knowledgeable Tips, I'd love to hear em!
Hopefully we can cut down some of these render times!