Announcement

Collapse
No announcement yet.

Understanding DMC Sampler

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • #31
    Double post - see below instead
    Last edited by joconnell; 27-02-2013, 10:42 AM.

    Comment


    • #32
      Originally posted by joconnell View Post
      Also when you set material glossiness, are you normally using the reflection glossiness spinner for this? I've written a small utility to make setting samples quicker based on how blurry it's set which could make some things slighty easier.
      That sounds brilliant, is it available?
      Cheers, Michael.

      Comment


      • #33
        Okay, I'd think that clr of 0.003 is a really fine setting, I'd normally start with 0.01 personally and it's quite good.

        From the sounds of your result I'd say the bump map is causing the anti aliaser to work quite hard as bump is almost like making "cheat" geometry, and with all the extra detail that your fine bump map add in, vray is doing quite a bit of anti aliasing on those bump details to try and meet your 0.003 quality threshold. Could you pop up some render elements for a look?

        Also when you set material glossiness, are you normally using the reflection glossiness spinner for this? I've written a small utility to make setting samples quicker based on how blurry it's set which could make some things slightly easier. Copy and paste this code into a maxscript > new script window and you can adjust your materials in the scene quickly based on the glossiness number. Setting all to 64 is fine, but you'll likely need less samples on sharper reflections and more on softer ones so this is a way of trying to do that quickly:

        Code:
        try(destroydialog SetVraySamples)catch()
        
        
        Function setVrayMatSubdivs ActualGlossy glossy_02 glossy_04 glossy_06 glossy_08 glossy_10 = (
        	
        	case of (
        					(ActualGlossy >= 0.0 and ActualGlossy < 0.2): ActualGlossys = glossy_02
        					(ActualGlossy >= 0.2 and ActualGlossy < 0.4): ActualGlossy = glossy_04
        					(ActualGlossy >= 0.4 and ActualGlossy < 0.6): ActualGlossy = glossy_06
        					(ActualGlossy >= 0.6 and ActualGlossy < 0.8): ActualGlossy = glossy_08
        					(ActualGlossy >= 0.8 and ActualGlossy <= 1.0): ActualGlossy = glossy_10
        					)	
        )
        
        rollout RollSetVraySamples "Set VrayMat Samples"
        (	
        	Group "Material sample amounts" 
        	(
        		spinner glossy_00_to_02 "Glossiness 0.0 to 0.2"  range:[00,5000,100] align:#right type:#integer
        		spinner glossy_02_to_04 "Glossiness 0.2 to 0.4"  range:[00,5000,80] align:#right type:#integer
        		spinner glossy_04_to_06 "Glossiness 0.4 to 0.6"  range:[00,5000,60] align:#right type:#integer
        		spinner glossy_06_to_08 "Glossiness 0.6 to 0.8"  range:[00,5000,40] align:#right type:#integer
        		spinner glossy_08_to_10 "Glossiness 0.8 to 1.0"  range:[00,5000,20] align:#right type:#integer
        					
        		button DoubleVraySamples "Double samples" width:180 align:#left
        		button HalfVraySamples "Half samples" width:180 align:#right offset:[0,-26]
        	)
        	button SetVraySamples "Set Sample amounts" width:200 align:#right
        	
        	Function ProcessMaterial m =
        	(
        		if (classof m) == VRayMtl then 
        		(
        			m.reflection_subdivs = setVrayMatSubdivs m.reflection_glossiness glossy_00_to_02.value glossy_02_to_04.value glossy_04_to_06.value glossy_06_to_08.value glossy_08_to_10.value
        			m.refraction_subdivs = setVrayMatSubdivs m.refraction_glossiness glossy_00_to_02.value glossy_02_to_04.value glossy_04_to_06.value glossy_06_to_08.value glossy_08_to_10.value
        		)
        		-- ============================ VRay2SidedMtl =============================================
        		else if (classof m) == VRay2SidedMtl then
        		(
        			ProcessMaterial m.frontmtl
        			ProcessMaterial m.backmtl
        		)
        		-- ============================ SHELLAC =============================================
        		else if (classof m) == SHELLAC then
        		(
        			ProcessMaterial m.shellacMtl1
        			ProcessMaterial m.shellacMtl2
        		)
        		-- ============================ VRayBlendMtl =============================================
        		else if (classof m) == VRayBlendMtl then
        		(
        			ProcessMaterial m.baseMtl
        			for i = 1 to 9 do ProcessMaterial m.coatMtl[i]
        		)
        		-- ============================ VrayMtlWrapper =============================================
        		else if  (classof m) == VrayMtlWrapper then ProcessMaterial  m.baseMtl
        		
        		-- ============================ VrayOverrideMtl =============================================
        		else if  (classof m) == VrayOverrideMtl then
        		(
        			ProcessMaterial  m.baseMtl
        			ProcessMaterial  m.GIMtl
        			ProcessMaterial  m.reflectmtl
        			ProcessMaterial  m.refractmtl
        			ProcessMaterial  m.shadowmtl
        		)
        		-- ============================= Vray CArPaint =====================================================
        		else if  (classof m) == Vraycarpaintmtl then
        		(
        			m.subdivs = setVrayMatSubdivs m.base_glossiness glossy_00_to_02.value glossy_02_to_04.value glossy_04_to_06.value glossy_06_to_08.value glossy_08_to_10.value
        		)
        		-- ============================= Vray FAST SSS2 =====================================================
        		else if  (classof m) == Vrayfastsss2 then
        		(
        			m.specular_subdivs = setVrayMatSubdivs m.specular_glossiness glossy_00_to_02.value glossy_02_to_04.value glossy_04_to_06.value glossy_06_to_08.value glossy_08_to_10.value
        			
        		)
        		-- ============================= Vray FLAKESMTL =====================================================
        		else if  (classof m) == VrayFlakesmtl then
        		(
        			m.subdivs = setVrayMatSubdivs m.flake_glossiness glossy_00_to_02.value glossy_02_to_04.value glossy_04_to_06.value glossy_06_to_08.value glossy_08_to_10.value
        		)
        		-- ======================================================================================
        		-- ============================ MULTIMAT =============================================
        		-- ======================================================================================
        		else if (classof m) == Multimaterial then for i = 1 to m.count do ProcessMaterial m[i]
        		
        		-- ============================= blend (fusion) =====================================================
        		else if (classof m) == blend then
        		(
        			ProcessMaterial  m.MAP1
        			ProcessMaterial  m.MAP2
        		)
        		-- ============================= composite =====================================================
        		else if (classof m) == compositematerial then
        		(
        			ProcessMaterial m.baseMaterial
        			for i = 1 to m.materiallist.count do ProcessMaterial m.materiallist[i]
        		)
        		-- ============================= top-bottom =====================================================
        		else if (classof m) == topbottom then
        		(
        			ProcessMaterial  m.topmaterial
        			ProcessMaterial  m.bottomMaterial
        		)
        		-- ============================= SHELL (coque) =====================================================
        		else if (classof m) == shell_material then
        		(
        			ProcessMaterial  m.originalMaterial
        			ProcessMaterial  m.bakedMaterial
        		)
        	)
        	
        	on DoubleVraySamples pressed do
        	(
        		glossy_00_to_02.value = glossy_00_to_02.value*2
        		glossy_02_to_04.value = glossy_02_to_04.value*2
        		glossy_04_to_06.value = glossy_04_to_06.value*2
        		glossy_06_to_08.value = glossy_06_to_08.value*2
        		glossy_08_to_10.value = glossy_08_to_10.value*2
        	)
        	
        		on HalfVraySamples pressed do
        	(
        		glossy_00_to_02.value = glossy_00_to_02.value*0.5
        		glossy_02_to_04.value = glossy_02_to_04.value*0.5
        		glossy_04_to_06.value = glossy_04_to_06.value*0.5
        		glossy_06_to_08.value = glossy_06_to_08.value*0.5
        		glossy_08_to_10.value = glossy_08_to_10.value*0.5
        	)
        	
        	on SetVraySamples pressed do
        	(
        		for m in scenematerials  do with undo off ProcessMaterial m
        	)
        
        )
        
        CreateDialog RollSetVraySamples width: 400

        Comment


        • #34
          joconnell, I love the sound of this -

          I'm going to test this out myself when I've got a moment. I've always struggled with balancing aliasing vs material samples vs light samples. Love this calculated step by step approach.

          cheers
          Brendan Coyle | www.brendancoyle.com

          Comment


          • #35
            Here's the second script that I use. The blurrier a reflection gets, the less bounces it needs as if you've got something really soft, you can't make out detail in the surface of it anyway. This will run through your scene and turn up or down reflection bounces depending on their glossiness:

            Code:
            try(destroydialog SetVrayMatRefDepth)catch()
            
            
            Function setVrayRefDepth ActualGlossy glossy_02 glossy_04 glossy_06 glossy_08 glossy_10 = (
            	
            	case of (
            					(ActualGlossy >= 0.0 and ActualGlossy < 0.2): ActualGlossys = glossy_02
            					(ActualGlossy >= 0.2 and ActualGlossy < 0.4): ActualGlossy = glossy_04
            					(ActualGlossy >= 0.4 and ActualGlossy < 0.6): ActualGlossy = glossy_06
            					(ActualGlossy >= 0.6 and ActualGlossy < 0.8): ActualGlossy = glossy_08
            					(ActualGlossy >= 0.8 and ActualGlossy <= 1.0): ActualGlossy = glossy_10
            					)	
            )
            
            rollout SetVrayMatRefDepth "Set VrayMat Reflection bounces"
            (	
            	Group "Set reflection bounces" 
            	(
            		spinner glossy_00_to_02 "Glossiness 0.0 to 0.2"  range:[00,5000,1] align:#right type:#integer
            		spinner glossy_02_to_04 "Glossiness 0.2 to 0.4"  range:[00,5000,2] align:#right type:#integer
            		spinner glossy_04_to_06 "Glossiness 0.4 to 0.6"  range:[00,5000,3] align:#right type:#integer
            		spinner glossy_06_to_08 "Glossiness 0.6 to 0.8"  range:[00,5000,4] align:#right type:#integer
            		spinner glossy_08_to_10 "Glossiness 0.8 to 1.0"  range:[00,5000,5] align:#right type:#integer
            					
            		button DoubleRefDepth "Double Ref bounces" width:180 align:#left
            		button HalfRefDepth "Half Ref bounces" width:180 align:#right offset:[0,-26]
            	)
            	button SetRefDepth "Set Reflection bounces" width:200 align:#right
            	
            	Function ProcessMaterial m =
            	(
            		if (classof m) == VRayMtl then 
            		(
            			m.reflection_maxDepth = setVrayRefDepth m.reflection_glossiness glossy_00_to_02.value glossy_02_to_04.value glossy_04_to_06.value glossy_06_to_08.value glossy_08_to_10.value
            			-- m.refraction_subdivs = setVrayMatSubdivs m.reflection_maxDepth glossy_00_to_02.value glossy_02_to_04.value glossy_04_to_06.value glossy_06_to_08.value glossy_08_to_10.value
            		)
            		-- ============================ VRay2SidedMtl =============================================
            		else if (classof m) == VRay2SidedMtl then
            		(
            			ProcessMaterial m.frontmtl
            			ProcessMaterial m.backmtl
            		)
            		-- ============================ SHELLAC =============================================
            		else if (classof m) == SHELLAC then
            		(
            			ProcessMaterial m.shellacMtl1
            			ProcessMaterial m.shellacMtl2
            		)
            		-- ============================ VRayBlendMtl =============================================
            		else if (classof m) == VRayBlendMtl then
            		(
            			ProcessMaterial m.baseMtl
            			for i = 1 to 9 do ProcessMaterial m.coatMtl[i]
            		)
            		-- ============================ VrayMtlWrapper =============================================
            		else if  (classof m) == VrayMtlWrapper then ProcessMaterial  m.baseMtl
            		
            		-- ============================ VrayOverrideMtl =============================================
            		else if  (classof m) == VrayOverrideMtl then
            		(
            			ProcessMaterial  m.baseMtl
            			ProcessMaterial  m.GIMtl
            			ProcessMaterial  m.reflectmtl
            			ProcessMaterial  m.refractmtl
            			ProcessMaterial  m.shadowmtl
            		)
            		-- ============================= Vray CArPaint =====================================================
            		else if  (classof m) == Vraycarpaintmtl then
            		(
            			m.subdivs = setVrayMatSubdivs m.base_glossiness glossy_00_to_02.value glossy_02_to_04.value glossy_04_to_06.value glossy_06_to_08.value glossy_08_to_10.value
            		)
            		-- ============================= Vray FAST SSS2 =====================================================
            		else if  (classof m) == Vrayfastsss2 then
            		(
            			m.specular_subdivs = setVrayMatSubdivs m.specular_glossiness glossy_00_to_02.value glossy_02_to_04.value glossy_04_to_06.value glossy_06_to_08.value glossy_08_to_10.value
            			
            		)
            		-- ============================= Vray FLAKESMTL =====================================================
            		else if  (classof m) == VrayFlakesmtl then
            		(
            			m.subdivs = setVrayMatSubdivs m.flake_glossiness glossy_00_to_02.value glossy_02_to_04.value glossy_04_to_06.value glossy_06_to_08.value glossy_08_to_10.value
            		)
            		-- ======================================================================================
            		-- ============================ MULTIMAT =============================================
            		-- ======================================================================================
            		else if (classof m) == Multimaterial then for i = 1 to m.count do ProcessMaterial m[i]
            		
            		-- ============================= blend (fusion) =====================================================
            		else if (classof m) == blend then
            		(
            			ProcessMaterial  m.MAP1
            			ProcessMaterial  m.MAP2
            		)
            		-- ============================= composite =====================================================
            		else if (classof m) == compositematerial then
            		(
            			ProcessMaterial m.baseMaterial
            			for i = 1 to m.materiallist.count do ProcessMaterial m.materiallist[i]
            		)
            		-- ============================= top-bottom =====================================================
            		else if (classof m) == topbottom then
            		(
            			ProcessMaterial  m.topmaterial
            			ProcessMaterial  m.bottomMaterial
            		)
            		-- ============================= SHELL (coque) =====================================================
            		else if (classof m) == shell_material then
            		(
            			ProcessMaterial  m.originalMaterial
            			ProcessMaterial  m.bakedMaterial
            		)
            	)
            	
            	on DoubleRefDepth pressed do
            	(
            		glossy_00_to_02.value = glossy_00_to_02.value*2
            		glossy_02_to_04.value = glossy_02_to_04.value*2
            		glossy_04_to_06.value = glossy_04_to_06.value*2
            		glossy_06_to_08.value = glossy_06_to_08.value*2
            		glossy_08_to_10.value = glossy_08_to_10.value*2
            	)
            	
            		on HalfRefDepth pressed do
            	(
            		glossy_00_to_02.value = glossy_00_to_02.value*0.5
            		glossy_02_to_04.value = glossy_02_to_04.value*0.5
            		glossy_04_to_06.value = glossy_04_to_06.value*0.5
            		glossy_06_to_08.value = glossy_06_to_08.value*0.5
            		glossy_08_to_10.value = glossy_08_to_10.value*0.5
            	)
            	
            	on SetRefDepth pressed do
            	(
            		for m in scenematerials  do with undo off ProcessMaterial m
            	)
            
            )
            
            CreateDialog SetVrayMatRefDepth width:400
            As a note, Many thanks to Jérôme Prévost who wrote the code to run through all the vray sub materials also.

            Comment


            • #36
              joconnell - Thank you so much for your input and these fantastic scripts!

              I have a question related to the formula behind the connection of the Image Sampler (Primary Rays) to the DMC Sampler (Secondary Rays).
              Am I correct in my understanding that the basic formula is as follows:

              (Secondary Subdivs Value / Primary Subdivs MAX Value)^2 = Max # of Secondary Samples taken per Primary Ray

              This formula is what happens when the Adaptiveness value is set to 1.0 - correct?
              This is also ignoring the Min Samples value, which takes over incase the # of Secondary Samples taken per Primary Ray is below it's value - correct?

              So how does the Adaptiveness value (0.0 to 1.0) fit into this formula?
              I want an single formula to know exactly how many rays are going to be taken depending on these 3 main values.
              Last edited by RockinAkin; 25-03-2013, 05:48 PM.
              Akin Bilgic | CGGallery.com
              Modeler & Generalist TD

              V-Ray Render Optimization
              V-Ray DMC Calculator

              Comment


              • #37
                It's the other way around - the adaptive value is how adaptive the sampler is, 0 is not adaptive at all so it'll be brute force and use the max sample amount, 1.0 means fully adaptive so it'll use the minimum samples to start with and then gradually add samples until the quality is good enough. The adaptive amount is what percent of the samples are used as adaptive rays which kick in after vray has used up it's fixed rays. So if you've got your adaptive amount set to 0.6, then 60% of your samples will be adaptive, with the 40% being used right at the start. In theory you want to try and keep things very adaptive, as if your solution was nearly clean enough when sampling, and only needed one more ray to get the result you want, your sampler might end up throwing lots more on top instead.

                So with your equation lets say you've got 1/4 aa, material samples of 8 and an adaptive amount of 0.5

                So you get 8 x 8 = 64 material samples / 4 aa subdivs = 16 samples. This is then multiplied by your adaptive amount so 0.5 or 8 of your samples are fixed to start, and then the remaining 8 will be gradually used until you hit the quality you've asked for.

                Comment


                • #38
                  Removed due to misleading info... see my post on Page 6 for updated and correct info / formulas!
                  Last edited by RockinAkin; 25-03-2013, 05:49 PM.
                  Akin Bilgic | CGGallery.com
                  Modeler & Generalist TD

                  V-Ray Render Optimization
                  V-Ray DMC Calculator

                  Comment


                  • #39
                    Nearly, just your sum above calculates how many rays are adaptive rather than the fixed ones that shoot first. In other words, if you have your adaptive amount set to 0.85 as default, it means 85% of your samples are the adaptive ones, so the sampler will shoot 15% of your rays to start with, then start working through the remaining 85% in an adaptive way until the quality is good enough.
                    Last edited by joconnell; 01-03-2013, 03:26 AM.

                    Comment


                    • #40
                      Removed due to misleading info... see my post on Page 6 for updated and correct info / formulas!
                      Last edited by RockinAkin; 25-03-2013, 05:50 PM.
                      Akin Bilgic | CGGallery.com
                      Modeler & Generalist TD

                      V-Ray Render Optimization
                      V-Ray DMC Calculator

                      Comment


                      • #41
                        All correct. I'd wonder about whether knowing the numbers would make any major difference or not as say for example you get a few pixels that have too many and other pixels that have too few samples, but they both belonged to the same object but were just being hit by slightly different lighting scenarios - would knowing the number of rays have any major benefit?

                        I'd personally rather have a sample rate type equivalent for lighting and reflect / refract rays, and the lighting is almost covered by raw lighting and raw gi. I'm not sure how helpful actual raw statistics are in terms of how you can apply them?

                        Comment


                        • #42
                          True, that'd be nice.

                          As an example, I'm often handed off scene files that someone else setup, and when I first test their settings, some parts of the image grind the render down to a halt... so then I dig through the scenes lights and materials one by one until I find a material that has it's subdivisions cranked up to 200 which is causing the delay. Would be nice to have a 'one stop shop' to quickly see what everything in the scene is set to... in addition to your mentioned secondary sample rate pass. This obviously gets less important with the AA 1/100 method.

                          Thanks again for your input.
                          Akin Bilgic | CGGallery.com
                          Modeler & Generalist TD

                          V-Ray Render Optimization
                          V-Ray DMC Calculator

                          Comment


                          • #43
                            For this type of thing maxscript is a big help - Colin senner wrote a great tool called VMC or vray material control which will likely give you a lot of at a glance info. Also Dave wortley from the forum is writing a lot of maxscript basics on his site that could at least give you enough to loop through all the scene's materials and print out their subdiv values!

                            Comment


                            • #44
                              Removed due to misleading info... see my post on Page 6 for updated and correct info / formulas!
                              Last edited by RockinAkin; 25-03-2013, 05:50 PM.
                              Akin Bilgic | CGGallery.com
                              Modeler & Generalist TD

                              V-Ray Render Optimization
                              V-Ray DMC Calculator

                              Comment


                              • #45
                                Exactly - I had my thinking wrong originally where I was interchanging subdivs and samples and not taking into account the subdivs being squared to make the samples number. Svetlozar pointed this out as regards the minimum samples number that it's a safety net - Vray can't make good decisions if it doesn't have enough samples to work with so the minimum samples parameter is there to stop that. It's also the same as Vlado mentioning that if you use an adaptive amount of 1.0, it can be slightly dangerous as again Vray won't have enough information at the start to make good decisions, so he normally sets it to a maximum of 0.9.

                                Comment

                                Working...
                                X