Description : |
Below is the source for a script that is executed at render-time for a given DzRSLShader object. It can be used to set attributes, or values of hidden properties, or.... |
Concepts Covered : |
|
Source : ./samples/shader swapping/scripts/support/DAZ/rendertime/surface/ |
00001 // DAZ Studio version 3.0 filetype DAZ Script 00002 /********************************************************************** 00003 File: dzDefaultAttribs.dsa 00004 00005 Copyright © 2002-2009 DAZ Productions. All Rights Reserved. 00006 00007 This file is part of the DAZ Script Documentation. 00008 00009 This file may be used only in accordance with the DAZ Script 00010 license provided with the DAZ Script Documentation. 00011 00012 The contents of this file may not be disclosed to third parties, 00013 copied or duplicated in any form, in whole or in part, without the 00014 prior written permission of DAZ Productions, except as explicitly 00015 allowed in the DAZ Script license. 00016 00017 See http://www.daz3d.com to contact DAZ Productions or for more 00018 information about DAZ Script. 00019 **********************************************************************/ 00020 var oNODE = App.getRenderMgr().getActiveRenderer().getCurrentNode(); 00021 var oOWNER = Shader.getOwner(); 00022 00023 /*********************************************************************/ 00024 // --- Identification 00025 // If we've got a node 00026 if( oNODE ) 00027 { 00028 // Set the attribute 00029 Shader.setStringAttrib( "user", "string node", oNODE.name ); 00030 } 00031 // Set the attribute 00032 Shader.setStringAttrib( "identifier", "name", String("/%1/%2".arg(oNODE.name).arg(oOWNER.name) ); 00033 00034 // --- Opacity 00035 var sOpacity = "primitive"; 00036 // If we've got a node and it casts shadows 00037 if( oNODE && oNODE.castsShadow() ){ 00038 // Get the opacity property 00039 var oProperty = oOWNER.getOpacityProperty(); 00040 // If the property is mapped use "shader", otherwise use "primitive" 00041 sOpacity = ( oProperty.isMapped() ? "shader" : "primitive" ) ; 00042 Shader.setIntegerAttrib( "visibility", "integer transmission", 1 ); 00043 } 00044 // Set the attributes 00045 Shader.setStringAttrib( "shade", "string transmissionhitmode", sOpacity ); 00046 Shader.setStringAttrib( "shade", "string diffusehitmode", sOpacity ); 00047 //Shader.setStringAttrib( "shade", "string specularhitmode", "shader" );//default 00048 00049 // --- Glossiness 00050 var bGloss = false; 00051 // Find the glossiness linear adjustment property 00052 oProperty = oOWNER.findProperty( "Glossiness Linear Adjustment" ); 00053 // If the property was found and its a bool property 00054 if( oProperty && oProperty.className() == "DzBoolProperty" ) 00055 { 00056 // Get the propety value 00057 bGloss = oProperty.getBoolValue(); 00058 } 00059 00060 // Find the glossiness property 00061 oProperty = oOWNER.findProperty( "Glossiness" ); 00062 // If the property was found and its a float property 00063 if( oProperty && oProperty.className() == "DzFloatProperty" ) 00064 { 00065 // Get the current value 00066 var fValue = oProperty.getValue(); 00067 // If we need to adjust glossiness 00068 if( bGloss ) 00069 { 00070 // Adjust the value to match DzDefaultMaterial 00071 fValue = 1.02 - fValue; 00072 fValue = 1.0 - (fValue * fValue * fValue); 00073 } 00074 // Set the token 00075 Shader.setFloatToken( "GlossinessStrength", fValue ); 00076 } 00077 00078 // --- Raytrace 00079 var nTrace = 1; 00080 // Find the property for the whether or not to trace 00081 oProperty = oOWNER.findProperty( "Raytrace" ); 00082 // If the property was found and its a bool property 00083 if( oProperty && oProperty.className() == "DzBoolProperty" ) 00084 { 00085 // Get the property value 00086 var bValue = oProperty.getBoolValue(); 00087 // Convert the value to a number 00088 var nTrace = ( bValue ? 1 : 0 ); 00089 } 00090 // Set the attribute 00091 Shader.setIntegerAttrib( "visibility", "integer diffuse", nTrace ); 00092 Shader.setIntegerAttrib( "visibility", "integer specular", nTrace ); 00093 00094 // --- Shadows 00095 // Find the accept shadows property 00096 oProperty = oOWNER.findProperty( "Accept Shadows" ); 00097 // If the property was found and its a bool property 00098 if( oProperty && oProperty.className() == "DzBoolProperty" ) 00099 { 00100 // Set the token 00101 Shader.setFloatToken( "__noshadows", ( oProperty.getBoolValue() ? 0 : 1 ) ); 00102 } |