diff --git a/README.md b/README.md index 00cf27d..f8a9bf8 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ under an Apache 2.0 open source license. #### Requirements * Softimage 2015 SP1 -* Arnold 5.3.1.1 or newer +* Arnold 5.4.0.1 or newer * Python 2.6 or newer * Visual Studio 2012 (Windows) * GCC 4.2.4 (Linux) @@ -65,7 +65,7 @@ VS_HOME = r'C:/Program Files (x86)/Microsoft Visual Studio 11.0/VC' WINDOWS_KIT = r'C:/Program Files (x86)/Windows Kits/8.0' XSISDK_ROOT = r'C:/Program Files/Autodesk/Softimage 2015/XSISDK' -ARNOLD_HOME = r'C:/SolidAngle/Arnold-5.3.1.1/win64' +ARNOLD_HOME = r'C:/SolidAngle/Arnold-5.4.0.1/win64' TARGET_WORKGROUP_PATH = r'./Softimage_2015/Addons/SItoA' diff --git a/SConstruct b/SConstruct index a728cd1..a272f64 100644 --- a/SConstruct +++ b/SConstruct @@ -534,7 +534,7 @@ env.Install(os.path.join(env['TARGET_WORKGROUP_PATH'], bin_path), [str(SITOA[0]) str(SITOA_SHADERS[0])]) env.Install(os.path.join(env['TARGET_WORKGROUP_PATH'], bin_path), [glob.glob(os.path.join(ARNOLD_BINARIES, '*'))]) -env.Install(os.path.join(env['TARGET_WORKGROUP_PATH'], bin_path, '..'), [glob.glob(ARNOLD_PLUGINS)]) +env.Install(os.path.join(env['TARGET_WORKGROUP_PATH'], bin_path, '..', 'plugins'), [glob.glob(os.path.join(ARNOLD_PLUGINS, '*'))]) # Copying Scripting Plugins # (if you modify the files directly on workgroup they will be overwritted with trunk version) diff --git a/abuild.bat b/abuild.bat index 91d944b..429e709 100644 --- a/abuild.bat +++ b/abuild.bat @@ -1,3 +1,15 @@ +@echo off +set py=python + +REM Use python launcher if it's found in PATH. +WHERE py >nul 2>nul +IF NOT ERRORLEVEL 1 ( + set "py=py -2" +) + +@echo on + @REM invokes a local install of scons (forwarding all arguments) +@%py% contrib\scons\scons --site-dir=tools\site_scons %* -@python contrib\scons\scons --site-dir=tools\site_scons %* +@set py= diff --git a/config/custom_linux.py b/config/custom_linux.py index 458f116..e6ba45e 100644 --- a/config/custom_linux.py +++ b/config/custom_linux.py @@ -6,7 +6,7 @@ SHCXX = r'/usr/bin/gcc-4.2.4/bin/gcc-4.2.4' XSISDK_ROOT = r'/usr/Softimage/Softimage_2015/XSISDK' -ARNOLD_HOME = r'/usr/SolidAngle/Arnold-5.3.1.1/linux' +ARNOLD_HOME = r'/usr/SolidAngle/Arnold-5.4.0.1/linux' TARGET_WORKGROUP_PATH = './Softimage_2015/Addons/SItoA' diff --git a/config/custom_windows.py b/config/custom_windows.py index e9ef46e..61cd468 100644 --- a/config/custom_windows.py +++ b/config/custom_windows.py @@ -9,7 +9,7 @@ WINDOWS_KIT = r'C:/Program Files (x86)/Windows Kits/8.0' XSISDK_ROOT = r'C:/Program Files/Autodesk/Softimage 2015/XSISDK' -ARNOLD_HOME = r'C:/SolidAngle/Arnold-5.3.1.1/win64' +ARNOLD_HOME = r'C:/SolidAngle/Arnold-5.4.0.1/win64' TARGET_WORKGROUP_PATH = r'./Softimage_2015/Addons/SItoA' diff --git a/plugins/helpers/ArnoldLights.js b/plugins/helpers/ArnoldLights.js index cbd9bf8..5d70ab3 100644 --- a/plugins/helpers/ArnoldLights.js +++ b/plugins/helpers/ArnoldLights.js @@ -75,8 +75,8 @@ function AddPointLight_Execute(in_name) light.Parameters("LightArea").value = true; light.Parameters("LightAreaGeom").value = 3; // Mapping Arnold Light Parameter to XSI Light Parameter.. - var spotRadius = light.Parameters("LightAreaXformSX"); - spotRadius.AddExpression(light.FullName+".light.arnold_point_light.radius"); + var lightRadius = light.Parameters("LightAreaXformSX"); + lightRadius.AddExpression("this.light.point_light.radius"); return light; // return the light } @@ -110,8 +110,10 @@ function AddSpotLight_Execute(in_name) ApplyLightShader(lightPrim, "arnold_spot_light"); // Mapping Arnold Light Parameters to XSI Light Parameters.. - var spotRadius = lightPrim.Parameters("LightAreaXformSX"); - spotRadius.AddExpression(lightPrim.FullName+".light.arnold_spot_light.radius") + var coneAngle = lightPrim.Parameters("LightCone"); + coneAngle.AddExpression("this.light.spot_light.cone_angle"); + var lightRadius = lightPrim.Parameters("LightAreaXformSX"); + lightRadius.AddExpression("this.light.spot_light.radius"); lightPrim.LightArea = true; lightPrim.LightAreaGeom = 2; return lightPrim; @@ -143,6 +145,8 @@ function AddQuadLight_Execute(in_name) var name = in_name == null ? "Quad" : in_name; var light = GetPrimLight("Light_Box.Preset", name, "", null, null, null); var lightPrim = light.Light; + var lightType = lightPrim.Parameters("Type"); + lightType.Value = 1; // Infinite light gizmo ApplyLightShader(lightPrim, "arnold_quad_light"); return lightPrim; diff --git a/plugins/helpers/ArnoldMenu.js b/plugins/helpers/ArnoldMenu.js index 546b5fb..80a2dc7 100644 --- a/plugins/helpers/ArnoldMenu.js +++ b/plugins/helpers/ArnoldMenu.js @@ -278,7 +278,9 @@ function AddShadersSubMenu(in_menu) in_menu.AddSeparatorItem(); in_menu.AddCallbackItem("Standard Volume", "OnShadersMenu"); in_menu.AddSeparatorItem(); - in_menu.AddCallbackItem("Physical Sky", "OnShadersMenu"); + in_menu.AddCallbackItem("Physical Sky", "OnShadersMenu"); + in_menu.AddSeparatorItem(); + in_menu.AddCallbackItem("Clip Geo", "OnShadersMenu"); } @@ -521,6 +523,9 @@ function OnShadersMenu(in_ctxt) case "Operator": SITOA_AddShaderStack("Arnold.operator.1.0", "OutputShaderStack"); break; + case "Clip Geo": + SITOA_AddShader("Arnold.clip_geo.1.0", "surface"); + break; } } diff --git a/plugins/helpers/ArnoldProperties.js b/plugins/helpers/ArnoldProperties.js index cee09a1..7a1fd95 100644 --- a/plugins/helpers/ArnoldProperties.js +++ b/plugins/helpers/ArnoldProperties.js @@ -510,6 +510,7 @@ function AddParamsShape(in_prop) in_prop.AddParameter2("self_shadows", siBool, 1, 0, 1, 0, 5, 0, siPersistable|siAnimatable); in_prop.AddParameter2("receive_shadows", siBool, 1, 0, 1, 0, 5, 0, siPersistable|siAnimatable); in_prop.AddParameter2("export_pref", siBool, false, null, null, null, null); + in_prop.AddParameter2("export_nref", siBool, false, null, null, null, null); in_prop.AddParameter2("subdiv_smooth_derivs", siBool, false, null, null, null, null); in_prop.AddParameter2("sss_setname", siString, "", null, null, null, null, 0, siPersistable|siAnimatable); in_prop.AddParameter2("toon_id", siString, "", null, null, null, null, 0, siPersistable|siAnimatable); @@ -686,7 +687,8 @@ function arnold_parameters_DefineLayout(io_Context) xsiLayout.AddItem("invert_normals", "Invert Normals"); xsiLayout.AddItem("self_shadows", "Self Shadows"); xsiLayout.AddItem("receive_shadows", "Receive Shadows"); - xsiLayout.AddItem("export_pref", "Export Bind Pose (Pref)"); + xsiLayout.AddItem("export_pref", "Export Bind Pose Positions (Pref)"); + xsiLayout.AddItem("export_nref", "Export Bind Pose Normals (Nref)"); xsiLayout.AddItem("subdiv_smooth_derivs", "Smooth Subdiv Tangents"); xsiLayout.EndGroup(); diff --git a/plugins/helpers/ArnoldShaderDef.js b/plugins/helpers/ArnoldShaderDef.js index 54dc3cb..0f60aa8 100644 --- a/plugins/helpers/ArnoldShaderDef.js +++ b/plugins/helpers/ArnoldShaderDef.js @@ -24,6 +24,10 @@ function XSILoadPlugin( in_reg ) in_reg.RegisterShader("abs", 1, 0); in_reg.RegisterShader("add", 1, 0); in_reg.RegisterShader("ambient_occlusion", 1, 0); + in_reg.RegisterShader("aov_read_float", 1, 0); + in_reg.RegisterShader("aov_read_int", 1, 0); + in_reg.RegisterShader("aov_read_rgb", 1, 0); + in_reg.RegisterShader("aov_read_rgba", 1, 0); in_reg.RegisterShader("aov_write_float", 1, 0); in_reg.RegisterShader("aov_write_int", 1, 0); in_reg.RegisterShader("aov_write_rgb", 1, 0); @@ -39,13 +43,14 @@ function XSILoadPlugin( in_reg ) in_reg.RegisterShader("cell_noise", 1, 0); in_reg.RegisterShader("checkerboard", 1, 0); in_reg.RegisterShader("clamp", 1, 0); + in_reg.RegisterShader("clip_geo", 1, 0); in_reg.RegisterShader("closure", 1, 0); // SItoA in_reg.RegisterShader("color_convert", 1, 0); in_reg.RegisterShader("color_correct", 1, 0); in_reg.RegisterShader("color_jitter", 1, 0); in_reg.RegisterShader("compare", 1, 0); in_reg.RegisterShader("complement", 1, 0); - in_reg.RegisterShader("complex_ior", 1, 0); + in_reg.RegisterShader("complex_ior", 1, 0); // deprecated in_reg.RegisterShader("composite", 1, 0); in_reg.RegisterShader("cross", 1, 0); in_reg.RegisterShader("cryptomatte", 1, 0); @@ -140,15 +145,15 @@ function XSILoadPlugin( in_reg ) in_reg.RegisterShader("volume_sample_rgb", 1, 0); in_reg.RegisterShader("wireframe", 1, 0); // operators - in_reg.RegisterShader("operator", 1, 0); + in_reg.RegisterShader("disable", 1, 0); + in_reg.RegisterShader("collection", 1, 0); + in_reg.RegisterShader("include_graph", 1, 0); in_reg.RegisterShader("materialx", 1, 0); in_reg.RegisterShader("merge", 1, 0); + in_reg.RegisterShader("operator", 1, 0); in_reg.RegisterShader("set_parameter", 1, 0); - in_reg.RegisterShader("disable", 1, 0); - in_reg.RegisterShader("switch_operator", 1, 0); in_reg.RegisterShader("set_transform", 1, 0); - in_reg.RegisterShader("collection", 1, 0); - in_reg.RegisterShader("include_graph", 1, 0); + in_reg.RegisterShader("switch_operator", 1, 0); // in_reg.Help = "https://support.solidangle.com/display/A5SItoAUG/Shaders"; @@ -163,6 +168,14 @@ function Arnold_add_1_0_DefineInfo(in_ctxt) { return true; } function Arnold_add_1_0_Define(in_ctxt) { return true; } function Arnold_ambient_occlusion_1_0_DefineInfo(in_ctxt) { return true; } function Arnold_ambient_occlusion_1_0_Define(in_ctxt) { return true; } +function Arnold_aov_read_float_1_0_DefineInfo(in_ctxt) { return true; } +function Arnold_aov_read_float_1_0_Define(in_ctxt) { return true; } +function Arnold_aov_read_int_1_0_DefineInfo(in_ctxt) { return true; } +function Arnold_aov_read_int_1_0_Define(in_ctxt) { return true; } +function Arnold_aov_read_rgb_1_0_DefineInfo(in_ctxt) { return true; } +function Arnold_aov_read_rgb_1_0_Define(in_ctxt) { return true; } +function Arnold_aov_read_rgba_1_0_DefineInfo(in_ctxt) { return true; } +function Arnold_aov_read_rgba_1_0_Define(in_ctxt) { return true; } function Arnold_aov_write_float_1_0_DefineInfo(in_ctxt) { return true; } function Arnold_aov_write_float_1_0_Define(in_ctxt) { return true; } function Arnold_aov_write_int_1_0_DefineInfo(in_ctxt) { return true; } @@ -193,6 +206,8 @@ function Arnold_checkerboard_1_0_DefineInfo(in_ctxt) { return true; } function Arnold_checkerboard_1_0_Define(in_ctxt) { return true; } function Arnold_clamp_1_0_DefineInfo(in_ctxt) { return true; } function Arnold_clamp_1_0_Define(in_ctxt) { return true; } +function Arnold_clip_geo_1_0_DefineInfo(in_ctxt) { return true; } +function Arnold_clip_geo_1_0_Define(in_ctxt) { return true; } function Arnold_closure_1_0_DefineInfo(in_ctxt) { return true; } // SItoA function Arnold_closure_1_0_Define(in_ctxt) { return true; } // SItoA function Arnold_color_convert_1_0_DefineInfo(in_ctxt) { return true; } @@ -205,8 +220,8 @@ function Arnold_compare_1_0_DefineInfo(in_ctxt) { return true; } function Arnold_compare_1_0_Define(in_ctxt) { return true; } function Arnold_complement_1_0_DefineInfo(in_ctxt) { return true; } function Arnold_complement_1_0_Define(in_ctxt) { return true; } -function Arnold_complex_ior_1_0_DefineInfo(in_ctxt) { return true; } -function Arnold_complex_ior_1_0_Define(in_ctxt) { return true; } +function Arnold_complex_ior_1_0_DefineInfo(in_ctxt) { return true; } // deprecated +function Arnold_complex_ior_1_0_Define(in_ctxt) { return true; } // deprecated function Arnold_composite_1_0_DefineInfo(in_ctxt) { return true; } function Arnold_composite_1_0_Define(in_ctxt) { return true; } function Arnold_cross_1_0_DefineInfo(in_ctxt) { return true; } @@ -291,7 +306,7 @@ function Arnold_osl_1_0_DefineInfo(in_ctxt) { return true; } function Arnold_osl_1_0_Define(in_ctxt) { return true; } function Arnold_passthrough_1_0_DefineInfo(in_ctxt) { return true; } function Arnold_passthrough_1_0_Define(in_ctxt) { return true; } -// function Arnold_physical_sky_1_0_DefineInfo(in_ctxt) { return true; } +function Arnold_physical_sky_1_0_DefineInfo(in_ctxt) { return true; } // function Arnold_physical_sky_1_0_Define(in_ctxt) { return true; } function Arnold_pow_1_0_DefineInfo(in_ctxt) { return true; } function Arnold_pow_1_0_Define(in_ctxt) { return true; } @@ -393,61 +408,33 @@ function Arnold_volume_sample_rgb_1_0_DefineInfo(in_ctxt) { return true; } function Arnold_volume_sample_rgb_1_0_Define(in_ctxt) { return true; } function Arnold_wireframe_1_0_DefineInfo(in_ctxt) { return true; } function Arnold_wireframe_1_0_Define(in_ctxt) { return true; } + // operators +function Arnold_collection_1_0_DefineInfo(in_ctxt) { return true; } +function Arnold_collection_1_0_Define(in_ctxt) { return true; } +function Arnold_disable_1_0_DefineInfo(in_ctxt) { return true; } +function Arnold_disable_1_0_Define(in_ctxt) { return true; } +function Arnold_include_graph_1_0_DefineInfo(in_ctxt) { return true; } +function Arnold_include_graph_1_0_Define(in_ctxt) { return true; } function Arnold_materialx_1_0_DefineInfo(in_ctxt) { return true; } function Arnold_materialx_1_0_Define(in_ctxt) { return true; } function Arnold_merge_1_0_DefineInfo(in_ctxt) { return true; } function Arnold_merge_1_0_Define(in_ctxt) { return true; } function Arnold_set_parameter_1_0_DefineInfo(in_ctxt) { return true; } -function Arnold_set_parameter_1_0_Define(in_ctxt) { return true; } -function Arnold_disable_1_0_DefineInfo(in_ctxt) { return true; } -function Arnold_disable_1_0_Define(in_ctxt) { return true; } -function Arnold_switch_operator_1_0_DefineInfo(in_ctxt) { return true; } -function Arnold_switch_operator_1_0_Define(in_ctxt) { return true; } +//function Arnold_set_parameter_1_0_Define(in_ctxt) { return true; } function Arnold_set_transform_1_0_DefineInfo(in_ctxt) { return true; } function Arnold_set_transform_1_0_Define(in_ctxt) { return true; } -function Arnold_collection_1_0_DefineInfo(in_ctxt) { return true; } -function Arnold_collection_1_0_Define(in_ctxt) { return true; } -function Arnold_include_graph_1_0_DefineInfo(in_ctxt) { return true; } -function Arnold_include_graph_1_0_Define(in_ctxt) { return true; } +function Arnold_switch_operator_1_0_DefineInfo(in_ctxt) { return true; } +function Arnold_switch_operator_1_0_Define(in_ctxt) { return true; } + /////////////////////////////////////////////////// /////////////// shaders that require a dedicated UI /////////////////////////////////////////////////// -function Arnold_physical_sky_1_0_DefineInfo(in_ctxt) -{ - return true; -} - -function Arnold_physical_sky_1_0_Define(in_ctxt) +function Arnold_physical_sky_1_0_Define(in_ctxt) { - var h = SItoAShaderDefHelpers(); // helper object - var shaderDef = in_ctxt.GetAttribute("Definition"); - shaderDef.AddShaderFamily(siShaderFamilyTexture); - - // INPUT - params = shaderDef.InputParamDefs; - h.AddScalar (params, "turbidity", 3.0, 1.0, 10.0, 1.0, 10.0, true, false, true); - h.AddColor3 (params, "ground_albedo", 0.1, 0.1, 0.1, true, false, true); - h.AddScalar (params, "elevation", 45.0, 0.0, 180.0, 0.0, 180.0, true, false, true); - h.AddScalar (params, "azimuth", 90.0, 0.0, 360.0, 0.0, 360.0, true, false, true); - h.AddBoolean(params, "enable_sun", true, true, false, true); - h.AddScalar (params, "sun_size", 0.51, 0.0, 180.0, 0.0, 5.0, true, false, true); - h.AddScalar (params, "intensity", 1.0, 0.0, 10.0, 0.0, 10.0, true, false, true); - h.AddColor3 (params, "sky_tint", 1.0, 1.0, 1.0, true, false, true); - h.AddColor3 (params, "sun_tint", 1.0, 1.0, 1.0, true, false, true); - h.AddVector3(params, "X", 1.0, 0.0, 0.0, -1.0, 1.0, -1.0, 1.0); - h.AddVector3(params, "Y", 0.0, 1.0, 0.0, -1.0, 1.0, -1.0, 1.0); - h.AddVector3(params, "Z", 0.0, 0.0, 1.0, -1.0, 1.0, -1.0, 1.0); - - // OUTPUT - h.AddOutputColor4(shaderDef.OutputParamDefs); - - // Renderer definition - h.AddArnoldRendererDef(shaderDef); - physical_sky_Layout(shaderDef.PPGLayout); return true; @@ -455,29 +442,12 @@ function Arnold_physical_sky_1_0_Define(in_ctxt) function physical_sky_Layout(in_layout) { - in_layout.Clear(); - in_layout.SetAttribute(siUIHelpFile, "https://support.solidangle.com/display/SItoAUG/Physical+Sky"); - - item = in_layout.AddItem("turbidity", "Turbidity"); - item = in_layout.AddItem("ground_albedo", "Ground Albedo"); - item = in_layout.AddItem("elevation", "Elevation"); - item = in_layout.AddItem("azimuth", "Azimuth"); - item = in_layout.AddItem("intensity", "Intensity"); - item = in_layout.AddItem("sky_tint", "Sky Tint"); - item = in_layout.AddItem("enable_sun", "Enable Sun"); - item = in_layout.AddItem("sun_tint", "Sun Tint"); - item = in_layout.AddItem("sun_size", "Sun Size"); - in_layout.AddGroup("Orientation"); - in_layout.AddGroup(""); - item = in_layout.AddItem("X", "X"); - item = in_layout.AddItem("Y", "Y"); - item = in_layout.AddItem("Z", "Z"); - in_layout.EndGroup(); - in_layout.AddRow(); - item = in_layout.AddButton("SetExpression", "Set Expression"); - item = in_layout.AddButton("RemoveExpression", "Remove Expression"); - in_layout.EndRow(); - in_layout.EndGroup(); + in_layout.SetAttribute(siUIHelpFile, "https://support.solidangle.com/display/SItoAUG/Physical+Sky"); + + in_layout.AddRow(); + item = in_layout.AddButton("SetExpression", "Set Expression"); + item = in_layout.AddButton("RemoveExpression", "Remove Expression"); + in_layout.EndRow(); in_layout.SetAttribute(siUILogicPrefix, "physical_sky_"); } @@ -485,12 +455,20 @@ function physical_sky_Layout(in_layout) function physical_sky_OnInit() { physical_sky_enable_sun_OnChanged(); + physical_sky_use_degrees_OnChanged(); +} + +function physical_sky_use_degrees_OnChanged() +{ + PPG.azimuth.Enable(PPG.use_degrees.Value); + PPG.elevation.Enable(PPG.use_degrees.Value); + PPG.sun_direction.Enable(!PPG.use_degrees.Value); } function physical_sky_enable_sun_OnChanged() { - PPG.sun_size.Enable(PPG.enable_sun.Value); - PPG.sun_tint.Enable(PPG.enable_sun.Value); + PPG.sun_size.Enable(PPG.enable_sun.Value); + PPG.sun_tint.Enable(PPG.enable_sun.Value); } // Xx = cy*cz; @@ -576,3 +554,62 @@ function Arnold_operator_1_0_Define(in_ctxt) return true; } + +function Arnold_set_parameter_1_0_Define(in_ctxt) +{ + var h = SItoAShaderDefHelpers(); // helper object + + var shaderDef = in_ctxt.GetAttribute("Definition"); + shaderDef.AddShaderFamily(siShaderFamilyTexture); + + // INPUT + params = shaderDef.InputParamDefs; + + h.AddBoolean(params, "enable", true, true, false, true); + + paramOptions = XSIFactory.CreateShaderParamDefOptions(); + paramOptions.SetLongName("Inputs"); + h.SetCapability(paramOptions, false, true, true); + params.AddArrayParamDef("inputs", siShaderDataTypeReference, paramOptions); + + h.AddString(params, "selection", ""); + + paramOptions = XSIFactory.CreateShaderParamDefOptions(); + paramOptions.SetLongName("Assignments"); + var paramDef = params.AddArrayParamDef("assignments", siShaderDataTypeStructure, paramOptions); + var subParamDefs = paramDef.ItemDef.SubParamDefs; + + paramOptions = XSIFactory.CreateShaderParamDefOptions(); + h.SetCapability(paramOptions, true, false, true); + paramOptions.SetDefaultValue(true); + paramOptions.SetLongName("Enable"); + subParamDefs.AddParamDef("enable_assignment", siShaderDataTypeBoolean, paramOptions); + + paramOptions = XSIFactory.CreateShaderParamDefOptions(); + h.SetCapability(paramOptions, false, false, true); + paramOptions.SetLongName("Assignment"); + subParamDefs.AddParamDef("assignment", siShaderDataTypeString, paramOptions); + + // OUTPUT + h.AddOutputNode(shaderDef.OutputParamDefs); + + // Renderer definition + h.AddArnoldRendererDef(shaderDef); + + set_parameter_Layout(shaderDef.PPGLayout); + + return true; +} + +function set_parameter_Layout(in_layout) +{ + in_layout.Clear(); + in_layout.SetAttribute(siUIHelpFile, "https://docs.arnoldrenderer.com/display/A5NodeRef/set_parameter"); + + item = in_layout.AddItem("enable", "Enable"); + item = in_layout.AddItem("inputs", "Inputs"); + item = in_layout.AddItem("selection", "Selection"); + item = in_layout.AddItem("assignments"); + + in_layout.SetAttribute(siUILogicPrefix, "set_parameter_"); +} diff --git a/plugins/helpers/ArnoldShaderDefHelpers.js b/plugins/helpers/ArnoldShaderDefHelpers.js index af35eec..71fe774 100644 --- a/plugins/helpers/ArnoldShaderDefHelpers.js +++ b/plugins/helpers/ArnoldShaderDefHelpers.js @@ -245,6 +245,13 @@ function ShaderHelperObj() paramDef.MainPort = false; } + this.AddOutputNode = function(in_params) + { + paramOptions = XSIFactory.CreateShaderParamDefOptions(); + paramDef = in_params.AddParamDef("out", siShaderDataTypeReference, paramOptions); + paramDef.MainPort = false; + } + this.AddArnoldRendererDef = function(in_shaderDef) { var h = SItoAToolHelper(); diff --git a/plugins/sitoa/common/ParamsCommon.cpp b/plugins/sitoa/common/ParamsCommon.cpp index 91cccab..835f3cd 100644 --- a/plugins/sitoa/common/ParamsCommon.cpp +++ b/plugins/sitoa/common/ParamsCommon.cpp @@ -79,6 +79,9 @@ CStatus LoadParameterValue(AtNode *in_node, const CString &in_entryName, const C in_entryName == L"ScalarSwitch" || in_entryName == L"Vector3Switch") return LoadArraySwitcherParameter(in_node, in_param, in_frame, arrayElement, in_ref); + + if (in_entryName == L"set_parameter" && in_paramName == L"assignments") + return LoadArrayAssignmentParameter(in_node, in_param, in_frame, arrayElement, in_ref); } // Compound param (with subcomponents) diff --git a/plugins/sitoa/common/ParamsShader.cpp b/plugins/sitoa/common/ParamsShader.cpp index e91433e..a4a6c6b 100644 --- a/plugins/sitoa/common/ParamsShader.cpp +++ b/plugins/sitoa/common/ParamsShader.cpp @@ -232,65 +232,6 @@ CStatus LoadShaderParameter(AtNode* in_node, const CString &in_entryName, Parame } CNodeSetter::SetString(in_node, aiParamName, paramValue.GetAsciiString()); } - else if (in_entryName == L"set_parameter" && in_param.GetScriptName() == L"assignment") - { - // set_parameters could be used to override a shader on a node - // since sitoa shaders have their name translated, we should do a name lookup and translate the name - AtArray* entries = AiArrayAllocate(paramArray.GetCount(), 1, AI_TYPE_STRING); - AiNodeSetArray(in_node, in_param.GetScriptName().GetAsciiString(), entries); - - // Iterate through all the parameters of the parameters array - for (LONG i=0; iShaderMap().Get(surfaceShader, in_frame); - if (!shaderNode) - shaderNode = LoadShader(surfaceShader, in_frame, in_ref, RECURSE_FALSE); - } - } - - if (shaderNode) - { - CString shaderName = CNodeUtilities().GetName(shaderNode); - CString newParamValue = L"shader = \"" + shaderName + "\""; - AiArraySetStr(entries, i, newParamValue.GetAsciiString()); - ordinaryParamLoad = false; - } - } - } - if (ordinaryParamLoad) - LoadShaderParameter(in_node, in_entryName, theParam, in_frame, in_ref, in_recursively, paramArray.GetScriptName(), i); - } - } // end of special case for set_parameter operator else { AtArray *values(NULL); @@ -312,6 +253,14 @@ CStatus LoadShaderParameter(AtNode* in_node, const CString &in_entryName, Parame AiNodeSetArray(in_node, "values", values); AiNodeSetArray(in_node, "index", index); } + else if (in_entryName == L"set_parameter") + { + AtArray* assignments = AiArrayAllocate(paramArray.GetCount(), 1, AI_TYPE_STRING); + AtArray* enable_assignments = AiArrayAllocate(paramArray.GetCount(), 1, AI_TYPE_BOOLEAN); + + AiNodeSetArray(in_node, "assignment", assignments); + AiNodeSetArray(in_node, "enable_assignment", enable_assignments); + } else { // array type @@ -487,6 +436,90 @@ CStatus LoadArraySwitcherParameter(AtNode *in_node, const Parameter &in_param, d } +// Load the n-th element of the asignments array parameter of the set_parameter operator. A dedicated function +// is needed, because the array has elements of struct type (enable_assignment-assignment) that can't be parsed otherwise +// +// @param *in_node the Arnold shader node +// @param in_param the n-th Item parameter of the assignments array +// @param in_frame the frame time. +// @param in_arrayElement the index of the array, so the n that in_param refers to +// @param in_ref the object owning the shader. +// +// @return CStatus::OK +// +CStatus LoadArrayAssignmentParameter(AtNode *in_node, const Parameter &in_param, double in_frame, int in_arrayElement, CRef in_ref) +{ + AtArray *assignments = AiNodeGetArray(in_node, "assignment"); + AtArray *enable_assignments = AiNodeGetArray(in_node, "enable_assignment"); + + // this gets the Item container, with the index-value pair + CParameterRefArray paramsArray = in_param.GetParameters(); + + for (LONG i=0; iShaderMap().Get(surfaceShader, in_frame); + if (!shaderNode) + shaderNode = LoadShader(surfaceShader, in_frame, in_ref, RECURSE_FALSE); + } + } + + if (shaderNode) + { + CString shaderName = CNodeUtilities().GetName(shaderNode); + CString newParamValue = L"shader = \"" + shaderName + "\""; + AiArraySetStr(assignments, in_arrayElement, newParamValue.GetAsciiString()); + ordinaryParamLoad = false; + } + } + } + if (ordinaryParamLoad) + AiArraySetStr(assignments, in_arrayElement, paramValue.GetAsciiString()); + } + + return CStatus::OK; +} + + Shader GetShaderFromSource(const CRef &in_refCnxSrc) { diff --git a/plugins/sitoa/common/ParamsShader.h b/plugins/sitoa/common/ParamsShader.h index a2079ee..ec11ee0 100644 --- a/plugins/sitoa/common/ParamsShader.h +++ b/plugins/sitoa/common/ParamsShader.h @@ -27,6 +27,8 @@ CStatus LoadShaderParameters(AtNode* in_node, CRefArray &in_paramsArray, double CStatus LoadShaderParameter(AtNode* in_node, const CString &in_entryName, Parameter &in_param, double in_frame, const CRef &in_ref, bool in_recursively, const CString& in_arrayParamName=CString(), int in_arrayElement=-1); // Load the n-th element of the array parameters of the array switcher shaders. CStatus LoadArraySwitcherParameter(AtNode *in_node, const Parameter &in_param, double in_frame, int in_arrayElement, CRef in_ref); +// Load the n-th element of the asignments array parameter of the set_parameter operator. +CStatus LoadArrayAssignmentParameter(AtNode *in_node, const Parameter &in_param, double in_frame, int in_arrayElement, CRef in_ref); // Get the shader from a given source Shader GetShaderFromSource(const CRef &in_refCnxSrc); // Get the shader from a parameter diff --git a/plugins/sitoa/loader/Polymeshes.cpp b/plugins/sitoa/loader/Polymeshes.cpp index 4a271f9..fd80ba2 100644 --- a/plugins/sitoa/loader/Polymeshes.cpp +++ b/plugins/sitoa/loader/Polymeshes.cpp @@ -1602,6 +1602,46 @@ void CMesh::ExportPref(double in_frame) } +// Export the nref normals, ie the normals at the modeling stage +// https://github.com/Autodesk/sitoa/issues/78 +// +// @param in_frame The frame time +// +void CMesh::ExportNref(double in_frame) +{ + // Export the Nref data if checked + if (!(bool)ParAcc_GetValue(m_paramProperty, L"export_nref", in_frame)) + return; + + AiNodeDeclare(m_node, "Nref", "indexed VECTOR"); // Nrefidxs seems to be defined automatically by this. + + PolygonMesh polyMeshBindPose = CObjectUtilities().GetGeometryAtFrame(m_xsiObj, siConstructionModeModeling, in_frame); + CGeometryAccessor geoAccessorBindPose = polyMeshBindPose.GetGeometryAccessor(siConstructionModeModeling, siCatmullClark, 0, false, + m_useDiscontinuity, m_discontinuityAngle); + + CLongArray NodeIndicesBindPose; + geoAccessorBindPose.GetNodeIndices(NodeIndicesBindPose); + AtArray* nidxsBindPose = AiArrayCopy(LongArrayToUIntArray(NodeIndicesBindPose)); + LONG nodeCountBindPose = AiArrayGetNumElements(nidxsBindPose); + + AtArray* nlistBindPose = AiArrayAllocate(nodeCountBindPose, 1, AI_TYPE_VECTOR); + CFloatArray nodeNormalsBindPose; + + if (m_hasIceNodeUserNormal) + GetIceNodeUserNormals(polyMeshBindPose, nodeNormalsBindPose); + else // Eric Mootz for #704 + GetGeoAccessorNormals(geoAccessorBindPose, nodeCountBindPose, nodeNormalsBindPose); + + for (LONG i=0; i < nodeCountBindPose; ++i) + { + AiArraySetVec(nlistBindPose, i, AtVector((float)nodeNormalsBindPose[3*i], (float)nodeNormalsBindPose[3*i + 1], (float)nodeNormalsBindPose[3*i + 2])); + } + + AiNodeSetArray(m_node, "Nrefidxs", nidxsBindPose); + AiNodeSetArray(m_node, "Nref", nlistBindPose); +} + + // Export the visibility, sidedness, custom parameters, user options and blob data // // @param in_frame The frame time @@ -1727,6 +1767,7 @@ CStatus LoadSinglePolymesh(X3DObject &in_xsiObj, double in_frame, CRefArray &in_ mesh.ExportEnvironment(); mesh.ExportLightGroup(); mesh.ExportPref(in_frame); + mesh.ExportNref(in_frame); mesh.ExportMotionStartEnd(); mesh.ExportVizSidednessAndOptions(in_frame); diff --git a/plugins/sitoa/loader/Polymeshes.h b/plugins/sitoa/loader/Polymeshes.h index 4afef51..92e1104 100644 --- a/plugins/sitoa/loader/Polymeshes.h +++ b/plugins/sitoa/loader/Polymeshes.h @@ -119,6 +119,8 @@ class CMesh void ExportSubdivision(double in_frame); // Export the pref points, ie the points at the modeling stage void ExportPref(double in_frame); + // Export the nref normals, ie the normals at the modeling stage + void ExportNref(double in_frame); // Export the visibility, sidedness, custom parameters, user options and blob data void ExportVizSidednessAndOptions(double in_frame); // Export motion_start, motion_end diff --git a/plugins/sitoa/loader/Properties.cpp b/plugins/sitoa/loader/Properties.cpp index b753854..c192ec5 100644 --- a/plugins/sitoa/loader/Properties.cpp +++ b/plugins/sitoa/loader/Properties.cpp @@ -297,6 +297,7 @@ void LoadArnoldParameters(AtNode* in_node, CParameterRefArray &in_paramsArray, d { // sss does not apply on curves, points, etc (just polymesh), so skip these params if ( !strcmp(charParamName, "export_pref") || + !strcmp(charParamName, "export_nref") || !strcmp(charParamName, "sss_setname")) { if (!isMesh) diff --git a/plugins/sitoa/loader/ShaderDef.cpp b/plugins/sitoa/loader/ShaderDef.cpp index 0fd1eed..8ac9640 100644 --- a/plugins/sitoa/loader/ShaderDef.cpp +++ b/plugins/sitoa/loader/ShaderDef.cpp @@ -565,8 +565,8 @@ CString CShaderDefShader::Define(const bool in_clone_vector_map) m_sd.PutDisplayName(m_name + L" (deprecated)"); m_sd.AddRendererDef(L"Arnold Render"); - - if (m_name == L"physical_sky") // defined in js, just categorize and bail out + + if (m_name == L"set_parameter") // defined in js, just categorize and bail out return L""; vector ::iterator it; @@ -813,6 +813,15 @@ void CShaderDefSet::Load(const CString &in_plugin_origin_path) if (shader_def.m_so_name == L"core" && shader_def.m_is_camera_node) continue; + // xsibatch needs to completely skip the shaders defined in ArnoldShaderDef.js + // there's no need to categorize them when in batch anyway + // https://github.com/Autodesk/sitoa/issues/77 + if (!Application().IsInteractive()) + { + if (node_name == L"set_parameter") + continue; + } + progId = shader_def.Define(); // build parameters and the UI if (!progId.IsEmpty()) // enter in the list only the shaders whose definition was actually created diff --git a/plugins/sitoa/renderer/RenderInstance.cpp b/plugins/sitoa/renderer/RenderInstance.cpp index 24c257f..0de8a26 100644 --- a/plugins/sitoa/renderer/RenderInstance.cpp +++ b/plugins/sitoa/renderer/RenderInstance.cpp @@ -389,6 +389,7 @@ CRef CRenderInstance::GetUpdateType(const CRef &in_ref, eUpdateType &out_updateT incompatible.Add(L"skip_license_check"); incompatible.Add(L"abort_on_license_fail"); incompatible.Add(L"export_pref"); + incompatible.Add(L"export_nref"); incompatible.Add(L"subdiv_smooth_derivs"); // #1240 incompatible.Add(L"procedurals_path"); diff --git a/plugins/sitoa/version.cpp b/plugins/sitoa/version.cpp index a9addcd..26362a6 100644 --- a/plugins/sitoa/version.cpp +++ b/plugins/sitoa/version.cpp @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations #include #define SITOA_MAJOR_VERSION_NUM 5 -#define SITOA_MINOR_VERSION_NUM 3 +#define SITOA_MINOR_VERSION_NUM 4 #define SITOA_FIX_VERSION L"0" diff --git a/shaders/metadata/arnold_shaders.mtd b/shaders/metadata/arnold_shaders.mtd index cf6229b..768ad66 100644 --- a/shaders/metadata/arnold_shaders.mtd +++ b/shaders/metadata/arnold_shaders.mtd @@ -85,6 +85,34 @@ desc STRING "If on, the tracing works in inclusive mode, else in exclusive, as d [attr self_only] desc STRING "Gather occlusion against the shaded object only." +############################################################################## +[node aov_read_float] +soft.category STRING "AOV" + +[attr aov_name] +desc STRING "Name of the AOV." + +############################################################################## +[node aov_read_int] +soft.category STRING "AOV" + +[attr aov_name] +desc STRING "Name of the AOV." + +############################################################################## +[node aov_read_rgb] +soft.category STRING "AOV" + +[attr aov_name] +desc STRING "Name of the AOV." + +############################################################################## +[node aov_read_rgba] +soft.category STRING "AOV" + +[attr aov_name] +desc STRING "Name of the AOV." + ############################################################################## [node aov_write_float] soft.label STRING "AOV Write Float" @@ -590,6 +618,19 @@ desc STRING "The minimum value for the color channels to be used in the output." [attr max_color] desc STRING "The maximum value for the color channels to be used in the output." +############################################################################## +[node clip_geo] +soft.category STRING "Utility" + +[attr intersection] +desc STRING "The color or shader applied to the result of the clipping." + +[attr trace_set] +desc STRING "It is possible to tag objects to be part of one or many trace sets. You can use trace sets to control which objects are clipped." + +[attr inclusive] +desc STRING "If on, the tracing works in inclusive mode, else in exclusive, as described above." + # SItoA specific ############################################################################## [node closure] @@ -2253,11 +2294,12 @@ soft.inspectable BOOL false ############################################################################## [node physical_sky] soft.category STRING "Environment" -soft.order STRING "use_degrees azimuth elevation sun_direction enable_sun sun_size sun_tint sky_tint ground_albedo intensity turbidity X Y Z" +soft.order STRING "turbidity ground_albedo use_degrees azimuth elevation sun_direction enable_sun sun_size sun_tint sky_tint intensity " +"BeginGroup Orientation X Y Z EndGroup" [attr use_degrees] linkable BOOL false -soft.label STRING "Azimuth / Elevation" +soft.label STRING "Use Azimuth / Elevation" desc STRING "Switch between Azimuth/Elevation mode and Direction for defining the sun position. " [attr azimuth] diff --git a/testsuite/XSIProject/Scenes/test_0268/data/test.scn b/testsuite/XSIProject/Scenes/test_0268/data/test.scn index db86eca..8f3c5a1 100644 Binary files a/testsuite/XSIProject/Scenes/test_0268/data/test.scn and b/testsuite/XSIProject/Scenes/test_0268/data/test.scn differ diff --git a/testsuite/XSIProject/Scenes/test_0272/README b/testsuite/XSIProject/Scenes/test_0272/README new file mode 100644 index 0000000..17c914b --- /dev/null +++ b/testsuite/XSIProject/Scenes/test_0272/README @@ -0,0 +1,5 @@ +Export Nref + +Github #78 + +author: Jens Lindgren diff --git a/testsuite/XSIProject/Scenes/test_0272/data/test.scn b/testsuite/XSIProject/Scenes/test_0272/data/test.scn new file mode 100644 index 0000000..a4d6ea3 Binary files /dev/null and b/testsuite/XSIProject/Scenes/test_0272/data/test.scn differ diff --git a/testsuite/XSIProject/Scenes/test_0272/ref/reference.log b/testsuite/XSIProject/Scenes/test_0272/ref/reference.log new file mode 100644 index 0000000..73156e8 --- /dev/null +++ b/testsuite/XSIProject/Scenes/test_0272/ref/reference.log @@ -0,0 +1,57 @@ +======================================================= + Autodesk Softimage 13.2.163.0 +======================================================= + +License information: using [Processing] +00:00:00 208MB | log started Fri Aug 16 00:23:54 2019 +00:00:00 208MB | Arnold 5.4.0.0 [b7d9819c] windows icc-17.0.2 oiio-2.1.0 osl-1.11.0 vdb-4.0.0 clm-1.0.3.513 rlm-12.4.2 optix-6.0.0 2019/07/26 08:50:52 +00:00:00 208MB | running on Jenus, pid=33684 +00:00:00 208MB | 1 x Intel(R) Core(TM) i7-2600K CPU @ 3.40GHz (4 cores, 8 logical) with 16333MB +00:00:00 208MB | NVIDIA driver version 430.86 (Optix 60102) +00:00:00 208MB | GPU 0: GeForce GTX 1070 @ 1771MHz (compute 6.1) with 8192MB (6789MB available) (NVLink:0) +00:00:00 208MB | Windows 8 Professional (version 6.2, build 9200) +00:00:00 208MB | soft limit for open files raised from 512 to 2048 +00:00:00 208MB | +00:00:00 208MB | loading plugins from C:\Users\lindg\GitHub\sitoa\dist\Softimage_2015_SP2\Addons\SItoA\Application\Plugins\bin\nt-x86-64\..\plugins ... +00:00:00 208MB | loaded 4 plugins from 2 lib(s) in 0:00.00 +00:00:00 208MB | loading plugins from C:\Users\lindg\GitHub\sitoa\dist\Softimage_2015_SP2\Addons\SItoA\Application\Plugins\bin\nt-x86-64 ... +00:00:00 209MB | loaded 103 plugins from 1 lib(s) in 0:00.03 + + + + +00:00:00 217MB | +00:00:00 217MB | releasing resources +00:00:00 215MB | Arnold shutdown +// INFO : [sitoa] SItoA 5.4.0 win loaded. +// INFO : [sitoa] Arnold 5.4.0.0 detected. +InstallCustomPreferences("ArnoldRenderPreferences", "Arnold Render"); +COMMAND: -processing -script "execute_test.js" -main main +// INFO : C:\Users\lindg\GitHub\sitoa\dist\Softimage_2015_SP2\Addons\SItoA\Application\Plugins\bin\nt-x86-64\ +>Loading: C:\Users\lindg\GitHub\sitoa\build\windows_x86_64\msvc_opt\si_13000\testsuite\test_0272\test.scn... +// INFO : 4034 - Loaded scene was created with build number: 13.2.163.0 - compatibility version: 1300 +OpenScene("C:\\Users\\lindg\\GitHub\\sitoa\\build\\windows_x86_64\\msvc_opt\\si_13000\\testsuite\\test_0272\\test.scn", null, null); +SetValue("Passes.RenderOptions.ImageLockAspectRatio", false, null); +SetValue("Passes.RenderOptions.ImageWidth", 160, null); +SetValue("Passes.RenderOptions.ImageHeight", 120, null); +SetValue("Passes.Default_Pass.Main.Filename", "C:\\Users\\lindg\\GitHub\\sitoa\\build\\windows_x86_64\\msvc_opt\\si_13000\\testsuite\\test_0272\\testrender.####.tif", null); +SetValue("Passes.Default_Pass.Main.Format", "tif", null); +SetValue("Passes.Arnold_Render_Options.output_tiff_tiled", 0, null); +SetValue("Passes.Arnold_Render_Options.enable_log_file", true, null); +SetValue("Passes.Arnold_Render_Options.log_level", 1, null); +SetValue("Passes.Arnold_Render_Options.output_file_tagdir_log", "C:\\Users\\lindg\\GitHub\\sitoa\\build\\windows_x86_64\\msvc_opt\\si_13000\\testsuite\\test_0272", null); +SetValue("Passes.Arnold_Render_Options.textures_path", "C:\\Users\\lindg\\GitHub\\sitoa\\testsuite\\XSIProject\\Pictures", null); +SetValue("Passes.Arnold_Render_Options.save_texture_paths", false, null); +// INFO : Rendering pass 'Default_Pass'... +// INFO : Rendering frame 1 (0.0% done) +// INFO : [sitoa] Frame 1 exported to Arnold in 0.137 sec. +// INFO : Render completed (100% done) +RenderAllPasses(null, null, null, null, siRenderVerbosityDefault); +Warning: return value of the executed script is not an integer +// INFO : Characters has been unloaded. +// INFO : polymatricksPlugin has been unloaded. +// INFO : [sitoa] SItoA 5.4.0 win has been unloaded. +// INFO : TransformUVsPlugin has been unloaded. +// INFO : FBX-XSI import/export Plug-in has been unloaded. +// INFO : Unfold3D Plugin has been unloaded. + diff --git a/testsuite/XSIProject/Scenes/test_0272/ref/reference.tif b/testsuite/XSIProject/Scenes/test_0272/ref/reference.tif new file mode 100644 index 0000000..af0860f Binary files /dev/null and b/testsuite/XSIProject/Scenes/test_0272/ref/reference.tif differ