Sunday, March 24, 2013

Sampling - In Depth

It has been a long while since I've posted here. Life has changed a lot, and I don't get to use Vray (or any off-the-shelf rendering software) very much anymore. Since I've been with Blue Sky for the last 1.5 years, My vray lic has lapsed, and I have had scant time to test other tools (but I have a bit).

There has been one major subject that folks have asked me about in more detail, and I just haven't gotten time to record a video for. I'd like to address that subject here as best I can, in text.

Sampling:

Vray's DMC is awesome. But it's not perfect. Sometimes, it needs help to do its work properly. I'll assume you're already familiar with the basics of DMC. If not, check out my video on the subject. The thing about DMC is that it might lead one to believe that you can control all quality in one place. For many situations, this illusion holds true. Even if it takes a bit longer to render, it saves fiddling time, so many use it that way... a master control. I may have contributed to that belief with my own videos. So I'm sorry it took me this long to explain in more detail.

In my vids, I mentioned turning the "Adaptive Amount" to 1, to allow DMC to do the work. That can be very handy, but lets get down to more serious optimizing. When you set that to 1, you are letting something happen that can unwittingly slow down your scene in some cases. There is a setting in the DMC section called "Adaptive Min Samples". For any glossy calculation (area lights, glossy reflections, gi, atmosphere, etc), this will be the starting number of samples. It defaults to 8, and in plenty of cases, this is not enough. Sometimes this is a severely undersampled starting point that will force DMC to work much too hard to overcome. That's why when using DMC, it seems like you have to lower your quality threshold super low... and still not get a clean image. Let's fix this.

side note - You could of course, just raise that "Adaptive Min Samples" setting. But that could be inefficient. You would be raising all min samples for all glossy settings, even where they are not needed. It's possibly effective, but a bit lazy, and that's not where we're going.

It would be better to determine what glossy aspect of your render is causing most of your noise and fix (up the samples on) that thing. Is it GI, a huge area light, material settings? It all depends on your scene, so there is never an out-of-the-box answer. One of the easiest ways I've found to troubleshoot a scene, and see where the noise is coming from is to render an image with a nice set of render elements to view in the vray framebuffer. You can tell a lot by seeing which elements are the noisiest.

While in a "Adaptive Amount"= 1 setup, set your threshold to a faster number like .02 or something you can stomach the rendertime. Do a render with several elements active. Include Diffuse, Specular, Reflection, GI, and Environment (if you are using it). You can also include light elements if you want to troubleshoot particular individual lights, but it isn't critical. When this finishes (or even while it's running) you can tap through the different elements, and determine which ones are the noisiest. Perhaps the diffuse and gi layers are the worst. That points to the need to raise samples on the area lights, and the gi solution. This is pretty common.

Now, change the "Adaptive Amount" setting to 0.9 . Why? This setting serves as a blend between manual sample settings and the DMC automatic threshold. If you have "Adaptive Amount" set to 1, then your area light will use the "Adaptive Min Samples" of 8 to start. If you area light is large, this may be too low a starting point to really get to a clean image quickly. The important thing to understand is that any subdivs set on glossy parameters (such as an area light) is actually set by the inverse percentage of "Adaptive Amount".

A simple example: [An area light with 10 subdivs to start] With "Adaptive Amount" set to 1, it will get 8 starting subdivs (the min default). At "Adaptive Amount" of .5 it will get 50%, or 5 subdivs to start. At "Adaptive Amount" set to .9 the light will start with only 10%, or 1 subdiv. I use "Adaptive Amount" at .9 since the math is easy; just move a decimal.

5 subdivs, 1 subdiv, or even the 8 subdivs of the DMC min setting are all sometimes too low to give the DMC sampler enough to work with. A large area light may need something more like 20 subdivs or more to give the DMC system enough tio refine. I'll often plug 250 into a light and see where that gets me. 250x10% is only 25 subdivs. This often cleans up the noise from an area light quickly. It puts more samples only where it is needed, and therefore is faster to calculate than to simply over-sample the entire image with a lower threshold. In fact, if you get your various glossy settings right, you can often get by with a higher DMC threshold, and get significantly faster renders.

In our previous example, we had noise in the area light contribution and the GI. We probably fixed the light samples now, but should also raise the GI samples. (I'm assuming Brute Force as primary). Once you start tuning each glossy parameter, you'll start to get a feel for how many more samples each one requires. Don't be afraid of some larger numbers as you are only really using 10% of whatever you enter in.

Not only can his method improve rendertimes, it can also allow you to render something clean that you simply never could with a purely adaptive dmc. One situation where this is critical is ENVfog. If you've been using fog with "Adaptive Amount"=1, then you've probably been cursing rendertimes and noise. Now with "Adaptive Amount"= .9 go set your fog subdivs to 250, and you'll get much cleaner ENVfog renders in less time. I've had scenes where fog was critical, and I raised it to 500. But rendertimes were perfectly acceptable.

2 comments:

While many learned professors have abandoned hope of ever discovering the truth behind lighting, I for one feel that it is still a worthy cause for examination. I really, really like lighting. While it is becoming a hot topic for debate, spasmodically it returns to create a new passion amongst those who study its history.