DAZ Studio LQ and HQ Rendering Quality Preset Scripts

RenpatsuRenpatsu Posts: 828

Perhaps this is useful for some, basically in this thread are scripts which try to adjust some object, material, and renderer quality options in one go.

In DAZ Studio quality options can be very far spread, e.g. uberEnvironment2, several surface shaders (uberSurface2, pwSurface2, uberAreaLight), and Renderer options. So in this first post is my LQ aka "Low Quality" version of a script to tune some options and it focuses on properties that I usually like to adjust quickly. I also created a similar script for MQ and HQ (HQ is in post below) and essentially your interpretation of "low quality" (or MQ, HQ) might differ of course :)

I used the scripts quite a bit in DAZ Studio version 4.5.1.56, but they are not tested that much so there might be some bugs of course. Not sure if this works in a version lower than 4.5.1.56. However, the scripts should be decently easy to adjust by e.g. adding additional properties or even enable it to cover additional shaders - the principles should be similar. Also ... this is in no way optimised and doesn't give any control options etc. - "quick and dirty".

Note: The scripts only adjusts the render options of the currently selected renderer, so if e.g. 3Delight is selected, then those options get adjusted.

Edit: Adjusted the title and added HQ script to go with.

// DAZ Studio LQ quality preset script
//
// The script adjusts the following settings:
// * Rendering options
// * uberEnvironment2 settings
// * pwSurface2 settings
// * uberSurface2 settings
// * uberAreaLight settings
//
// Currently the script ignores any selection (nodes, surfaces) and just iterates through all. It just
// tries to find applicable settings. This means this script may take a moment to execute with larger
// scenes. This is not optimised either, so e.g. there is a full object loop plus a full
// material loop.
//

var foundUberEnvironment = 0;

// Function to adjust uberEnvironmentLights. This function will iterate through all nodes,
//  ignoring any selection at the moment.
//
// It doesn't actually check for uberEnvironment properly, but just has a look, if it
//  is able to adjust specific properties - so this is basically a quick & dirty version.
//
function adjustUberEnvironment() {
 var nNodes = Scene.getNumNodes();
 
 var oNode;
 for( var i = 0; i < nNodes; i++ ) {
  oNode = Scene.getNode( i );
  if( !oNode ) {
   continue;
  }
  
  var uberProperty = oNode.findProperty( "Occlusion Samples" );
  if( uberProperty )
  {
   uberProperty.setValue( 8 );
  } else
   continue;
  
  uberProperty = oNode.findProperty( "Shading Rate" );
  if( uberProperty )
  {
   uberProperty.setValue( 10 );
  }
   
  uberProperty = oNode.findProperty( "Max Error" );
  if( uberProperty )
  {
   uberProperty.setValue( 1 );
  }

  uberProperty = oNode.findProperty( "Maximum Trace Distance" );
  if( uberProperty )
  {
   uberProperty.setValue( 150 );
   foundUberEnvironment = 1;
  }
 }
}

// Function to set rendering options
//
// Currently standard 3Delight and some Point-based occlusion script properties get set
//
function adjustRenderingOptions() {
 var oRenderMgr = App.getRenderMgr();
 
 if ( oRenderMgr ) {
  var oRenderer = oRenderMgr.getActiveRenderer();
  
  if ( oRenderer ) {
   var oRenderOptions = oRenderMgr.getRenderOptions();
   
   if ( oRenderer.className() ==  "DzDelightRenderer" ) {
    oRenderOptions.rayTraceDepth = 2;
    oRenderOptions.shadowSamples = 32;
    oRenderOptions.shadingRate = 10;
    return;
   }
   
   if ( ( oRenderer.className() == "DzScriptedRenderer" ) && oRenderer.getRenderScript() &&
    ( oRenderer.getRenderScript() == "support/DAZ/ScriptedRenderer/Point-Based Occlusion/PointBasedOcclusionRenderScript.dsa" ) ) {
    var oOwner = oRenderer.getPropertyHolder();

    if ( oOwner ) {
     var oProperty = oOwner.findProperty( "Max Ray Depth" );
     if ( oProperty )
      oProperty.setValue( 2 );

     oProperty = oOwner.findProperty( "Shading Rate" );
     if ( oProperty )
      oProperty.setValue( 10 );

     oProperty = oOwner.findProperty( "Shadow Samples" );
     if ( oProperty )
      oProperty.setValue( 32 );

     oProperty = oOwner.findProperty( "Pct Shading Rate" );
     if ( oProperty )
      oProperty.setValue( 10 );
    }
   }
  }
 }
}

// Function to set materials (pwSurface2, uberSurface2, and uberAreaLight)
//
function adjustMaterialOptions() {
 var mat = new DzShaderMaterial;
 
 var presetHelper = new DzPresetHelper;
 
 var n = mat.getNumMaterials();
 
 for ( var i = 0 ; i < n ; i++ ) {
    var curMat = mat.getMaterial( i );
    if ( curMat && curMat != mat && curMat.inherits( "DzShaderMaterial" ) ) {
   
    var curSettings = new DzSettings;
    curMat.getAttributes( curSettings );
    
    var curDefFile = curSettings.getStringValue( "DefinitionFile" );
    
    delete curSettings;
    
    presetHelper.setTargetElement( curMat );
    
    if ( curDefFile && curDefFile == "support/Poseworks/shaderDefinitions/surface/pwSurface2Def.ds" ) {
    
     presetHelper.setNumericProperty( "Soften Samples", [ 2 ] );
     presetHelper.setNumericProperty( "Gather Samples", [ 8 ] );
     presetHelper.setNumericProperty( "Occlusion MaxDist", [ 150 ] );
     presetHelper.setNumericProperty( "Visible in Occlusion", [ 1 ] );
     if ( foundUberEnvironment == 1 ) {
       presetHelper.setNumericProperty( "Occlusion Strength", [ 0 ] );
     } else {
       presetHelper.setNumericProperty( "Occlusion Strength", [ 1 ] );
     }
     continue;
    }
    
    if ( curDefFile && curDefFile == "support/omnifreaker/shaderDefinitions/surface/omUberSurface2Def.ds" ) {

     presetHelper.setFloatProperty( "Subsurface Shading Rate", [ 10 ] );
     
     continue;
    }
    
    if ( curDefFile && curDefFile == "support/DAZ/Uber/shaderDefinitions/surface/omUberAreaLightDef.dse" ) {

     presetHelper.setNumericProperty( "Samples", [ 8 ] );
    }
    }
 }
 
 delete presetHelper;
 mat.deleteLater();
}

var g_oFILE = new DzFile( getScriptFileName() );
var g_sSCRIPT_NAME = String( "%1.%2" ).arg( g_oFILE.baseName() ).arg( g_oFILE.extension() );

setBusyCursor();
beginUndo();

adjustRenderingOptions();
adjustUberEnvironment();
adjustMaterialOptions();

acceptUndo( String( "\"%1\"" ).arg( g_sSCRIPT_NAME ) );
clearBusyCursor();

delete g_oFILE;
Post edited by Renpatsu on

Comments

  • RenpatsuRenpatsu Posts: 828
    edited December 1969

    This is the HQ script I use.

    Feel free to chime in as to what might be good to adjust and potentially how. These scripts are not rocket science and very simple, but can be quite helpful.

    // DAZ Studio HQ quality preset script
    //
    // The script adjusts the following settings:
    // * Rendering options
    // * uberEnvironment2 settings
    // * pwSurface2 settings
    // * uberSurface2 settings
    // * uberAreaLight settings
    //
    // Currently the script ignores any selection (nodes, surfaces) and just iterates through all. It just
    // tries to find applicable settings. This means this script may take a moment to execute with larger
    // scenes. This is not optimised either, so e.g. there is a full object loop plus a full
    // material loop.
    //
    
    var foundUberEnvironment = 0;
    
    // Function to adjust uberEnvironmentLights. This function will iterate through all nodes,
    //  ignoring any selection at the moment.
    //
    // It doesn't actually check for uberEnvironment properly, but just has a look, if it
    //  is able to adjust specific properties - so this is basically a quick & dirty version.
    //
    function adjustUberEnvironment() {
     var nNodes = Scene.getNumNodes();
     
     var oNode;
     for( var i = 0; i < nNodes; i++ ) {
      oNode = Scene.getNode( i );
      if( !oNode ) {
       continue;
      }
      
      var uberProperty = oNode.findProperty( "Occlusion Samples" );
      if( uberProperty )
      {
       uberProperty.setValue( 128 );
      } else
       continue;
      
      uberProperty = oNode.findProperty( "Shading Rate" );
      if( uberProperty )
      {
       uberProperty.setValue( 0.2 );
      }
       
      uberProperty = oNode.findProperty( "Max Error" );
      if( uberProperty )
      {
       uberProperty.setValue( 0.1 );
      }
    
      uberProperty = oNode.findProperty( "Maximum Trace Distance" );
      if( uberProperty )
      {
       uberProperty.setValue( 150 );
       foundUberEnvironment = 1;
      }
     }
    }
    
    // Function to set rendering options
    //
    // Currently standard 3Delight and some Point-based occlusion script properties get set
    //
    function adjustRenderingOptions() {
     var oRenderMgr = App.getRenderMgr();
     
     if ( oRenderMgr ) {
      var oRenderer = oRenderMgr.getActiveRenderer();
      
      if ( oRenderer ) {
       var oRenderOptions = oRenderMgr.getRenderOptions();
       
       if ( oRenderer.className() ==  "DzDelightRenderer" ) {
        oRenderOptions.rayTraceDepth = 4;
        oRenderOptions.shadowSamples = 64;
        oRenderOptions.shadingRate = 0.2;
        return;
       }
       
       if ( ( oRenderer.className() == "DzScriptedRenderer" ) && oRenderer.getRenderScript() &&
        ( oRenderer.getRenderScript() == "support/DAZ/ScriptedRenderer/Point-Based Occlusion/PointBasedOcclusionRenderScript.dsa" ) ) {
        var oOwner = oRenderer.getPropertyHolder();
    
        if ( oOwner ) {
         var oProperty = oOwner.findProperty( "Max Ray Depth" );
         if ( oProperty )
          oProperty.setValue( 4 );
    
         oProperty = oOwner.findProperty( "Shading Rate" );
         if ( oProperty )
          oProperty.setValue( 0.2 );
    
         oProperty = oOwner.findProperty( "Shadow Samples" );
         if ( oProperty )
          oProperty.setValue( 32 );
    
         oProperty = oOwner.findProperty( "Pct Shading Rate" );
         if ( oProperty )
          oProperty.setValue( 0.2 );
        }
       }
      }
     }
    }
    
    // Function to set materials (pwSurface2, uberSurface2, and uberAreaLight)
    //
    function adjustMaterialOptions() {
     var mat = new DzShaderMaterial;
     
     var presetHelper = new DzPresetHelper;
     
     var n = mat.getNumMaterials();
     
     for ( var i = 0 ; i < n ; i++ ) {
        var curMat = mat.getMaterial( i );
        if ( curMat && curMat != mat && curMat.inherits( "DzShaderMaterial" ) ) {
       
        var curSettings = new DzSettings;
        curMat.getAttributes( curSettings );
        
        var curDefFile = curSettings.getStringValue( "DefinitionFile" );
        
        delete curSettings;
        
        presetHelper.setTargetElement( curMat );
        
        if ( curDefFile && curDefFile == "support/Poseworks/shaderDefinitions/surface/pwSurface2Def.ds" ) {
         
         presetHelper.setNumericProperty( "Soften Samples", [ 16 ] );
         presetHelper.setNumericProperty( "Gather Samples", [ 256 ] );
         presetHelper.setNumericProperty( "Occlusion MaxDist", [ 150 ] );
         presetHelper.setNumericProperty( "Visible in Occlusion", [ 1 ] );
         if ( foundUberEnvironment == 1 ) {
           presetHelper.setNumericProperty( "Occlusion Strength", [ 0 ] );
         } else {
           presetHelper.setNumericProperty( "Occlusion Strength", [ 1 ] );
         }     
         continue;
        }
        
        if ( curDefFile && curDefFile == "support/omnifreaker/shaderDefinitions/surface/omUberSurface2Def.ds" ) {
    
         presetHelper.setFloatProperty( "Subsurface Shading Rate", [ 0.2 ] );
         
         continue;
        }
        
        if ( curDefFile && curDefFile == "support/DAZ/Uber/shaderDefinitions/surface/omUberAreaLightDef.dse" ) {
    
         presetHelper.setNumericProperty( "Samples", [ 256 ] );
        }
        }
     }
     
     delete presetHelper;
     mat.deleteLater();
    }
    
    var g_oFILE = new DzFile( getScriptFileName() );
    var g_sSCRIPT_NAME = String( "%1.%2" ).arg( g_oFILE.baseName() ).arg( g_oFILE.extension() );
    
    setBusyCursor();
    beginUndo();
    
    adjustRenderingOptions();
    adjustUberEnvironment();
    adjustMaterialOptions();
    
    acceptUndo( String( "\"%1\"" ).arg( g_sSCRIPT_NAME ) );
    clearBusyCursor();
    
    delete g_oFILE;
  • BlackFeather1973BlackFeather1973 Posts: 739
    edited December 1969

    Thanks for these, Renpatsu.
    A nice addition to my scripting-toolbox. :)

Sign In or Register to comment.