How to set the default for a color parameter in a shaderdef?

35 views
Skip to first unread message

Stefano Jannuzzo

unread,
Jul 26, 2013, 12:05:55 PM7/26/13
to soft...@listproc.autodesk.com
Hi folks.
In a shaderdef define function, I can create a color param and set its default value to a mid gray by   

paramOptions = XSIFactory.CreateShaderParamDefOptions();
paramOptions.SetDefaultValue(0.5);
params.AddParamDef("color", siShaderDataTypeColor3, paramOptions);

Any idea how to set each channel independently?
Thanks. Stefano

Vincent Ullmann

unread,
Jul 26, 2013, 12:09:06 PM7/26/13
to soft...@listproc.autodesk.com
Hi,

i have something like this in my Shader-Definitions:

inputParameterOptions.SetDefaultValue([1, 1, 1])

Vladimir Jankijevic

unread,
Jul 26, 2013, 12:08:55 PM7/26/13
to soft...@listproc.autodesk.com
like this: paramOptions.SetDefaultValue( [0.5, 0.3, 0.2] )

Vincent Ullmann

unread,
Jul 26, 2013, 12:13:22 PM7/26/13
to soft...@listproc.autodesk.com
Becouse it partly fits on this Topic:

Does anyone know how to set the Viewport-Mapping in a Python-ShaderDefinition?

In a SPDL-File you can set a it via
ui "mapping"

Is there a similar function for Python?

Nicolas Burtnyk

unread,
Jul 26, 2013, 12:46:14 PM7/26/13
to soft...@listproc.autodesk.com
In C++ you do this to set the diffuse ui mapping (should be simple to port this to python):

diffuseParamDef.GetAttributes().Set(L"{8C80DEF3-1064-11d3-B0B7-00A0C982A112}",  L"{3515CC72-082C-11D0-91DE-00A024C78EE3}");

The GUID "{8C80DEF3-1064-11d3-B0B7-00A0C982A112}" means "ui mapping".
The GUID "{3515CC72-082C-11D0-91DE-00A024C78EE3}" is the XSI GUID for diffuse.

GUIDs for other shader parameters (like spec etc..) can be found by looking at the ui mapping lines in material-phong.spdl.

-Nicolas

Stefano Jannuzzo

unread,
Jul 26, 2013, 2:35:40 PM7/26/13
to soft...@listproc.autodesk.com
Thanks Vincent, Vladimir. Is this in python? It still doesn't work in jscript.

Vincent Ullmann

unread,
Jul 26, 2013, 2:37:37 PM7/26/13
to soft...@listproc.autodesk.com
"Is this in python?" == True

Stefano Jannuzzo

unread,
Jul 29, 2013, 11:53:14 AM7/29/13
to soft...@listproc.autodesk.com
I found the way in jscript after reading this

var paramDef = params.AddParamDef("scattering_color", siShaderDataTypeColor3, paramOptions);   
var subParamDef = paramDef.SubParamDefs;
subParamDef.GetParamDefByName("red").DefaultValue = 0.2;
subParamDef.GetParamDefByName("green").DefaultValue = 0.4;
subParamDef.GetParamDefByName("blue").DefaultValue = 0.6;
Reply all
Reply to author
Forward
0 new messages