Setting Render Engine in a script?

zigraphixzigraphix Posts: 2,787

When we use "Save Render Settings" in DS 4.6.0.18, only the default 3Delight settings are saved, even if a different render engine is selected, e.g. "Preview Render" or "Scripted 3Delight." If we save a scene with a different render engine selected, the options for the alternate render engine are saved with the scene, but they don't appear until the user manually sets the other render engine.

How can we use a script to set the Render Engine so the user can select Scripted 3Delight and a particular render script from the Content Library? It seems to me that the parameter ought to be specified somewhere in here, between the two "type" declarations:

{ "file_version" : "0.6.0.0", "asset_info" : {  "id" : "...",  "type" : "scene",  "contributor" : {   "author" : "zigraphix",   "email" : "[email protected]",   "website" : "http://zigraphix.com";  },  "revision" : "1.0",  "modified" : "2013-09-07T18:34:30Z" }, "scene" : {  "extra" : [   {    "type" : "studio_render_settings",    "render_options" : {     "aspect_ratio" : [ 1, 1 ],     "startTime" : 0,     "endTime" : 1,     "renderMovToId" : "ImageSeries",     "renderViewport" : false,     "isAspectConstrained" : true,     "imageSize" : [ 490, 490 ],     "renderType" : "Software",     "renderStyle" : "Normal",     "rayTraceDepth" : 2,     "openGLPasses" : 1,     "useGLSL" : false,     "isCurrentFrameRender" : true,     "useMotionBlur" : false,     "motionBlurPct" : 100,     "motionBlurSamples" : 2,     "xPixelSamples" : 4,     "yPixelSamples" : 4,     "shadowSamples" : 16,     "shadingRate" : 1,     "doubleSided" : true,     "gain" : 1,     "gamma" : 1,     "pixelFilter" : "Sinc",     "xFilterWidth" : 6,     "yFilterWidth" : 6,     "gammaCorrection" : "GCOff"    }   },   {    "type" : "studio/scene_data/simple_data",    "name" : "Outline Renderer Data",    "settings" : {     "Bucket Order" : "Horizontal",     "Bucket Size" : 16,     "Max Ray Depth" : 4,     "Pixel Samples X" : 4,     "Pixel Samples Y" : 4,     "Shadow Samples" : 16,     "Gain" : 1,     "Gamma" : 1,     "Shading Rate" : 1,     "Pixel Filter" : "Sinc",     "Pixel Filter Width X" : 6,     "Pixel Filter Width Y" : 6,     "Color ID Edge Threshold" : 0.05,     "Color ID Line Width" : 2,     "Color ID Line Color" : -1,     "Color ID Fadeout Enable" : false,     "Color ID Fadeout Near" : -100,     "Color ID Fadeout Far" : 400,     "Color ID Fadeout Minwidth" : 1,     "Normal Edge Threshold" : 0.5,     "Normal Line Width" : 2,     "Normal Line Color" : -1,     "Normal Fadeout Enable" : false,     "Normal Fadeout Near" : -100,     "Normal Fadeout Far" : 400,     "Normal Fadeout Minwidth" : 1,     "Depth Edge Threshold" : 0.5,     "Depth Line Width" : 2,     "Depth Line Color" : -1,     "Depth Fadeout Enable" : false,     "Depth Fadeout Near" : -100,     "Depth Fadeout Far" : 400,     "Depth Fadeout Minwidth" : 1,     "Render to RIB" : false,     "File Prefix" : "Outline"    }   }  ] }}

Comments

  • Richard HaseltineRichard Haseltine Posts: 100,939
    edited September 2013

    I'm not seeing anything very hopeful in the scriptable commands for the Render Settings pane:

     var paneMgr = MainWindow.getPaneMgr();
     // if successful, get the Content Library pane
     if ( paneMgr ) {
      var library = paneMgr.findPane( "DzRenderSettingsPane" );
      // if successful, get the current container (folder or category)
      if ( library ) {
       for ( var n in library ) {
        print ( n );
       }
      }
     }

    Do you want this moved to the Developer Discussions forum, which is for scripting and seems more likely to catch one of the devs' eye?

    This looks like it may help http://docs.daz3d.com/doku.php/public/software/dazstudio/4/referenceguide/scripting/api_reference/samples/rendering/render_to_viewport/start

    Post edited by Richard Haseltine on
  • RenpatsuRenpatsu Posts: 828
    edited September 2013

    Well, as I wrote in the multipass thread (last post on http://www.daz3d.com/forums/discussion/6946/P45), I am able to switch the active renderer and also start the render process then. I can also set render settings via script (http://www.daz3d.com/forums/discussion/20457/). What didn't seem to work however is to steer the user interface in that regard, so that the user gets a display of e.g. the scripted render settings automatically. So far I still had to select this and couldn't trigger this from script.

    Post edited by Renpatsu on
  • zigraphixzigraphix Posts: 2,787
    edited December 1969

    Sure, let's move to Developer Discussions... I probably should have posted it there in the first place.

    The sample script you included is more like what I used in the "scripted renderer" script I worked on... it doesn't give me the interface element names I need to set. It's probably something obvious like

     "Render Engine"  :  "Scripted 3Delight",

    or something like that, but it would be nice not to have to guess....

  • zigraphixzigraphix Posts: 2,787
    edited December 1969

    Renpatsu said:
    Well, as I wrote in the multipass thread (last post on http://www.daz3d.com/forums/discussion/6946/P45), I am able to switch the active renderer and also start the render process then. I can also set render settings via script (http://www.daz3d.com/forums/discussion/20457/). What didn't seem to work however is to steer the user interface in that regard, so that the user gets a display of e.g. the scripted render settings automatically. So far I still had to select this and couldn't trigger this from script.

    I completely forgot that we had exchanged info about this earlier-- sorry! between what's in that thread and what I've been digging around figuring out, I think I may have some more ideas to try....

  • zigraphixzigraphix Posts: 2,787
    edited September 2013

    Ok, to followup... I am able to turn on Scripted 3Delight from a script in the Content Library, and I am able to configure the options (and the configuration shows in the Render Settings pane). What I still can't do is change the value of "Select a Render Script" and choose a script there. Essentially I have to redo the script that normally appears in the DAZ Studio/Resources/Scripted Renderer subdirectory as a Content Library script instead. I think I can live with that. :)

    (Edited to add... but I still think "Save As Render Preset" ought to correctly save the Render Engine and selected Render Script, if any.)

    Post edited by zigraphix on
  • RenpatsuRenpatsu Posts: 828
    edited December 1969

    zigraphix said:
    ... (Edited to add... but I still think "Save As Render Preset" ought to correctly save the Render Engine and selected Render Script, if any.)

    I was hoping that render presets would work this way at some point, too. Personally, I got the render settings completely ignored on scene saving/loading and exclusively set them via my scripts these days.

  • Richard HaseltineRichard Haseltine Posts: 100,939
    edited December 1969

    OK, moved to Developer Discussion.

  • rbtwhizrbtwhiz Posts: 2,250
    edited December 1969

    // Get the render manager
    var oRenderMgr = App.getRenderMgr();
    // Find the scripted renderer
    var oRenderer = oRenderMgr.findRenderer( "DzScriptedRenderer" );
    // If we found the render
    if( oRenderer ){
     // Set the active renderer
     oRenderMgr.setActiveRenderer( oRenderer );
     // Set the [relative] definition file path;
     // relative to App.getResourcesPath() + "/Scripted Renderer/"
     oRenderer.setDefinitionFile( "Outline/Outline.dsa" );
    }

    -Rob

  • Richard HaseltineRichard Haseltine Posts: 100,939
    edited September 2013

    And use DzRenderMgr.getRendererList() and iterate over the array using getName() to learn the names to enter in the findRenderer command?

    Post edited by Richard Haseltine on
  • zigraphixzigraphix Posts: 2,787
    edited December 1969

    Thanks, Rob!

    Is there any way to choose these settings using the same format used by the "Save As Render Settings" results? That would allow the other scripts to stay in the DAZ Studio folder.

    Or is keeping scripts in the Content Library folder preferred?

    rbtwhiz said:
    // Get the render manager
    var oRenderMgr = App.getRenderMgr();
    // Find the scripted renderer
    var oRenderer = oRenderMgr.findRenderer( "DzScriptedRenderer" );
    // If we found the render
    if( oRenderer ){
     // Set the active renderer
     oRenderMgr.setActiveRenderer( oRenderer );
     // Set the [relative] definition file path;
     // relative to App.getResourcesPath() + "/Scripted Renderer/"
     oRenderer.setDefinitionFile( "Outline/Outline.dsa" );
    }

    -Rob

  • Richard HaseltineRichard Haseltine Posts: 100,939
    edited December 1969

    A script file should be usable anywhere a .duf file is, as far as I know.

  • rbtwhizrbtwhiz Posts: 2,250
    edited November 2015

     

    Richard Haseltine said:

    And use DzRenderMgr.getRendererList() and iterate over the array using getName() to learn the names to enter in the findRenderer command?

     

    DzRenderMgr::findRenderer() expects to receive the classname of the renderer, not the display name, so use something like the script below to get those:

    // Get the render managervar oRenderMgr = App.getRenderMgr();// Get the array of renderersvar aRenderers = oRenderMgr.getRendererList();// Initialize a variable for collecting class namesvar sMessage = "";// Iterate over the renderersfor( var i = 0; i < aRenderers.length; i += 1 ){ // If the string is not empty if( !sMessage.isEmpty() ){  // Add a newline character  sMessage = String("%1\n").arg( sMessage ); } // Add the classname of the renderer sMessage = String("%1%2").arg( sMessage ).arg( aRenderers[ i ].className() );}// Display a message with the class names of available renderersMessageBox.information( sMessage, "Renderers", "OK" );

     

    -Rob

    Post edited by Richard Haseltine on
  • zigraphixzigraphix Posts: 2,787
    edited December 1969

    A script file should be usable anywhere a .duf file is, as far as I know.

    Yes, but in the Scripted Renderer examples, the script that creates the interface and sets parameters "lives" in DAZ Studio/Resources, and the script that actually does the rendering is in DAZ Studio/Scripts/Support. If I use a script to redefine the Render Settings tab and set the parameters, I'll either need to keep matching code in both places, or users won't be able to select the script using the regular Scripted Renderer access.

    I'd like to create a duf that works like the Render Preset asset type, but sets up my Scripted Renderer elements, calling the UI script from DAZ Studio/Resources, if possible. If that can't be done, I'll put the UI script in the Content Library, because that will be easier for users, but it won't match the way Render Scripts work in the examples provided. I know Rob is a fan of consistency and standards in coding practices, and so am I.

  • rbtwhizrbtwhiz Posts: 2,250
    edited December 1969

    Added two new examples...
    DAZ Studio > v4.x > Reference Guide > Scripting > API Reference > Samples # Rendering # Scripted Renderer

    -Rob

  • zigraphixzigraphix Posts: 2,787
    edited December 1969

    rbtwhiz said:
    Added two new examples...
    DAZ Studio > v4.x > Reference Guide > Scripting > API Reference > Samples # Rendering # Scripted Renderer

    -Rob

    Awesome! Thank you so much! The "Scripted Renderer Save Preset" works perfectly! :)

Sign In or Register to comment.