.spdl based shaders do not have ShaderParamDefs or ShaderParamDefOptions.

Matt



From: softimage-boun...@listproc.autodesk.com 
[mailto:softimage-boun...@listproc.autodesk.com] On Behalf Of Stephen Blair
Sent: Friday, January 11, 2013 11:12 AM
To: softimage@listproc.autodesk.com
Subject: Re: Change default settings?

My guess is the 
ShaderParamDef<http://download.autodesk.com/global/docs/softimage2013/en_us/sdkguide/si_om/ShaderParamDefOptions.SetDefaultValue.html>
 or the ShaderParamDefOptions.

On 11/01/2013 1:47 PM, Matt Lind wrote:
Shader .spdl files are really just input for generating a .preset file.  
Changing values in there doesn't have any effect until a new .preset is 
generated.  The preset is the glue between Softimage/mental ray and the shader 
.dll.   However, since .presets are no longer used as of Softimage 2011, it's 
anybody's guess where the default value resides.

Matt




From: 
softimage-boun...@listproc.autodesk.com<mailto:softimage-boun...@listproc.autodesk.com>
 [mailto:softimage-boun...@listproc.autodesk.com] On Behalf Of Stephen Blair
Sent: Friday, January 11, 2013 3:36 AM
To: softimage@listproc.autodesk.com<mailto:softimage@listproc.autodesk.com>
Subject: Re: Change default settings?

Hi Arvid

Yes, I noticed that yesterday too.
The menu command loads a preset, and in that case, the defaults come from the 
preset.


On 11/01/2013 3:35 AM, Arvid Björn wrote:

Thanks, that was very helpful!

It's working fine when you create shader nodes in the render tree, but it 
doesn't apply to Get->Material->Architectural, the node you get from that still 
uses the old defaults. Is it a different callback?

Anyway, here's what I came up.


------8<---------------

import win32com.client
from win32com.client import constants

from siutils import si        # Application
from siutils import log        # LogMessage
from siutils import disp    # win32com.client.Dispatch
from siutils import C        # win32com.client.constants

null = None
false = 0
true = 1

def XSILoadPlugin( in_reg ):
    in_reg.Author = "blairs"
    in_reg.Name = "ShaderDef Plug-in"
    in_reg.Major = 1
    in_reg.Minor = 0

    in_reg.RegisterEvent("CreateShaderDef",constants.siOnCreateShaderDef)

    return true

def XSIUnloadPlugin( in_reg ):
    strPluginName = in_reg.Name
    return true



def dispFix( badDispatch ):
    import win32com.client.dynamic
    # Re-Wraps a bad dispatch into a working one:
    return win32com.client.dynamic.Dispatch(badDispatch)

def setColorP(oDef, param, r, g, b):
    oB = oDef.InputParamDefs.GetParamDefByName( param )
    x = dispFix(oB).SubParamDefs
    oRed = x.GetParamDefByName( "red" )
    oGreen = x.GetParamDefByName( "green" )
    oBlue = x.GetParamDefByName( "blue" )
    oRed.DefaultValue = r
    oGreen.DefaultValue = g
    oBlue.DefaultValue = b
    return

def setValueP(oDef, param, v):
    oB = oDef.InputParamDefs.GetParamDefByName( param )
    oB.DefaultValue = v
    return

def setBoolP(oDef, param, b):
    oB = oDef.InputParamDefs.GetParamDefByName( param )
    oB.DefaultValue = b
    return


# Callback for the CreateShaderDef event.
def CreateShaderDef_OnEvent( in_ctxt ):
    oD = in_ctxt.GetAttribute("ShaderDef")
    sProgID = str(in_ctxt.GetAttribute("ProgID"))

    if "Softimage.mia_material_phen.1.0" in sProgID:
        setValueP(oD, "reflectivity", 0)
        setBoolP(oD, "ao_on", True)
        setValueP(oD, "ao_samples", 1)
        setValueP(oD, "refl_gloss_samples", 1)
        setValueP(oD, "refr_gloss_samples", 1)
        setValueP(oD, "refl_base_gloss_samples", 1)
        setColorP(oD, "ao_dark", 0,0,0)
        setColorP(oD, "diffuse", 0.75,0.75,0.75)
        setColorP(oD, "refl_base_color", 0,0,0)


#     Return value is ignored as this event can not be aborted.
    return true



------8<---------------




On Thu, Jan 10, 2013 at 3:02 PM, Stephen Blair 
<stephenrbl...@gmail.com<mailto:stephenrbl...@gmail.com>> wrote:
Here's a hint:
oRefl_Color = oDef.InputParamDefs.GetParamDefByName( "refl_color" )
print si.ClassName( oRefl_Color )

also, I had to use dispFix on oRefl_Color



On 10/01/2013 3:38 AM, Arvid Björn wrote:
Trying it again directly in the script editor, this line actually does work, 
just not in the context of the plugin for some reason:

oDef.InputParamDefs.GetParamDefByName("reflectivity").DefaultValue = 0.3

Either way, it's working now, but I can't figure out how to change a color 
value such as the diffuse color and possibly other more complex properties. I 
really can't find any reference to these objects in the SDK. The only thing 
that works is assigning single numbers, how do you assign a color to 
"DefaultValue"?

Sorry if this is obvious ;)


On Wed, Jan 9, 2013 at 3:50 PM, Arvid Björn 
<arvidbj...@gmail.com<mailto:arvidbj...@gmail.com>> wrote:
Great! I was a bit confused by the example as it did it all on one line of 
code. This wouldn't work:

oDef.InputParamDefs.GetParamDefByName( "reflectivity" ).DefaultValue = 0.3

I'll try yours, thanks!



On Wed, Jan 9, 2013 at 3:32 PM, Stephen Blair 
<stephenrbl...@gmail.com<mailto:stephenrbl...@gmail.com>> wrote:
Hi

If you wanted to change the default value, you do something like this:


from siutils import si        # Application
from siutils import log        # LogMessage
from siutils import disp    # win32com.client.Dispatch
from siutils import C        # win32com.client.constants

# Get ShaderDef for the Environment shader
sProgID = "Softimage.mia_material_phen.1.0"
oDef = si.GetShaderDef( sProgID )

# Get ShaderParamDef for the Tranformation parameter
oReflectivity = oDef.InputParamDefs.GetParamDefByName( "reflectivity" )

# Change the default value
oReflectivity.DefaultValue = 0.333









On 09/01/2013 8:58 AM, Arvid Björn wrote:

Honestly didn't know that existed, but I'd rather have it as a plugin on the 
workgroup so I can keep it general across our workstations and future versions, 
thanks though. =)




On Wed, Jan 9, 2013 at 2:39 PM, César Sáez 
<cesa...@gmail.com<mailto:cesa...@gmail.com>> wrote:
Or just use the preset manager :)

On Wed, Jan 9, 2013 at 2:33 PM, Arvid Björn 
<arvidbj...@gmail.com<mailto:arvidbj...@gmail.com>> wrote:
Thanks, sounds good! A default scene takes care of everything except default 
shader definitions.

Can't get it to work though, I'm using the example in that article to try and 
change the architectural shader, but using the examples and looking through the 
SDK I can't figure out how to actually set the values, which method or syntax 
should I use?

    if "Softimage.mia_material_phen.1.0" in sProgID:
        oDef.InputParamDefs.GetParamDefByName( "reflectivity" ) --> ???




On Wed, Jan 9, 2013 at 12:02 PM, Stephen Blair 
<stephenrbl...@gmail.com<mailto:stephenrbl...@gmail.com>> wrote:
You could use events eg OnNewScene.
Or create your own presets?

I'd avoid editing the factory SPDLs and presets (I think you can probably find 
a number of posts from Luc-Eric about defaults and spdls and the factory 
location)

For shaders, you can use events to override SPDL defaults with a 
OnCreateShaderDef
http://xsisupport.com/2012/02/27/overriding-spdl-defaults/





On 09/01/2013 5:20 AM, Arvid Björn wrote:
Hi,

Is it possible to change default settings of the rendering ppg, architectural 
shader settings, geo approx, lights etc?

There are so many things that I constantly edit because the default settings 
isn't really up to date. I've made a few script buttons for it, but I'd rather 
just have different default settings.

I'd be interested in hearing how you all solve this on a daily basis. Can you 
dig up the SPDLs and just edit those? Could it even be put in a workgroup so it 
works globally?


Cheers











Reply via email to