2
$\begingroup$

In Cycles' render settings, there is a setting for a sampling pattern (default Sobol), and there is a setting for a pixel filter (default Gaussian).

What is the link between these settings?

More specifically, this is my understanding of what the two settings mean:

  • Sampling pattern: indicates a pattern of points within a pixel where rays will be cast into the scene
  • Pixel filter: used to filter the rendered image (post-processing, if you will), much like a Gaussian blur in Photoshop; this effectively adds to every pixel some contributions from neighboring pixels

I hope my understanding about these is more or less correct. Now my question, more precisely, is:

Could one use a sampling pattern that goes outside of the pixel boundaries to combine the sampling pattern and filtering into a single procedure?

Render settings

$\endgroup$
1
$\begingroup$

Simple Answere

What is the link between these settings?

The Pixel Filter randomly changes the coordinte of every sample with the given distribution, meaning for example: When the Sobol Sampling Pattern samples near the edge of the pixel, the neighbouring pixel might be lit instead with a rather high probability. This is used to get rid of aliasing on the sharp edge of very bright objects, like mesh lights.

Look at these examples with a mesh light with a strength of 100. You can see the noisy Gauss distributed white dots during the whole sampling process.

Gauss with width of 0:

Gauss 0

Gauss with width of 2:

Gauss 2

Gauss with width of 10:

Gauss 10

With more samples the last two would both result in a smooth image. The higher the width of the Gauss the less antialiasing you get, but at the cost of loosing some sharpness.

Could one use a sampling pattern that goes outside of the pixel boundaries to combine the sampling pattern and filtering into a single procedure?

Actually, this is a not a bad idea, but I never heard of any renderer doing this. Convoluting the Sampling Pattern with the Pixel Filter and using the resulting function as the new Sampling Pattern should result a render that converges to the same image.

This is however not desired probably because being able to separately choose these two functions rather than from a huge list of all possible convolutions is better. And the common Pixel Filter functions are used in other type of renderers, where sampling is done over the whole image rather than pixel-by-pixel, and one sample really lits multiple pixels, which is not stochastically sampled but fully calculated, like LuxRender.

Mathematical Explanation

First Possibility

Given the i-th columns k-th pixel indexed from 0, the Sobol Sampling Pattern gives a uniform pseudo random 2D vector (x, y) inside the [i, i + 1) x [k, k + 1) set, which is the mathematical notation for the square of the pixel. The rendering engine traces the related direction and returns with the color. The Gauss Pixel Filter samples a Gaussian distributed pseudo random 2D vector (dx, dy). The pixel containing the (x + dx, y + dy) vector gets lit with the traced color.

Probably this is done in Blender.

Second Possibility

Given the i-th columns k-th pixel indexed from 0, the Sobol Sampling Pattern gives a uniform pseudo random 2D vector (x, y) inside the [i, i + 1) x [k, k + 1) set, which is the mathematical notation for the square of the pixel. The Gauss Pixel Filter samples a Gaussian distributed pseudo random 2D vector (dx, dy). The rendering engine traces the (x + dx, y + dy) related direction and returns with the color. The original pixel gets lit with the traced color.

Why these result the Same

For every x, y, dx, dy where (x, y) is contained in the i-th columns k-th pixel pixel and (dx, dy) is a possible outcome of the Pixel Filter, the events below have the same probability:

First Possibility: The Sampling Pattern sampled (x, y) in the mentioned pixel and the Pixel Filter sampled (dx, dy).

Second Possibility: The Sampling Pattern sampled (x + dx, y + dy) in some pixel and the Pixel Filter sampled ( - dx, - dy).

These events have the same probability because all Sampling Patterns have uniform distribution and all Pixel Filters have a symmetrical distribution.

This means that both possibilities converge to the same image.

$\endgroup$
  • $\begingroup$ Thanks! That's interesting. Let me see if I understand correctly: using [a Sobol sampling pattern with a Gaussian pixel filter] is the same as using [a sampling pattern that is the convolution of a Sobol pattern with a Gaussian, and no pixel filter at all]. Is that right? Also, your answer tells me that the pixel filter is not applied in post-processing, but is, in fact, done when casting the rays. Right? $\endgroup$ – Daan Michiels Jul 29 '16 at 13:12
  • $\begingroup$ (And in that case, the sampling pattern and the pixel filter are in a sense the same procedure, namely sampling according to the convolution of the pattern and the filter.) $\endgroup$ – Daan Michiels Jul 29 '16 at 13:13
  • $\begingroup$ Yes, me to have just realized, that technically it is the same as using the Gaussian-Sobol convolution function as sampling pattern. During the whole sampling, you can see the noisy Gauss distributed white dots in the preview like in the images I attached. $\endgroup$ – Róbert László Páli Jul 29 '16 at 17:30
  • $\begingroup$ It is desired that the Sampling Pattern is uniformly distributed on the area of the pixel. I guess being able separately choose these two functions rather than from a huge list of all possible convolutions is better. Also, the common Pixel Filter functions are used in other type of renderers, where sampling is done over the whole image rather than pixel-by-pixel, and one sample really lits multiple pixels (the Pixel Filter is not stochastically sampled but fully calculated), like LuxRender. $\endgroup$ – Róbert László Páli Jul 29 '16 at 17:36
0
$\begingroup$

I am interested in the topic and I try to understand what you are saying about sampling and using Gaussian-Sobol convolution. If I get it right, number of points (x,y) are randomly sampled within the pixel using Sobol sampling, which is one of possible sampling patterns. They are traced, get some color value. I assume this value gets assigned to location (x+dx, y+dy) instead, where (dx,dy) - Gaussian noise. And this is called a pixel filter.

And if I am correct all samples within a pixel get combined using e.g. Gaussian weighting to get the final pixel value.

Now if you instead apply Gaussian noise to the location first and then trace (x+dx, y+dy) you won't get the same value. So I don't think you can combine these operations, unless you also average over samples outside the pixel when computing pixel values (and don't average over other stuff that got into your pixel from neighbouring ones). But maybe there are reasons to do it this way and not the "inverse" way. The inverse way samples that were dropped outside the pixel will get very low weights if also use Gaussian when combining them.

I am actually very new to this stuff, I think my answer is right, but sorry if I misunderstood something.

$\endgroup$
  • $\begingroup$ Yes and no: I also think that the Pixel Filter gets applied post sampling. But you should get the same result. I will explain this further soon. $\endgroup$ – Róbert László Páli Jul 29 '16 at 18:30
  • $\begingroup$ @Róbert László Páli, I added some information to my answer about the final pixel values. However, that's was a bit guessing, Blender internals is quite a mystery for me. $\endgroup$ – Noidea Jul 29 '16 at 18:39
  • $\begingroup$ I updated my answere with my reasoning why the convolution would work. $\endgroup$ – Róbert László Páli Jul 29 '16 at 19:45

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.