Jump to content

Mantra Sampling, infos needed


Recommended Posts

Hi everyone

In fact my purpose of this post is to try to understand more about sampling in mantra. this post will be a little bit long so please bear with me.

(please also correct me if i'm wrong in anything i'm saying)

let me begin with MP, main two parameters here are : pixel samples, and dicing. so mainly dicing will keep dividing our polygons till each micropolygon gets smaller than 1 pixel (unless we ask for dicing more than 1), then the shader will be evaluated 4 times 1 for each corner of our micropolygon, and here we will randomly take (pixelSamplesX * pixelSamplesY) samples on that micropolygon, the result of each is an interpolation (unless we tell mantra not to interpolate), then we average the samples to get the result by filtering it with a gaussian 2 2 or anything else we specify.

now Raytracing, the objects in the scene won't be diced unless mantra doesn't know how to raytrace them natively (so if it doesn't the object in question will be diced just like for the MP), then the raytracer will send (pixelSamplesX * pixelSamplesY) for each pixel and with each sent ray it will evaluate the shader (so more shader calls then for MP, unless we have a very high polys model showing very small in our frame since MP can't join polygons), then we average the samples to get the result by filtering it also like for the MP.

am i right up untill now ?

so here comes the first question, in all I said I can not see anything about "ray samples" or "shading quality" or "ray shading quality" so where do those parameters come into play, and what are they ?

so Please any clarification about all this sampling subject would be very appreciated.

and here comes why all that began, let us assume i'm rendering with the raytracer, what values would be "acceptable" to get a final good render with the least render time? (because my tests up untill now, always gives me over killing render times for a good quality render) (one example of my tests, is an HD size render with GI - 5x5 pixel samples and 256 samples for the vex gi, which takes like 8 hours render time (quad core 2.66, 3GB RAM) and still it has noise in it ! i tried getting rid of that noise using irradiance caching to smooth things out, but even with 0.01 error and 3 max pixels spacing i'm still getting blotchiness on some of my objects)

is there any specific workflow or .. way of thinking ... or dunno any help that you can give me regarding those subjects ?

my last question for this post is : "does every render parameter work on object basis?" and what i mean by that is that for example if I turn on the irradince caching in my output driver, then on one of my objects i add the irradiance parameters and turn it off will it work this way?will it be off only for this object? same goes for pixel samples for example if i add it on object basis ...

Sorry again for this long post, I hope you cold help me understand Mantra better, and hope this thread will be also usefull to other persons who are also wanting to get the best out of Mantra.

Best Regards

Edited by nmn
Link to comment
Share on other sites

I haven't looked at this but it might be helpful:

http://www.sidefx.com/index.php?option=com...&Itemid=132

Hey Edward, Thanks for the link, it was helpfull, it helped me confirm what i was saying and clarify some other things.

Though there are some few things still i didn't grasp, "ray samples", "shading quality" and "ray shading quality"in fact in the video he just spoke very very briefly about the max ray shading, and from what i understood is that they are only used with PBR ? to decorrelate the sampling or smtg like that ... so any explanation about that would be appreciated.

the second thing is, we use irradiance caching to reduce render times, and reduce high frequency noise right? but sometimes it introduces the low frequency noise, so how do i get rid of it ?

third and last thing, will pixel sampling and irradiance caching enable-disable work on a per object basis, if i just add them to my object and set them ?

Thanks for your help.

Regards

Link to comment
Share on other sites

Hey Edward, Thanks for the link, it was helpfull, it helped me confirm what i was saying and clarify some other things.

Though there are some few things still i didn't grasp, "ray samples", "shading quality" and "ray shading quality"in fact in the video he just spoke very very briefly about the max ray shading, and from what i understood is that they are only used with PBR ? to decorrelate the sampling or smtg like that ... so any explanation about that would be appreciated.

the second thing is, we use irradiance caching to reduce render times, and reduce high frequency noise right? but sometimes it introduces the low frequency noise, so how do i get rid of it ?

third and last thing, will pixel sampling and irradiance caching enable-disable work on a per object basis, if i just add them to my object and set them ?

Thanks for your help.

Regards

There are really just a few people ready to answer your questions. Mostly SESI stuff, as these details are mystery to some extend for many of us (even sessioned users). So, mostly guessing:

- ray shading quality, by analogy to shading quality (one of dicing control), seems to tune a quality of dicing geometry for

ray tracing purposes. I don't have any clarity here (at least not the one I would like to have*), but Mantra needs to represent surfaces in a similar way as for scanline mode to process ray intersection tests.

- max and min ray samples: mantra usually doesn't send a single ray but a whole bunch of them for anti-aliasing. These params control defaults for that behavior (varying amount of additional rays based on their similarity). PBR mode is different story I'm not sure about.

- Irradiance cache (and its options) can be set per object basis, but not pixel sampling. These things change often from property to property (like recent shutter control per object addition), so it's good to search through the help page about Mantra rendering properties once for a while.

Your explanation from a first post seems to be correct afaik. One thing bothers me though: the number of shader call in mp mode. Mantra isn't pure reyes, as it shades after generating samples (am I right?), so it can call shaders for every sample, not just for mp corner. In fact I always had a feeling that pixel sampling in Mantra is rather expensive and the time expense related to it can't be result of sampling ready-to-use data. I can be completely wrong here, but calling shader per sample would be a good reason to reverse order of usual reyes stuff (shade, then sample)... I hope someone will address these doubts one day ;)

skk.

* - I wonder for example if this representation is completely separate from mp one?. I also wonder why raytrace mode and pbr(!) deals with 1000+ of instances easily, while mp doesn't... it suggests that mantra stores diced geometry differently in mp/rt modes and it's incapable to reuse objects cache for instancing in mp (I know, I know famous "screen space surface refining", but I tried to disable any of these... - uniform dicing etc).

Edited by SYmek
Link to comment
Share on other sites

Thanks for your answer Symek, much appreciated

- max and min ray samples: mantra usually doesn't send a single ray but a whole bunch of them for anti-aliasing. These params control defaults for that behavior (varying amount of additional rays based on their similarity). PBR mode is different story I'm not sure about.

here i'm confused, i thought px samples were the ones responsible for the AA ...

and when you said "mantra usually doesn't send a single ray but a whole bunch of them for anti-aliasing", aren't those bunch of rays

determined by the px samples (for example 3x3 will shoot 9 rays per pixel), and if we think of those as the boundaries of the pixel samples well that also isn't convincing, because if we use min 1 max 9 and 8x8 px samples, render times are a lot bigger than min 1 max 9 with 3x3 px samples sooo the rays aren't limited max 9 i guess.

practically if you have objects in the scene that need small AA, and others that need a higher AA, which way would you go ? passes is the best bet ?

- Irradiance cache (and its options) can be set per object basis, but not pixel sampling. These things change often from property to property (like recent shutter control per object addition), so it's good to search through the help page about Mantra rendering properties once for a while.

how can we know from the docs that the property can be set on per object basis ? is it when we see for example IFD name object:irradiance ?

now back to the irradiance, is it normal that when we turn on irradiance caching the noise in the shadowy areas be lot more then the more lit areas ? how could we solve that ? (maybe by increasing the samples in the vex gi ? but here arises another question are 2048 samples or more considered normal to get acceptable result ? )

let us assume we turn off irradiance caching, render times will go sky high, and high frequency noise will come back, is there any other way to tackle those without irradiance caching ?

btw if you want to add irradiance to the shader itself i mean with the irradiance node, what do you do with its result, you just add it to the final result of your shader or what ? coz i tried that and it gave a different redult from the vex GI ...

Sorry if i'm asking too much ( i have a lot more still but i'll stop for now hehe), but in fact it's more like ... thinking out loud ...

:ph34r: I want to get my head around mantra !! lol

Cheers

Edited by nmn
Link to comment
Share on other sites

Thanks for your answer Symek, much appreciated

here i'm confused, i thought px samples were the ones responsible for the AA ...

and when you said "mantra usually doesn't send a single ray but a whole bunch of them for anti-aliasing", aren't those bunch of rays

This refers to ray tracing call inside a shader regardless mode mantra operates under. Even if you work in micropolygon mode, you can call one of ray trace related functions (trace, reflectlight, refractlight, gather etc), all of of them will make use of ray trace settings like variance, max/min ray samples. Some of them (variance for example) can be explicity set by a function.

Link to comment
Share on other sites

This is a small extract from the docs, if i got it right the min and max ray samples bound the number of times the shader is run when using MPPBR

so unlike for MP which runs the shader once per MP vertex, in MPPBR it runs the shader many times per MP vertex ... then average ...etc

In micropolygon PBR shading, mantra runs the shaders at the vertices of the micropolygon grid. However, because PBR depends on taking many shading samples, it runs the shader many times (controlled by the Max ray samples parameter), sending rays in random directions controlled by the BSDF. As with regular micropolygon rendering, it then takes samples across the micropolygon. The values of the samples are interpolated from the values at the corners (where the shaders ran). The number of samples is controlled by the Pixel samples parameter.

Because the Pixel samples parameter controls how many sub-pixel samples are averaged together to get the pixel color (whether the shaders run at the samples or the values of the samples are interpolated from the vertices), increasing the pixel samples gives better anti-aliasing for geometry edges, motion blur, and depth of field.

still i didn't find answers to the other thingies

  • Like 1
Link to comment
Share on other sites

Here's an example of where ray shading quality comes into play:

Torus Shading Quality: 5

Torus Ray Shading Quality: 1

th_torus-SQ5_RSQ1_ground_SQ1.png

Torus Shading Quality: 5

Torus Ray Shading Quality: 5

th_torus-SQ5_RSQ5_ground_SQ1.png

Torus Shading Quality: 5

Torus Ray Shading Quality: 5

Ground Shading Quality: 3

th_torus-SQ5_RSQ5_ground_SQ3.png

Increasing the ray shading quality on the torus makes the displacement look as detailed in the reflection as it does on the object itself. Then increasing the shading quality on the ground got rid of the blurryness from insufficient dicing. Hope that helps a bit.

Link to comment
Share on other sites

Correct, forgot to mention that. :)

I'm not quite sure what ray shading quality does in raytracing modes, time to check...

edit-

Pretty interesting, didn't know ray shading quality had an effect on displacement in raytracing. Sounds logical, but I thought it didn't make a difference before. :mellow:

Torus Ray Shading Quality: 1

th_torus_raytrace-RSQ1.png

Torus Ray Shading Quality: 5

th_torus_raytrace-RSQ5.png

Edited by DaJuice
Link to comment
Share on other sites

Thank you very much DaJuice for the examples, does that confirms that shading quality (resp ray shading quality)

are just responsible of the quality or level of dicing of the geometry but one for MP and one whenever any kind of raytracing is invloved ?

What about min and max ray samples ?

Regards

Edited by nmn
Link to comment
Share on other sites

Thank you very much DaJuice for the examples, does that confirms that shading quality (resp ray shading quality)

are just responsible of the quality or level of dicing of the geometry but one for MP and one whenever any kind of raytracing is invloved ?

What about min and max ray samples ?

Regards

In this case especially, the Micropolygon is acting as a HYBRID renderer - using Micropolygon for primary visibility and raytracing for secondary. This is why you need to adjust both sets: Shading Quality .vs. Ray Shading Quality.

In pure raytracing mode, the Micropolygon engine parms are ignored.

Min and Max ray samples control the number of rays sent from secondary ray bounces. You might initially think that only a single ray gets fired when the shader asks for a trace to occur, but this is not true: the reason is because objects are almost always convex or concave, meaning that the adjacent rays will diverge, resulting in sparse intersections with the scene (i.e. your reflections will be undersampled and glittery). So Mantra sends a fan of rays (interpolated from the vertex normals of the mp-patch/point) to provide better coverage of the scene. It uses "Variance" to determine whether to shoot a new ray - ie, if adjacent rays have a high luminance contrast, it'll send more rays in between, up until Max Ray Samples is reached. This property can be added to each object if you like; so if you're rendering a reflective plane, you might not need too many samples to get a good reflection... and so on. If you have a high-frequency environment (lots of brights and darks, like a stage), you may need more -- if it's bland (like an overcast day) you might get away with less.

Link to comment
Share on other sites

Thsnkd for the explanation Jason, but honestly i didn't understand the min max ray thing vrey well

Min and Max ray samples control the number of rays sent from secondary ray bounces.

first of all, here you mean by secondary ray bounces, every ray that is not an eye ray ?

and those parameters are used only when any type of raytracing occur right?

You might initially think that only a single ray gets fired when the shader asks for a trace to occur, but this is not true: the reason is because objects are almost always convex or concave, meaning that the adjacent rays will diverge, resulting in sparse intersections with the scene (i.e. your reflections will be undersampled and glittery).

here i didn't undesrtand why we need more rays, let us suppose we have a mirror, whatever was its shape, every point in the mirror where an eye ray hits will reflect one unique point in space right ? so i didn't get it ... if we send many samples we won't be reflecting that unique point ... :|

so if you could please clarify this matter some more :rolleyes:

ah and one more thing, a fast explanation about the irradiance caching parameters could help me also, to close the circle of this sampling matter :)

Thanks again for you all

Best Regards

Link to comment
Share on other sites

first of all, here you mean by secondary ray bounces, every ray that is not an eye ray ?

Correct, yes.

here i didn't undesrtand why we need more rays, let us suppose we have a mirror, whatever was its shape, every point in the mirror where an eye ray hits will reflect one unique point in space right ? so i didn't get it ... if we send many samples we won't be reflecting that unique point ... :|

so if you could please clarify this matter some more :rolleyes:

If you look in the attached diagram I just threw together, see how the green rays are necessary to intersect the smaller sphere? If the two primary rays only emitted one secondary reflection ray each then the smaller sphere would be missed completely.

post-4-1244683396_thumb.jpg

Link to comment
Share on other sites

If you look in the attached diagram I just threw together, see how the green rays are necessary to intersect the smaller sphere? If the two primary rays only emitted one secondary reflection ray each then the smaller sphere would be missed completely.

Thanks for your time Jason and for the diagram,

in fact I understood this way before, but what is not clear is ... suppose our big sphere is a perfect mirror then in reality the black rays would've acted as you drew them, and we wouldn't have seen any reflection of the small sphere in those 2 points, but if we sample between the two black hit points then we will be able to see our sphere

could it be that here with the two black rays you're referring to two closest samples ? i mean no samples in between ? but in such a case adding a little bit more pixel sampling would solve the issue no?

and in the case where we have blurred reflections, the numbers of the outgoing refl rays is determined by the shader ...

then how do we explain the following:

From the docs :

In micropolygon PBR shading, mantra runs the shaders at the vertices of the micropolygon grid. However, because PBR depends on taking many shading samples, it runs the shader many times (controlled by the Max ray samples parameter)

when for every eye ray hit we send only 2 rays one for diff and one for refl ...

Link to comment
Share on other sites

could it be that here with the two black rays you're referring to two closest samples ? i mean no samples in between ? but in such a case adding a little bit more pixel sampling would solve the issue no?

Yeah, if you're using the Raytrace render engine... but the point of these parameters is that it helps you sample more when you need it the most. If you increase your (primary ray) pixel samples then you're incurring a higher cost everywhere else in the scene just to resolve the reflections on one object.

For sure, the solution to most raytracing is "just throw more samples at it". The same is true for all raytracers of all kinds. Just look at smallpt, a path-tracer in 99 lines of C. This was written by Kevin Beason, an employee here where I work, actually. These kinds of features are things that you add to make a renderer faster and more flexible.

With the Micropolygon renderer, if you perform more supersampling it won't affect how the sphere is diced, meaning that the little mp-patch inside the pixel coverage area which you're bouncing off is the same little geometry piece regardless of how many supersamples you send at it. You'd have to push up your Shading Quality too.

Link to comment
Share on other sites

Thanks Jason for all the explanations and thanks for all the effort everyone.

This thread was very helpful to me to understand those under the hood aspects of mantra.

now it's up to me to experiment ...

ah i still had one point (irradiance caching) which its use is clear to me but i would like to know how it's done internally because now i'm using it more on a trial and error basis and i would like to understand it fully, but seems someone else opened a thread specific for the subject so i will follow it there

Thanks again for everyone

Best Regards

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...