Unified Sampling

"Driller" from Transfromers 3: Dark of the Moon - rendered with unified sampling

For the layman, unified sampling is a new sampling pattern for mental ray which is much smarter than the older Anti-Aliasing (AA) sampling grid.  Unified is smarter because it will only take samples when and where it needs to.  This means less wasted sampling (especially with things like motion blur), faster render times, and an improved ability resolve fine details.

Technically speaking, unified is Quasi-Monte Carlo (QMC) sampling across both image space and time.  Sampling is stratified based on QMC patterns and internal error estimations (not just color contrast) that are calculated between both individual samples and pixels as a whole.  This allows unified to find and adaptively sample detail on a scale smaller than a pixel.

Advantages of unified sampling:

  • Fast ray traced motion blur.  Also motion blur should be smoother and require less memory.
  • Fast ray traced depth of field.
  • Better at picking up small geometry and detail.
  • A foundation for future rendering techniques and materials.

You SHOULD use unified sampling.  Here is how…

How to Enable Unified Sampling

Unified sampling is not exposed within Maya but can be enabled and with string options.

Enabling unified sampling

“unified sampling”

  • Enables or disables unified sampling.
  • boolean, defaults to false

Note: You should use “Raytracing” with regular and progressive unified, NOT the default of “Scanline” (Render Settings > Features > Primary Renderer).  This is because the scanline mode is old, deprecated, and none of the cool kids are using it.  Switching to raytracing from scanline can take minutes off your render while reducing memory usage.  Using “Rasterizer” with unified sampling enables the unified rasterizer.

Unified Controls

In addition to performance improvements, unified sampling simplifies the user experience by unifying the controls for various mental ray features including progressive rendering, iray, and even the rasterizer.  For regular unified and progressive unified, you basically just have one control that you need to consider: Quality.

“samples quality”

  • This is the slider to control image quality.  Increasing quality makes things look better but take longer.
  • It does this by adaptively increasing the sampling in regions of greater error (as determined by the internal error estimations mentioned before).
  • You can think of quality as a samples per error setting.
  • Render time increases logarithmically with “samples quality”.
  • Generally leave it somewhere between 0.5 (for fast preview) and 1.5.  1.0 is deemed “production quality”.  You can go higher (or lower) if the situations demands it.  Possibly values are 0.0 and above.
  • scalar, defaults to 1.0

Additional Controls

“samples min”

  • The minimum number of samples taken per pixel.
  • Set to 1.0.  Don’t change this unless you have a pretty gosh darn good reason.
  • Using a value less than 1.0 will allow undersampling.  This could be useful for fast previews.
  • This is only a limit.  Use “samples quality” to control image quality.
  • scalar, defaults to 1.0

“samples max”

  • A limit for the maximum number of samples taken per pixel.
  • The default setting of 100.0 will generally provide you with a large enough range of adaptivity for production work.  Some situations, such as extreme motion blur or depth of field, may require more than a hundred samples per pixel to reach the desired quality and to reduce unwanted noise.  Setting “samples max” to 200.0 or 300.0 in these situations can help.
  • This is only a limit.  Use “samples quality” to control image quality.
  • scalar, defaults to 100.0

“samples error cutoff”

  • Provides an error threshold for pixels that, when error falls below this value, mental ray will no longer consider.
  • This is only useful for scenes with very high quality values (like 3.0+) where areas of low error are still being sampled/considered.
  • In general, use “samples quality” as the sole method to control image quality and leave “samples error cutoff” at 0.0 (disabled).
  • If you choose to use this setting, set it to a very low value like 0.001.
  • scalar, defaults to 0.0

“samples per object”

  • Allows you to override “samples min” and “samples max” on the per object level.
  • If enabled, overrides are set under the mental ray section of each object’s shape node.
    • “Anti-aliasin Sampling Override” is the override switch
    • “Min Sample Level” sets “samples min”
    • “Max Sample Level” sets “samples max”
    • Note: these values have different meanings for unified sampling than they do for AA sampling.  i.e. a value of 3 corresponds to 3 samples per pixel, not 2^(3*2) = 32
  • boolean, defaults to false

Additional Notes

When unified sampling is enabled, mental ray will ignore certain settings:

  • The AA settings (ie min sample level, max sample level, anti-aliasing contrast) are ignored because you are now using the new unified sampling pattern.
  • Jitter is ignored because unified is inherently QMC jittered across image space.
  • With motion blur enabled, time samples/time contrast (these are the same setting) is ignored because unified is also QMC jittered across time.  You still need to set motion steps for motion blur.

Quality and error cutoff can be set to per color values for RGB. This is probably overkill for 99% of situations.  If you wish to control per color values, you can adjust the string options to look something like this:

  • “samples quality”, “1.0 1.0 1.0″, “color”
  • “samples error cutoff”, “0.0 0.0 0.0″, “color”

About bnrayner

I am a VFX developer specializing in 3d rendering. With a background in Physics and Digital Art, I enjoying using math to explain how light interacts with materials and to creating pretty pictures along the way.

Posted on October 31, 2011, in maya, unified sampling and tagged , , . Bookmark the permalink. 17 Comments.

  1. FFfffff Yeah!

    I’m so there… Thanks guys!

  2. good article and great site,
    but pls cutout all the recommendations for sampling values, like 100 for max sampling, or that 1,5 quality means production quality.
    try to render mb or dof or glossis then you will see that none of these values are enough to render good quality. for example, a value of 10 for strong dof is easily a must to get rid of all the sampling artifacts. glossis are also a different thing in combination with dof or mb, 100 as max are to low, 200 or 300 as max is normal here.

    but if you get good quality out of your settings, pls show some examples here.
    would be also great to know what settings ilm used for the driller, cant imagine, but they must be insanely high. ;)

    • Hi Kzin.

      The values we are talking about are values that have been used for some of the productions we have been a part of or have direct knowledge of. So these are based on actual finished products. Also, during down time, jobs are sent to the farm to test different features and methods. This means we can leverage hundreds of machines to run iterations over and over again until we find a setting we like. This doesn’t mean that all settings work for every scene. But they are a good place to start. The alternative is to simply not comment on the settings we have used and let you find your own, but that’s not very helpful as a starting place is it?

      We will be posting some examples here too. Just takes awhile to get assets that can be shared. We spend 11 hours a day on things we can’t take home. :-) And assets generated by plug-ins like Onyx Tree are also forbidden to share.

      To tune a scene for a completely artifact-free still image will indeed take some time. But we are focused on VFX here which has different sensibilities. A lot of the projects we work on are designed to match a filmed plate (either film or digital) which means there is inherit grain we must match. So to render a frame that has no grain and then re-grain it is wasted time (many of these are re-matched to the grain automatically by an artist). The vast majority of what you see in a film is grainy. But you don’t see it because it’s in motion. Perceptually this detail is lost. We also find that people tend to enhance their motion blur to levels that are not realistic by multiplying it. This might look “cool” but the motion trail isn’t correct. When matching for filmed elements it’s generally much shorter than most people realize.

      As for ILM, I believe their Quality with Unified was set to 3.0 to ensure that they caught all the tiny debris in the shot. In a scene where I may not have tiny parts of buildings flying around I can get away with less. Just to illustrate. I do not have hard numbers on their samples settings.

  3. thanks david,
    yes, film is different because of the noise (and there can be alot of it, deathly hollows for example, of course its film noise, so its not that bad ;) ).
    i could not believe the driller was rendered with mr, thought that ilm uses renderman only at the moment for their hero shots.
    i did some tests with unified in the last couple of days, its way better then adaptive in terms of detail catching and rendertimes.
    i think the problem was that i tryed to render smooth dof and this is nerly impossible with good rendertimes (as i wrote in another forum, looks like unified and dof bokeh shader are “disconnected” at the moment?). mb is the opposite because you can get clean results with comparable good rendertimes. so i hope dof will also benefit from unified in the near future.

    i did a test yesterday with unified and mb, can be seen here:
    http://s7.directupload.net/file/d/2718/rb6zfees_jpg.htm

    rendertime is not that bad for all the sampling in the scene and its clean, i think cleaner as you would need it for film.

    • The aspect of new features that many people miss is that there is a law of diminishing returns for features. Each feature has a different threshold. Newer features tend to extend that threshold to favor more complex scenes and effects that were previously prohibitive. Something I will go over later in more detail, but simply put: To achieve the same level of quality in a complex scene with regular adaptive rendering (AA) should take longer than using Unified Sampling (all else being equal).

      So to get a similar frame in something complex from regular AA will be more expensive than Unified Sampling.

      Another example is running FG with a complex lighting setup. You will get a lot of disco ball effects that are hard to clean up. Use Irradiance Particles that are “slower” and you end up with a correct result immediately. To clear up that variance in FG would take longer to do than using IP. So your “better” original method is now too difficult to use in something more advanced.

      The bokeh shader is indeed compatible with Unified Sampling. To get an idea of what kind of DOF you need, make the bokeh samples ’1′ and render with Unified Sampling and Progressive “on”. Do not use the progressive controls, just set Unified Sampling Controls to your guesstimated Quality and max samples and Progressive “on” and render. Lower the local sampling on objects in the area of most confusion (blurriness) since there will be no or little detail (things like glossy rays, occlusion rays, etc.) Then render. The first pass should be fairly quick and give you a rough idea of what the image will look like when converged. DOF is expensive, but it should be less expensive in Unified Sampling than regular AA.

      I will explain more of this later with images, settings, and diagnostics (very helpful diagnostics come with Unified Sampling by the way.) Hopefully in the next week or so I can generate a post with Unified Sampling explanations in a visual context.

      Log in to the ARC forum and look here: http://forum.mentalimages.com/showthread.php?8296-Mental-Images-User-Group-Gallery&p=36025#post36025

      The lighting was partially brute force (builtin IBL) Glossy reflection and SSS.

      • unified does a better job. in my little example all local sample values are set to 1.
        its the best way to render gloosis and area lights.
        glossis are the best way to show what unified can do because of the better detail catching. its not possible to catch the details with adaptive, you would end up with 256 or 512 local glossi rays which would slow down the rendering alot.

        i will try the progressive mode, i avoid this normally because there is no framebuffer support, or is this different with unifed progressive (did not test this combination)?

      • Progressive isn’t meant for final renders, it’s a way for you to tune and test your scene. Once it’s where you want it to be, turn Progressive “off” and render. The Unified Controls will mean you should get a similar quality but now your renders will contain your passes, etc.

      • Hey Kzin,

        I have an idea why we have different expectations of Quality. In many cases I have not completely abandoned the original ways of using local samples. I have decreased them for Unified Sampling but not dropped them to ’1′ for everything. This is because local samples have an added efficiency in many cases like soft shadows.

        However, in your scenario where everything is set to ’1′ you will not only need more Quality, but you will need more samples as well. If previously a pixel was taking 5 samples and the shader sent 64 reflection rays each time, then I had 320 rays generated (assuming no additional ones were spawned by struck objects). Now, at local samples ’1′ I would need about 320 samples from Unified Sampling (actually, less but I’ll get to that). Since the default “samples max” is set to 100, your result was unsatisfactory. You would indeed need more than that.

        I will cover more of this in a post I am working on right now. But your explanation of what you were doing made a little light go on in my head. You’re somewhat further ahead of the game than I originally thought. ;-) It’s a shame we aren’t using BSDF yet because your expectation would have been spot on.

        Thanks!

  4. Hi Kzin,

    Thanks for your comments! I have adjusted my recommendations to accommodate greater quality and max samples for situations that produce a lot of noise. Still, I feel the the ranges I have provided are an excellent place to being :)

  5. @David:
    after some more deeply tests with unified i think its a good way to set local sampling to 1 and let unified do the rest. you wrote in some posts in the arc forum that unified dont need a lot local sampling and in my early test i did the same experience.
    but some time ago, as vray open beta starts for xsi some comparisions shows that dof rendering is alot more complicated to solve in mr then in vray. so i started to do some more tests. and here i got a problem (and thats because i thought dof is not connected with unified). if you increase local sampling for dof, but render with unified, you suffer alot of rendertime compared to 1 dof sample and high unified settings. the same for strong diffuse reflections, its better to let unified all the sampling because the local sampling gives you not the same details as high unified sample rates. if you use local glossi samples in the mia_mat, it looks like mr is not using the unified that resolves more details, it looks like mr uses the old “adaptive” aa that cannot solve the same details like unified and this ends up in way to noisy reflections (dont know how i should describe it in another way).

    so with higher local samples i could not get clean results with the settings you suggested and beause of this i came up to use only 1 sample for all local effects and it worked quite good. another sideeffect of this is that you dont need to tune local samples until the noisequality is good enough, you only set the min/max and thats it. the idea comes indeed from bsdf, yes, because there is no local sampling here which makes things alot easier.

    @bnrayner:
    i wrote this because the sampling of unifed is a bit different and alot of people want to get clean, noisefree results, especially in comparision with other renderers. if they use “only” 100 samples as max and they dont get that clean results then you might get the typical “new feature with bad quality” postings all around. ;)
    and because of this, of course not only of this, the site and its intention is great.

  6. Hi and thanks for your blog.

    I’ve made a script to add string options:

    http://forums.cgsociety.org/showthread.php?t=971719

    I think it’s easier.

    Hope this can help. :)

    Regards,

    Dorian

  7. hi master thanks for the support…
    one question…
    so as i understand i need to change manually one per one the settings in my materials and lights???? Unified doesnt override theirs sample values as do with AA and jitter????
    and finally, unified works with IP, IBL and importons settings?? it works in DBR or backburner mode???
    thanks and congratulations for your great work.

    • For shader settings you can either change them manually or you can script it. In some cases you can alter the .mi include file where some default values are found and it will be permanent when you start up Maya.

      Unified Sampling does not directly alter samples of anything. It simply samples the image in a smarter way. It is also naturally jittered from the QMC pattern.

      It works will all of the indirect lighting methods and in fact makes it easier to use brute force indirect lighting for high quality frames. It should also work with Backburner once it’s saved in the scene file.

      For now Unified Sampling is NOT supported for DBR (distributed rendering per tile).

      • Great tip.. override the .mi file
        I make a test in a production work but i obtain bad results… a lot of noise… the same scene without unified have cool glossiness reflection…
        Rendertime was: with unified 57min , without unified and higher values in samples 1:30h
        My scene is in 3dsmax design 2012-64bits and i use mr option manager script to available unified, ibl, importons and ip.
        My workflow is the same as i read in the post and comments… put 1 in samples values for glossiness in all my material, for ibl,ip and importons i leave the defaults values..
        I will try with other scenes and then post my results.

  1. Pingback: Linear Color Workflow(s) in Maya « elemental ray

  2. Pingback: Linear Color Workflow(s) in Maya – Part 2: The Preferred Method « elemental ray

  3. Pingback: Unified Sampling – Visually for the Artist « elemental ray

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 49 other followers