Announcement

Collapse
No announcement yet.

Prerender maxscript help setting DR region size...

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

  • Prerender maxscript help setting DR region size...

    Hi all,

    I wrote fairly simple script to automatically shrink the DR region size when doing previews (or small render regions) to ensure that I'm always using all of my DR nodes. I've set the script to run as a "Pre-Render" script in the Render Setup "Common" tab and it works great when I click the "render" button. However if I hit F9 or use the Render Last button in the Vray VFB it doesn't seem to run the script. Fair enough I thought, I'll just register it as a #preRender callback script. Only now it doesn't seem to want to change the DR region size until AFTER the render is complete. Am I missing something or is this not possible? What confused me is that the docs state the Render Setup script is run AFTER any #preRender callbacks which makes me think it should work just fine. The script is below in case anyones interested (no guarantees though).

    Thanks.

    Code:
        vr = renderers.current
        global oldDrSize=vr.system_region_x
        coresPerNode=8 --Average number of cores on render nodes
        sizeFactor=6  --number of regions devoted to each core
        minDrSize=16  --minimum region size
        
        VFBregionOn=vrayVFBGetRegionEnabled()
        VFBregion=vrayVFBGetRegion()
        drSize=oldDrSize^2
        
        if vr.system_distributedRender == true then 
            (
            drNodecount=1
            ini = ((getdir #plugcfg) +"\vray_dr.cfg")
            cfg=openFile ini
            do 
            (
                if (readchars cfg 3) != "res" then 
                (
                    skiptostring cfg " "
                    if  (readchars cfg 1) =="1" then drNodeCount +=1
                    skipToNextLine cfg
                )
            )while (eof cfg ==false and (readchars cfg 3) != "res" )
    
    
            if VFBregionOn==false then renderSize=renderWidth*renderHeight else renderSize=(VFBregion[3]-VFBregion[1])*(VFBregion[4]-VFBregion[2])
            if ((renderSize/drSize)/coresPerNode/sizeFactor/2) <= drNodeCount then newDrSize=sqrt((renderSize/coresPerNode)/drNodeCount/sizeFactor) else newDrSize=oldDrSize
            if newDrSize>oldDrSize then newDrSize=oldDrSize
            if newDrSize<=minDrSize then newDrSize=minDrSize 
            vr.system_region_x=newDrSize
            )
    www.dpict3d.com - "That's a very nice rendering, Dave. I think you've improved a great deal." - HAL9000... At least I have one fan.

  • #2
    I hate debugging callback scripts of max. It's such a pain in the butt. Try having it write the variables you're changing to some text file, and watch the folder for when it's created. You aren't assigning a callback in this script (so I assume there's more?) Can we see it all?
    Colin Senner

    Comment


    • #3
      I had saved the script as dp_AutoRegion_01.ms and then registered the callback in the listener via:

      Code:
      callbacks.addscript #preRender filename:"C:\Program Files\Autodesk\3ds Max Design 2011\Scripts\dp_Scripts\dp_AutoRegion_01.ms" id:#dpRR
      I get the "OK" back and the script seems to be functioning correctly, just that it's changing the values AFTER the render has completed (or at least after rendering has actually begun which does me no good). Is the a better way to implement the callback?
      www.dpict3d.com - "That's a very nice rendering, Dave. I think you've improved a great deal." - HAL9000... At least I have one fan.

      Comment


      • #4
        You sure it's running the script? Max reads \ as effectively nothing (because it wants another character after it for a new line, example: \n) Either use "\\" or "/" (no quotes)


        C:\\Program Files\\Autodesk\\3ds Max Design 2011\\Scripts\\dp_Scripts\\dp_AutoRegion_01.ms

        Let me check a list of callbacks real quick and see.

        Ok, check it out. Here's what I did that works just fine...


        Filename: "C:\Users\Colin\Desktop\BucketTest.ms"
        Code:
        (
        	global isVRayRenderer
        
        
        	fn isVRayRenderer = if matchPattern (renderers.current as string) pattern:"*V_Ray_Adv*" then true else false
        
        
        	if isVRayRenderer() then (
        		-- Change the bucket size right before rendering
        		vr = renderers.current
        		
        		vr.system_region_x=16
        		vr.system_region_y=16
        	)
        )
        Then registered the callback in the listener with

        Code:
        callbacks.addscript #preRender filename:"C:\Users\Colin\Desktop\BucketTest.ms" id:#dpRR
        Works fine.
        Colin Senner

        Comment


        • #5
          Tried your script. Works the same as mine in that it sets the bucket size AFTER the render begins. Actually, if I have the RenderSetup dialog open I can see the region size change to 16 just after the render starts. Is there any way to tell if there are any other callbacks running?
          www.dpict3d.com - "That's a very nice rendering, Dave. I think you've improved a great deal." - HAL9000... At least I have one fan.

          Comment


          • #6
            Mine works and changes it before render just fine. You can watch mine change the region size right before rendering. Restart your max?
            Colin Senner

            Comment


            • #7
              Still no go here after restarting. FYI: I'm on Max 2011 x64 with vray 2.20.01. Thanks for all your help though - much appreciated.
              www.dpict3d.com - "That's a very nice rendering, Dave. I think you've improved a great deal." - HAL9000... At least I have one fan.

              Comment


              • #8
                I think I've run into this before, it seems to work locally but then fails for network rendering.

                From the mxs help:
                #preRender: Array
                Sent before rendering is started. This notification is sent out before the renderer creates the render instance objects, which means that you can create nodes and other objects as a response to this event. When rendering multiple frames, this event is sent only once at the beginning of the rendering phase, and not on a per-frame basis. In the #preRender callback, you can't change any of the render parameters (height, width, aliasing, etc) and affect the current render sessions. Those parameters have already been set up internally in 3ds Max, and so changes to them won't occur until the next render session occurs.
                Dan Brew

                Comment


                • #9
                  In that case: try:

                  #preRenderFrame

                  and since you're sending it to the farm, where the max file will be opened you could try

                  #filePostOpen
                  Colin Senner

                  Comment


                  • #10
                    @Dan: I saw that as well but am confused because the docs state that the scripts listed in the render setup dialog are executed after any #prerender callback and when the script is put in there it works just fine (just not for "last Renders").

                    @Colin: I tried the #preRenderFrame just for kicks and got the same results. I'm not really rendering it via backburner so I don't think the filepostopen will work either. I'm still confused as to why it works for you but not me.
                    www.dpict3d.com - "That's a very nice rendering, Dave. I think you've improved a great deal." - HAL9000... At least I have one fan.

                    Comment


                    • #11
                      Hrm, well I checked again, and you're right it doesn't work. I was just watching the value change in the render scene dialog and assumed it did it for the frame (which it didn't).
                      Colin Senner

                      Comment


                      • #12
                        Thanks for double checking. At least I know it's not just my machine. It seems like there's limitation then.
                        www.dpict3d.com - "That's a very nice rendering, Dave. I think you've improved a great deal." - HAL9000... At least I have one fan.

                        Comment


                        • #13
                          There was a point where I was trying to get this to work too. I have a very vague memory of #filePostOpenProcess working. It might be worth a try.

                          Comment


                          • #14
                            You can do it on preRenderFrame (or something similar). Probably and send 2 frames, the first one just of the environment color/bg?
                            Colin Senner

                            Comment


                            • #15
                              Originally posted by tiw View Post
                              There was a point where I was trying to get this to work too. I have a very vague memory of #filePostOpenProcess working. It might be worth a try.
                              Originally posted by MoonDoggie View Post
                              You can do it on preRenderFrame (or something similar). Probably and send 2 frames, the first one just of the environment color/bg?
                              Yeah, these should work for sending a job through backburner but for renders just using DR it doesn't work at all. Seems we're out of luck for some reason.
                              www.dpict3d.com - "That's a very nice rendering, Dave. I think you've improved a great deal." - HAL9000... At least I have one fan.

                              Comment

                              Working...
                              X