Brazil Sampling Settings for Real Life


Sampling creates an approximation of a continuous data source by taking measurements at specific intervals.

Since when rendering an image, we cannot represent details smaller than one pixel, the solution for measuring the color of the pixel is to measure the color at the center of every pixel in the rendering and then to assume that this color is a reasonable average for the entire pixel.

In the illustration, the pink rings represent the 2-D projection of our continuous 3-D model. The dots represent the samples. Notice that the samples are not perfectly aligned in a grid. This prevents unwanted aliasing artifacts of vertical and horizontal lines that frequently occur in CG.

Assuming that every sample is near the pixel center, samples that intersect the rings is rendered black, and samples that do not intersect a ring are rendered red. The illustration shows a rendered image based on these samples.

This is not a very good approximation: large areas of white have been filled with black and large areas of pink are still visible.

One possible solution to the problem is to shorten the interval of our samples and measure four points instead of only one. This solution is a good one, but unfortunately the number of samples increases with the square of the accuracy gain. This means that it takes longer and longer to compute the whole image as we increase the accuracy. 

Note: These images images show a jittered-stratified grid, whereas Brazil actually uses a low-discrepancy best-candidate sampling.

One solution is to use an adaptive sampling algorithm that introduces additional samples only when an increase in accuracy is expected to pay off.

For example, if sample A intersects the pink rings, but its neighbor B does not, we can safely assume that the ring ends somewhere between A and B. We can then sample a few more times between A and B to increase our local accuracy.

This results in a more accurate approximation of the continuous input without doubling the number of samples. However, the thin lower part of the left ring is still ignored because it fell between two samples during the first pass. So it was not known that there was something there.

This is a common problem with renderers that use adaptive sampling. The only way to solve it is to increase the accuracy of the initial pass.





Brazil sampling controls

Brazil offers settings to control the sampling behavior. You can set the minimum and maximum sampling accuracy of a rendering. These numbers are integers and they indicate the exponent of the number of samples per pixel.

Samples per pixel




One sample every 8 pixels

Extreme low quality, very blurry



One sample every 4 pixels

Very low quality, useful for judging lighting conditions across a rendering



One sample every 2 pixels

Low quality, useful for judging local lighting conditions, good for previews



One sample every pixel

This effectively removes any anti-aliasing artifacts from the image



Two samples every pixel

Lowest anti-aliasing value, lines will still be fairly jagged



Four samples every pixel

Pretty good anti-aliasing, especially on low-contract thresholds



Eight samples every pixel

Very good anti-aliasing, only use higher settings to counter sampling artifacts


Take a closer look at how minimum and maximum resolution cooperate to give high-quality images in a reasonable amount of time. The following images are  renderings from a scene that contains a simple plane with a procedural texture. The procedural texture ensures that the lines will never become pixelated. The maximum sampling resolution for each image is +3 (8 samples per pixel). Our eyes cannot distinguish a higher quality, although Brazil can sample up to 256 points per pixel.

{-3, +3}

{-2, +3}

{-1, +3}

{0, +3}

{+1, +3}

{+2, +3}

The potential quality of the rendering is very high, but there are major sampling artifacts when we begin with a low-quality sampling resolution. As the first image shows, Brazil is trashing about like a headless chicken when it is not allowed to perform an accurate enough initial sampling pass. The result is very anti-aliased (because of the +3 maximum sampling) but the super-pixel elements are all messed up. When we start to increase the minimum quality, the moire patterns start to disappear and the image becomes more and more accurate. At {+1, +3} we finally have a completely accurate representation of our texture. {+1, +3} is a relatively high sampling resolution, though you should expect to use similar domains for any production quality rendering. Since the black stripes become very thin in the top half of the rendering (they become thinner than a single pixel), we need multiple samples per pixel for the minimum sampling resolution for Brazil to detect them as continuous entities.

Adaptive filters

Since you can specify two different sampling resolutions in Brazil, you also have to specify when you want to use the more accurate one. By default, Brazil will sample the whole image at the lowest sampling resolution, then refine (adaptive sampling) the sample grid whenever two neighboring samples meet the specified threshold settings. Assume we have a simple scene with two objects - a groundplane and a single light source plus skylight. If we set the minimum sampling resolution to -2 (one sample every 4 pixels) and the maximum to 2 (four samples per pixel) we can expect the following results without adaptive sampling.

The entire image is sampled at -2 resolution.

The entire image is sampled at +2 resolution.



Four options specify adaptive thresholds:

  • Object Edge
  • Normal
  • Z-Depth
  • Contrast
Object Edge

When sample A intersects the groundplane, and the neighboring sample B intersects the blue glass, we know that somewhere between these there must be a transition from groundplane to glass. We can use such a threshold to trigger a refinement event. In the resulting image, the edges are smooth, but all the sharp lines on the interior of the glasses are still chunky and rough.

All the pixels (red) where the Object Edge refinement was performed.

The resulting image.


Surface Normal

Instead of checking for different objects, the Normal adaption compares the surface normal vectors of samples A and B. If these differ sufficiently, a refinement event is triggered. This refinement algorithm found the near edge of the green glass, but it was unable to pick up on the far edge. Since the top edge of a glass is fairly level, the normal vectors all point upwards. Since the groundplane also has vertical normals, there was insufficient difference. It is already clear that Object Edge and Normal refinement complement each other.

All the pixels (red) where the Normal refinement was performed.

The resulting image.




Another geometric property that can be evaluated is the difference in distance between |Camera, A| and |Camera, B|. When sample A is very close and B is very far, it is probably safe to assume there is a lot happening between them. The image on the left already shows the weaknesses of this approach. Near tangent surfaces (such as the upper half of the groundplane) are easily tagged, even though this is a completely pointless refinement in this case.

All the pixels (red) where Z-Depth refinement was performed.

The resulting image.



Contrast adaptation relies on the results of the first (coarse) sampling pass and then refines based on relative contrast between adjacent samples. This is the only non-geometric filter. It is probably the most useful filter in Brazil sampling. Contrast refinement found almost all sharp edges in the rendering, with the exception of the transition between the blue glass and the shadow.

All the pixels (red) where Contrast refinement was performed.

The resulting image.


Grand Finale...

If we combine all four filters we get an overlay of refinement grids. The Z-Depth refinement does not contribute greatly in this case and could have been left out.  None of the filters found sufficient difference on the interior of the shadow field. Contrast tagged a few pixels, but not enough to sample the entire gradient at a higher resolution. As a result the resultion of the interior of the shadow is -2 which is coarse enough to see the noise of the skylight. We either have to fine-tune the contrast filter to be more sensitive (picking a contrast threshold color closer to black) or increase the resolution of the minimum sample density.

This page discusses the topic of Sampling in the Brazil render engine, sampling in general and guidelines for proper setups.

All four filters applied.

The resulting image.

Views: 910


You need to be a member of Brazil for Rhino to add comments!

Join Brazil for Rhino


  • Add Videos
  • View All


© 2022   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service