Maya 2012 Unified Sampling in mental ray


#1

Unified is QMC sampling across the image space. Unlike regular AA
where the pattern is somewhat like a grid, Unified is stratified based
on an optimal distance between samples that are moved based on QMC
patterns and an error estimation instead of just color contrast. This
means you can render small geometry like hair and fur using raytrace
instead of rasterizer with good results. The samples will catch
geometry smaller than a pixel generally with smaller sample
levels internally.

It also solves noise problems by generating its own adaptive grain. So
now depth of field and raytraced motion blur are faster to render and much
smoother.
(Sidenote: spinning chrome sphere’s should no longer blur
reflections.) You can render raytraced motion blur. Motion blur is now
visually adaptive. You can ignore time samples under Unified. Areas of
low detail and flat color still receive minimum samples regardless of
blur amount. Memory usage for motion blur is now a fraction of the
original amount.

Three main controls:

samples min = the minimum samples used per pixel (values lower than 1.
will under sample) These are not a power function like regular AA. It’s literal.
samples max = the maximum samples used per pixel
samples quality = the Unified control knob. More is better. Generally
1.0 is considered production quality. I occasionally have to go higher, 2 or 3
depending on noise/small details. 0.3ish is good for previews.

If you find motion blur or depth of field are grainy, increase max
samples. But for most things you can increase the quality knob and
leave your samples wide.

The Quality knob is now your control for rendering!

Basically: Set a set of sampling limits and then simply use Quality to make it look better.
You can use the diagnostics to see how/where your sampling is happening and make
decisions from there. Diagnostics are embedded into an EXR in different channels so
you still get your render unlike before.

Other controls:

sample error cutoff = when to stop sampling. Special cases where dark
areas can be ignored. This is a color threshold. Higher values begin
to tell the renderer to ignore lighter areas in the image as you
increase it. (Importance) It’s very sensitive, rarely used.
samples per object = Object tags for sampling override. Same as
previous versions except the amount is literal. 1 3 means minimum 1
and maximum of 3 samples. It’s not a power (4 min and 64 max at those
settings before).

Unified also controls the Rasterizer (Hence Unified’s name).
samples max = visibility samples
and quality is shading rate.
You should find that you do not need the Rasterizer nearly as often or at all.

Also, turn off Scanline. This is a performance consideration. Scanline
On will slow you down and shouldn’t be the default in Maya. There are
also three helpful new image diagnostics layered into the EXR when
rendering if you select “diagnose samples”. These are: estimated color
error per channel, samples per pixel (literal number when you mouse
over it), and pixel time to render (also literal time in seconds) More on this
can be explained later.

Here is the mel to insert the string options:

select miDefaultOptions;
int $idx = getAttr -size miDefaultOptions.stringOptions;
setAttr -type “string” miDefaultOptions.stringOptions[$idx].name
“unified sampling”;
setAttr -type “string” miDefaultOptions.stringOptions[$idx].value “on”;
setAttr -type “string” miDefaultOptions.stringOptions[$idx].type “boolean”;
$idx = getAttr -size miDefaultOptions.stringOptions;
setAttr -type “string” miDefaultOptions.stringOptions[$idx].name “samples min”;
setAttr -type “string” miDefaultOptions.stringOptions[$idx].value “1.”;
setAttr -type “string” miDefaultOptions.stringOptions[$idx].type “float”;
$idx = getAttr -size miDefaultOptions.stringOptions;
setAttr -type “string” miDefaultOptions.stringOptions[$idx].name “samples max”;
setAttr -type “string” miDefaultOptions.stringOptions[$idx].value “100.”;
setAttr -type “string” miDefaultOptions.stringOptions[$idx].type “float”;
$idx = getAttr -size miDefaultOptions.stringOptions;
setAttr -type “string” miDefaultOptions.stringOptions[$idx].name
“samples quality”;
setAttr -type “string” miDefaultOptions.stringOptions[$idx].value “0.3”;
setAttr -type “string” miDefaultOptions.stringOptions[$idx].type “scalar”;
$idx = getAttr -size miDefaultOptions.stringOptions;
setAttr -type “string” miDefaultOptions.stringOptions[$idx].name
“sample error cutoff”;
setAttr -type “string” miDefaultOptions.stringOptions[$idx].value “0 0 0”;
setAttr -type “string” miDefaultOptions.stringOptions[$idx].type “color”;
$idx = getAttr -size miDefaultOptions.stringOptions;
setAttr -type “string” miDefaultOptions.stringOptions[$idx].name
“samples per object”;
setAttr -type “string” miDefaultOptions.stringOptions[$idx].value “off”;
setAttr -type “string” miDefaultOptions.stringOptions[$idx].type “boolean”;

Technically “samples quality” is a color, but for most things making
it three values will be overkill.

Caveats: This is a first implementation and I find it is great for most things. You may
find that hard edges are not as defined as you’d like if you do Arch Viz. This is something
that has already been mentioned for improvement. Like anything else I expect continued refinement.


#2

This is good news for mentalray. Would you say this is similar to V-Ray’s DMC sampler ? it sure sounds like it.


#3

This previous post now has new results:

Why you should use Raytrace only

In mental ray 3.9 the results are:

Raytrace in 3.9:

RC 0.8 info : wallclock 0:13:16.14 for rendering
RC 0.8 info : allocated 642 MB, max resident 893 MB
GAPM 0.8 info : triangle count (including retessellation) : 16610880

Original Raytrace:

RC 0.10 info : wallclock 0:50:31.24 for rendering
RC 0.10 info : allocated 1092 MB, max resident 8963 MB
GAPM 0.10 info : triangle count (including retessellation) : 16610880


#4

This is good news for mentalray. Would you say this is similar to V-Ray’s DMC sampler ? it sure sounds like it.

It is and it isn’t. The criteria and stratification are different than V-rays DMC.

For those of you that enjoyed Progressive’s ability to resolve glossiness, etc, you will find Unified is similar if not better than that.

Unified is not exposed in Maya, hence the mel above. XSI already announced it will be exposed for its use in the Autodesk products.


#5

Awesome!,
thanks for the heads up Bitter :), this is exciting stuff for mentalray, can’t wait.


#6

That is a GIGANTIC difference !
Please excuse my ignorance but is there some more I can read about this, and this usable for animations ? (I haven’t used MR for a while :argh: )


#7

The technical side of the information exists in the documentation for mental ray 3.9. This is included with Maya.

Areas to look at: “What’s New” and “Release Notes”

If you want more technical information on how Unified Raytracing operates then you can find a few things floating around from their Chief Scientist, Alexander Keller


#8

This is great information. I look forward to trying out these new features once I can get a hold of 2012!


#9

Additionally, thought I’d point out where the diagnostic.exr goes:

project/maya/renderData/mentalray/

Seems Maya doesn’t know about it when it’s created. Super. But I’m not on a final release yet.

*Edit: keep forgetting to mention, the images for samples and time use a literal value for ‘S’. This means that samples min of 1 generates a white frame that hides the higher values, say samples max of 64, etc. You must lower your exposure to see the image represented. In imf_disp a good average value is -5.0 Then mouse over the image and the reading for S is the literal value for samples for that pixel. The same for the time buffer that reads in seconds per pixel. Now you have an idea of where the most time is being taken specifically.


#10

Sorry for the stupid question, everyone else seem to get it working fine.

I introduced the mel, but I can’t find the unified controls anywhere!
Where are those supposed to be?


#11

No problem.

It places the controls in miDefaultOptions under the String Options rollout. You can select the miDefaultOptions by going to the quick select box at the top menu bar, change it to select by name and type: miD* and hit enter.


#12

Well thank you sir, though I just doubled my render times with this! lol
I’ll have some good quality testing with the parameters and get back with results.
Thank you.


#13

hey Bitter this works with OSX do you know? thx


#14

I notice a lot of people are increasing their minimum samples. Don’t, keep them 1 or 2.

Max samples can probably be reduced from 64 in a lot of cases.

Also, for trivial scenes this may indeed increase render times because Unified is doing more work in the background resolving details. You will find the best performance is the more complex scenes. I can reduce render time and time spent tweaking much more as complexity increases.


#15

This should work in any version of Maya 2012. It’s a feature of mental ray 3.9 that’s software related and not hardware (a la iRay)


#16

Just: :bowdown:

Thank a lot for this thread!


#17

David I apologize for rambling throughout your thread, to post a few tests using the new Mental Ray 3.9 “Unified Sampling” String Options controls…!

But first I would like to draw your attention on the decimal point operator syntax, used in the Mental Ray 3.9 “Unified Sampling” String Options controls…

Posted at the start, of this very informative thread.

Looking at the String Options posted at the start of the thread, I was baffled by the decimal point operator input values syntax…

Since that I never used before this kind of syntax, for the mental Ray String Options input value fields.

Please correct me if I’m wrong… but I guess the correct syntax used for the mental Ray String Options input value fields, should be as follows:

select miDefaultOptions;
int $idx = getAttr -size miDefaultOptions.stringOptions;
setAttr -type “string” miDefaultOptions.stringOptions[$idx].name
“unified sampling”;
setAttr -type “string” miDefaultOptions.stringOptions[$idx].value “on”;
setAttr -type “string” miDefaultOptions.stringOptions[$idx].type “boolean”;
$idx = getAttr -size miDefaultOptions.stringOptions;
setAttr -type “string” miDefaultOptions.stringOptions[$idx].name “samples min”;
setAttr -type “string” miDefaultOptions.stringOptions[$idx].value “1.0”;
setAttr -type “string” miDefaultOptions.stringOptions[$idx].type “float”;
$idx = getAttr -size miDefaultOptions.stringOptions;
setAttr -type “string” miDefaultOptions.stringOptions[$idx].name “samples max”;
setAttr -type “string” miDefaultOptions.stringOptions[$idx].value “64”;
setAttr -type “string” miDefaultOptions.stringOptions[$idx].type “float”;
$idx = getAttr -size miDefaultOptions.stringOptions;
setAttr -type “string” miDefaultOptions.stringOptions[$idx].name
“samples quality”;
setAttr -type “string” miDefaultOptions.stringOptions[$idx].value “0.5”;
setAttr -type “string” miDefaultOptions.stringOptions[$idx].type “scalar”;
$idx = getAttr -size miDefaultOptions.stringOptions;
setAttr -type “string” miDefaultOptions.stringOptions[$idx].name
“sample error cutoff”;
setAttr -type “string” miDefaultOptions.stringOptions[$idx].value “0 0 0”;
setAttr -type “string” miDefaultOptions.stringOptions[$idx].type “color”;
$idx = getAttr -size miDefaultOptions.stringOptions;
setAttr -type “string” miDefaultOptions.stringOptions[$idx].name
“samples per object”;
setAttr -type “string” miDefaultOptions.stringOptions[$idx].value “off”;
setAttr -type “string” miDefaultOptions.stringOptions[$idx].type “boolean”;

Before to go to the point, a few pics to show what the Mental Ray 3.9 “Unified Sampling” String Options controls actually does…

The render image output with the (IBL) Environment Lighting String Options, used in conjunction to the new Mental Ray 3.9 “Unified Sampling” String Options controls.

With the three main “Unified Sampling” String Options controls, set a follows:

samples min = (1.0)

samples max = (64)

samples quality = (0.5)

Notice that the “High Samples” input value field located under the “mental ray/Area Light” subsection of the “areaLightShape1” tab, is set to the default input value (8.0).

The “areaLight1” node is a native Mental Ray “Area Light” light node with the “mia_portal_light1” light shader, connected to both the “Light Shader” and the “Photon Emitter” fields.

The (PR) Progressive Rendering String Options are disabled since that using the (PR) Progressive Rendering String Options, in conjunction to the new Mental Ray 3.9 “Unified Sampling” String Options controls…

Will cause the Mental Ray render engine algorithm to stop the sampling at subframe (1), hence disabling the new Mental Ray 3.9 “Unified Sampling” String Options controls as well.

The render image output with the (IBL) Environment Lighting String Options, used in conjunction to the new Mental Ray 3.9 “Unified Sampling” String Options controls.

With the three main “Unified Sampling” String Options controls, set a follows:

samples min = (1.0)

samples max = (64)

samples quality = (1.0)

Notice that the “High Samples” input value field, located under the “mental ray/Area Light” subsection of the “areaLightShape1” tab, is still set to the default input value (8.0).

The render image output with the (IBL) Environment Lighting String Options, used in conjunction to the new Mental Ray 3.9 “Unified Sampling” String Options controls.

With the three main “Unified Sampling” String Options controls, set a follows:

samples min = (1.0)

samples max = (64)

samples quality = (1.0)

Notice that the “High Samples” input value field, located under the “mental ray/Area Light” subsection of the “areaLightShape1” tab, is increased to the input value (64).

Notice the increased general samples interpolation “sharpness” displayed by the second and the third image, which is provided by the “samples quality” String Options control…

Increased to the input value (1.0) as well as the native Mental Ray “areaLight1” light node “High Samples” input value field, increased to the input value (64).

A few screenshots with the “Unified Sampling” String Options controls, used with the decimal point operator syntax posted at the start of this thread:

samples min = (1.)

samples max = (64.)

samples quality = (1.)

The Mental Ray 3.9 “Unified Sampling”, String Options controls settings:

Link to the high rez version:

http://www.samui3d.com/CGTALK/WRONG.jpg

The render image output:

Link to the high rez version:

http://www.samui3d.com/CGTALK/WRONG_SINTAX_1.44.jpg

As well as a few screenshots with the “Unified Sampling” String Options controls, using the “standard” decimal point operator syntax:

samples min = (1.0)

samples max = (64)

samples quality = (1.0)

The Mental Ray 3.9 “Unified Sampling”, String Options controls settings:

Link to the high rez version:

http://www.samui3d.com/CGTALK/CORRECT.jpg

The render image output:

Link to the high rez version:

http://www.samui3d.com/CGTALK/CORRECT_SINTAX_1.59.jpg

Notice the difference between the samples interpolation displayed by the first test using the “Unified Sampling” String Options controls, posted at the start of this thread…

And the second test using the “standard” decimal point operator syntax, as well as an increase in render times…

It seems that by using a different syntax for the “Unified Sampling” String Options controls, there are difference in the render times as well as in the way the general samples interpolation are computed…

Even if in the “Progress” or “Detailed” messages displayed by the “Output Window” panel, the “Unified Sampling” String Options controls are enabled using the same syntax…

Btw… I have enclosed a copy of the “Output Window” panel “Detailed” messages, output by the Mental Ray render engine algorithm.

http://www.samui3d.com/CGTALK/THE_UNIFIED_SAMPLING_OUTPUT_WINDOW_DETAIL_MESSAGES.rar

Seems to me that one of the above mentioned decimal point operator syntaxes, disables the “Unified Sampling” String Options controls and automatically defaults to the standard “Adaptive Sampling” sampling mode algorithm…

For these tests as the “Primary Renderer” I used the “Raytracing” option, located under the main “Render Settings” panel “Features” tab…

Hope it helps…!

Ciao.

PS. David the main point of my rambling was mostly to expose this weird behavior, displayed by the new Mental Ray 3.9 “Unified Sampling” String Options controls…

Guess they are still not fully implemented…!:smiley:

Btw… I quoted your extremely throughout description of these new Mental Ray 3.9 features in the tutorial guide, hope you don’t mind…!


#18

Hi withego,

Technically the reason for the syntax is how it is exported to mental ray. In order to be as efficient as possible, export of scalar or float values will ignore anything after the decimal if it is 0. So, for example: 64.0 becomes 64. in the .mi file.

The other reason Unified uses a decimal (scalar) value instead of an integer is because it can undersample pixels. “samples min” 0.25 means one sample for every 4 pixels.

So you can still do quick undersampled previews like the original adaptive sampler: -2 0 etc.

When exporting a scene without decimals I get this in the .mi file:

"rast useopacity" on 
"samples max" 100. 
"samples min" 1. 
"samples quality" 0.5 
"shadowmap pixel samples" 3 
"unified sampling" on

When exporting with decimals I get this:

"rast useopacity" on 
"samples max" 100. 
"samples min" 1. 
"samples quality" 0.5 
"shadowmap pixel samples" 3 
"unified sampling" on

The “scalar” setting identifies how the value is to be exported. So omitting a decimal point shouldn’t make a difference. I don’t know the exact cause of your render time difference because mental ray should see the values the same way. In order to export just “64” I would need to set the value type to integer.

This is actually a bug with the progressive renderer. It was designed to work with samples = 1 but the criteria to make it progress beyond that didn’t work. It has since been fixed. In this version of mental ray, Progressive has a different sampling pattern from Unified.

Also, if you haven’t changed your filter settings in the render globals, it will still export Box.

You have a guide somewhere? Didn’t see it on your site.


#19

Thought I’d give a better explanation of error control with Unified and raytracing.

The follow images show an increase in the quality parameter from 0.25 -> 0.75 -> 1.5

You’ll notice how the perceived error decreases with each increase in Quality. Areas with the most error are eroded away first. You can see individual color error by looking at each channel (RGB).

0.25

0.75

1.5

You can find a complete diagnostic.exr of quality 1.5 here:

diagnostic.exr

This has all 4 layers included. You can open this with imf_disp to view the layers. For the “samples” layer you should decrease the exposure to -5.0 to see the image. Then mouse-over the pixels to get a value for samples taken (S) This is similar to the time layer where S = seconds per pixel.

Not counting the FG process phase, the render takes Just under 11 minutes for a 1280x720 frame at Quality 1.5 I’m using BSDF shaders with glossiness (you can see it best on desks and on paint near the ceiling).

RC   0.3  info : rendering statistics
RC   0.3  info :   type                           number   per eye ray
RC   0.3  info :   eye rays                      4618306          1.00
RC   0.3  info :   transparent rays                63490          0.01
RC   0.3  info :   reflection rays              30493569          6.60
RC   0.3  info :   shadow rays                 335052362         72.55
RC   0.3  info :   fg points interpolated       33898517          7.34
RC   0.3  info : on average 65.38 finalgather points used per interpolation
RC   0.3  info : wallclock  0:10:30.95 for rendering
RC   0.3  info : allocated 124 MB, max resident 166 MB
GAPM 0.3  info : triangle count (including retessellation) :      247606

The biggest time-eater are the shadow rays, 72.55 per eye ray is the more expensive feature. I have portal lights in the windows (4) with a High Samples of only 16. I still get a clean render with just 16 high samples. I have some FG blotches but that’s easy to take care of.


#20

Undersample with Unified:

samples min 0.1
samples max 1.
samples quality 0.1

You can play with these however you like. My minimum now samples once every 10 pixels with a maximum of 1 sample per pixel. I can increase the maximum but it may trigger more samples if my quality increases as well.