Digital Art Zone

 
     
DAZ Studio LQ and HQ Rendering Quality Preset Scripts
Posted: 12 April 2013 04:20 PM   [ Ignore ]
Active Member
RankRank
Total Posts:  698
Joined  2010-03-13

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 smile

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 
0nNodesi++ ) {
  oNode 
Scene.getNode);
  if( !
oNode {
   
continue;
  
}
  
  
var uberProperty oNode.findProperty"Occlusion Samples" );
  if( 
uberProperty )
  
{
   uberProperty
.setValue);
  
else
   continue;
  
  
uberProperty oNode.findProperty"Shading Rate" );
  if( 
uberProperty )
  
{
   uberProperty
.setValue10 );
  
}
   
  uberProperty 
oNode.findProperty"Max Error" );
  if( 
uberProperty )
  
{
   uberProperty
.setValue);
  
}

  uberProperty 
oNode.findProperty"Maximum Trace Distance" );
  if( 
uberProperty )
  
{
   uberProperty
.setValue150 );
   
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);

     
oProperty oOwner.findProperty"Shading Rate" );
     if ( 
oProperty )
      
oProperty.setValue10 );

     
oProperty oOwner.findProperty"Shadow Samples" );
     if ( 
oProperty )
      
oProperty.setValue32 );

     
oProperty oOwner.findProperty"Pct Shading Rate" );
     if ( 
oProperty )
      
oProperty.setValue10 );
    
}
   }
  }
 }
}

// Function to set materials (pwSurface2, uberSurface2, and uberAreaLight)
//
function adjustMaterialOptions() {
 
var mat = new DzShaderMaterial;
 
 var 
presetHelper = new DzPresetHelper;
 
 var 
mat.getNumMaterials();
 
 for ( var 
i++ ) {
    
var curMat mat.getMaterial);
    if ( 
curMat && curMat != mat && curMat.inherits"DzShaderMaterial" ) ) {
   
    
var curSettings = new DzSettings;
    
curMat.getAttributescurSettings );
    
    var 
curDefFile curSettings.getStringValue"DefinitionFile" );
    
    
delete curSettings;
    
    
presetHelper.setTargetElementcurMat );
    
    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 == {
       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" ).argg_oFILE.baseName() ).argg_oFILE.extension();

setBusyCursor();
beginUndo();

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

acceptUndoString"\"%1\"" ).argg_sSCRIPT_NAME ) );
clearBusyCursor();

delete g_oFILE
Profile
 
 
Posted: 13 April 2013 03:38 AM   [ Ignore ]   [ # 1 ]
Active Member
RankRank
Total Posts:  698
Joined  2010-03-13

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 
0nNodesi++ ) {
  oNode 
Scene.getNode);
  if( !
oNode {
   
continue;
  
}
  
  
var uberProperty oNode.findProperty"Occlusion Samples" );
  if( 
uberProperty )
  
{
   uberProperty
.setValue128 );
  
else
   continue;
  
  
uberProperty oNode.findProperty"Shading Rate" );
  if( 
uberProperty )
  
{
   uberProperty
.setValue0.2 );
  
}
   
  uberProperty 
oNode.findProperty"Max Error" );
  if( 
uberProperty )
  
{
   uberProperty
.setValue0.1 );
  
}

  uberProperty 
oNode.findProperty"Maximum Trace Distance" );
  if( 
uberProperty )
  
{
   uberProperty
.setValue150 );
   
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);

     
oProperty oOwner.findProperty"Shading Rate" );
     if ( 
oProperty )
      
oProperty.setValue0.2 );

     
oProperty oOwner.findProperty"Shadow Samples" );
     if ( 
oProperty )
      
oProperty.setValue32 );

     
oProperty oOwner.findProperty"Pct Shading Rate" );
     if ( 
oProperty )
      
oProperty.setValue0.2 );
    
}
   }
  }
 }
}

// Function to set materials (pwSurface2, uberSurface2, and uberAreaLight)
//
function adjustMaterialOptions() {
 
var mat = new DzShaderMaterial;
 
 var 
presetHelper = new DzPresetHelper;
 
 var 
mat.getNumMaterials();
 
 for ( var 
i++ ) {
    
var curMat mat.getMaterial);
    if ( 
curMat && curMat != mat && curMat.inherits"DzShaderMaterial" ) ) {
   
    
var curSettings = new DzSettings;
    
curMat.getAttributescurSettings );
    
    var 
curDefFile curSettings.getStringValue"DefinitionFile" );
    
    
delete curSettings;
    
    
presetHelper.setTargetElementcurMat );
    
    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 == {
       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" ).argg_oFILE.baseName() ).argg_oFILE.extension() );

setBusyCursor();
beginUndo();

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

acceptUndoString"\"%1\"" ).argg_sSCRIPT_NAME ) );
clearBusyCursor();

delete g_oFILE
Profile
 
 
Posted: 14 April 2013 01:07 AM   [ Ignore ]   [ # 2 ]
Active Member
Avatar
RankRank
Total Posts:  718
Joined  2012-07-21

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

 Signature 

my freebies at ShareCG
me at DeviantArt

Profile