Skip to content

Commit

Permalink
Merge pull request #80 from Autodesk/develop
Browse files Browse the repository at this point in the history
Arnold 5.4.0 to master
  • Loading branch information
sjannuz authored Sep 25, 2019
2 parents 52a0a4b + 44fd522 commit 46b7de8
Show file tree
Hide file tree
Showing 66 changed files with 1,891 additions and 346 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ under an Apache 2.0 open source license.
#### Requirements

* Softimage 2015 SP1
* Arnold 5.2.2.0 or newer
* Arnold 5.4.0.1 or newer
* Python 2.6 or newer
* Visual Studio 2012 (Windows)
* GCC 4.2.4 (Linux)
Expand Down Expand Up @@ -65,13 +65,15 @@ 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.2.2.0/win64'
ARNOLD_HOME = r'C:/SolidAngle/Arnold-5.4.0.1/win64'

TARGET_WORKGROUP_PATH = r'./Softimage_2015/Addons/SItoA'

WARN_LEVEL = 'strict'
MODE = 'debug'
SHOW_CMDS = True

PATCH_ADLM = True
```

Default configuration files for Windows and Linux reside in `config`. If you
Expand Down
79 changes: 77 additions & 2 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import SCons
def make_package(target, source, env):
package_name = str(target[0]) + ".xsiaddon"
zip_name = str(target[0])
base_pkg_dir = os.path.join('dist', 'package_temp' + get_softimage_version(env['XSISDK_ROOT']));
base_pkg_dir = os.path.join('dist', 'package_temp' + get_softimage_version(env['XSISDK_ROOT']))

# First we make sure the temp directory doesn't exist
#if os.path.exists(base_pkg_dir):
Expand All @@ -46,6 +46,10 @@ def make_package(target, source, env):
for f in file_list:
shutil.copy2(f, target_dir)

if env['PATCH_ADLM']:
wg_bin_path = os.path.join(base_pkg_dir, 'Addons', 'SItoA', bin_path)
patch_adlm(wg_bin_path, env)

# Now we generate deploy scripts
f = open(os.path.join(base_pkg_dir, 'deploy_sitoa.js'), 'w')
f.write('''
Expand Down Expand Up @@ -115,6 +119,8 @@ vars.AddVariables(
BoolVariable('UPDATE_REFERENCE', 'Update the reference log/image for the specified targets', False),
('TEST_PATTERN' , 'Glob pattern of tests to be run', 'test_*'),

BoolVariable('PATCH_ADLM' , 'Patches AdLM so that SItoA doesn\'t crash. See GitHub #74 for background info.', False),

PathVariable('XSISDK_ROOT', 'Where to find XSI libraries', get_default_path('XSISDK_ROOT', '.')),
PathVariable('ARNOLD_HOME', 'Base Arnold dir', '.'),
PathVariable('VS_HOME', 'Visual Studio 11 home', '.'),
Expand Down Expand Up @@ -403,6 +409,7 @@ PACKAGE_FILES = [
[os.path.join('plugins', 'helpers', '*.py'), os.path.join(addon_path, plugins_path)],
[os.path.join('plugins', 'helpers', 'Pictures', '*.bmp'), os.path.join(addon_path, pictures_path)],
[os.path.join('shaders', 'metadata', '*.mtd'), os.path.join(addon_path, bin_path)],
[os.path.join('plugins', 'metadata', '*.mtd'), os.path.join(addon_path, bin_path)],
[os.path.join(ARNOLD_HOME, 'license', 'lmuti*'), os.path.join(addon_path, license_path)],
[os.path.join(ARNOLD_HOME, 'license', 'rl*'), os.path.join(addon_path, license_path)],
[os.path.join(ARNOLD_HOME, 'license', 'solidangle.*'), os.path.join(addon_path, license_path)],
Expand Down Expand Up @@ -453,6 +460,72 @@ env['BUILDERS']['PackageDeploy'] = Builder(action = Action(deploy, "Deploying

DEPLOY = env.PackageDeploy('deploy', package_name)

################################
## PATCH ADLM
################################

def make_patch_adlm(target, source, env):
if env['PATCH_ADLM']:
wg_bin_path = os.path.normpath(os.path.join(env['TARGET_WORKGROUP_PATH'], bin_path))
patch_adlm(wg_bin_path, env)

def patch_adlm(wg_bin_path, env):
new_adlmint_last_char = '2' # ONLY ONE CHARACTER
if system.os() == 'windows':
adclmhub_name = 'AdClmHub_1.dll'
adlmint_name = 'adlmint.dll'
size = 383280
seek_pos = 266236
else:
adclmhub_name = 'libAdClmHub.so'
adlmint_name = 'libadlmint.so'
size = 1853576
seek_pos = 779034

new_adlmint_name = os.path.splitext(adlmint_name)[0][:-1] + new_adlmint_last_char + get_library_extension()

adclmhub_path = os.path.join(wg_bin_path, adclmhub_name)
adlmint_path = os.path.join(wg_bin_path, adlmint_name)
new_adlmint_path = os.path.join(wg_bin_path, new_adlmint_name)

need_to_patch = False

if os.path.isfile(adclmhub_path):
# check file size as a way to see if patching is needed
if os.path.getsize(adclmhub_path) == size:
need_to_patch = True

if not os.path.isfile(adlmint_path):
need_to_patch = False

if need_to_patch:
# patch AdClmHub_1
with open(adclmhub_path, 'r+b') as f:
f.seek(seek_pos)
letter = f.read(1)
if letter == 't':
print 'Patching {} ...'.format(adclmhub_name)
f.seek(seek_pos)
f.write(new_adlmint_last_char)
print '{} patched!'.format(adclmhub_name)
else:
print '{} already patched. Skipping ...'.format(adclmhub_name)

# rename adlmint.dll
if os.path.isfile(new_adlmint_path):
print 'Removing old {} ...'.format(new_adlmint_name)
os.remove(new_adlmint_path)
print 'Renaming {} to {} ...'.format(adlmint_name, new_adlmint_name)
os.rename(adlmint_path, new_adlmint_path)

print 'done patching ADLM.'

else:
print 'No need to patch.'

env['BUILDERS']['Patch'] = Builder(action = Action(make_patch_adlm, None))
PATCH = env.Patch('patch', SITOA)

################################
## INSTALL TO WORKGROUP
################################
Expand All @@ -461,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)
Expand All @@ -475,6 +548,7 @@ env.Install(os.path.join(env['TARGET_WORKGROUP_PATH'], pictures_path), [glob.glo
env.Install(os.path.join(env['TARGET_WORKGROUP_PATH'], license_path), [glob.glob(os.path.join(ARNOLD_HOME, 'license', '*'))])
env.Install(os.path.join(env['TARGET_WORKGROUP_PATH'], pit_path), [glob.glob(os.path.join(ARNOLD_HOME, 'license', 'pit', '*'))])
env.Install(os.path.join(env['TARGET_WORKGROUP_PATH'], bin_path), [glob.glob(os.path.join('shaders', 'metadata', '*.mtd'))])
env.Install(os.path.join(env['TARGET_WORKGROUP_PATH'], bin_path), [glob.glob(os.path.join('plugins', 'metadata', '*.mtd'))])

################################
## TARGETS ALIASES AND DEPENDENCIES
Expand All @@ -501,6 +575,7 @@ env.Depends(PACKAGE, SITOA_SHADERS)
env.Depends(DEPLOY, PACKAGE)
env.Depends('install', SITOA)
env.Depends('install', SITOA_SHADERS)
env.Depends('install', PATCH)

Default(['sitoa', 'shaders'])

Expand Down
14 changes: 13 additions & 1 deletion abuild.bat
Original file line number Diff line number Diff line change
@@ -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=
2 changes: 1 addition & 1 deletion config/custom_linux.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.2.2.1/linux'
ARNOLD_HOME = r'/usr/SolidAngle/Arnold-5.4.0.1/linux'

TARGET_WORKGROUP_PATH = './Softimage_2015/Addons/SItoA'

Expand Down
4 changes: 3 additions & 1 deletion config/custom_windows.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@
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.2.2.1/win64'
ARNOLD_HOME = r'C:/SolidAngle/Arnold-5.4.0.1/win64'

TARGET_WORKGROUP_PATH = r'./Softimage_2015/Addons/SItoA'

WARN_LEVEL = 'strict'
MODE = 'opt'
SHOW_CMDS = True

PATCH_ADLM = True
41 changes: 22 additions & 19 deletions plugins/helpers/ArnoldLightShaderDef.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ function XSIUnloadPlugin(in_reg)
var lightLabelMinPixels = 100;
var lightLabelPcg = 25;

function LightCommonParams(in_params, in_normalize, in_exposeColor, in_is_skydome)
function LightCommonParams(in_params, in_normalize, in_exposeColor, in_has_visibility, in_visible)
{
var h = SItoAShaderDefHelpers(); // helper object
h.AddColor3 (in_params, "color", 1, 1, 1, true, in_exposeColor, true, h.UiLightColorGuid);
Expand All @@ -64,10 +64,13 @@ function LightCommonParams(in_params, in_normalize, in_exposeColor, in_is_skydom
h.AddColor3 (in_params, "shadow_color", 0, 0, 0, true, false, true);
h.AddScalar (in_params, "shadow_density", 1, 0, 1000000, 0, 1, true, false, true);

if (in_is_skydome)
if (in_has_visibility)
{
h.AddScalar (in_params, "camera", 1, 0, 1, 0, 1, true, false, true);
h.AddScalar (in_params, "transmission", 1, 0, 1, 0, 1, true, false, true);
var default_visibility = 0;
if (in_visible)
default_visibility = 1;
h.AddScalar (in_params, "camera", default_visibility, 0, 1, 0, 1, true, false, true);
h.AddScalar (in_params, "transmission", default_visibility, 0, 1, 0, 1, true, false, true);
}
h.AddScalar (in_params, "diffuse", 1, 0, 1, 0, 1, true, false, true);
h.AddScalar (in_params, "specular", 1, 0, 1, 0, 1, true, false, true);
Expand Down Expand Up @@ -98,10 +101,10 @@ function LightCommonLayoutColor(in_layout)
in_layout.EndGroup();
}

function LightCommonLayoutContribution(in_layout, in_is_skydome)
function LightCommonLayoutContribution(in_layout, in_has_visibility)
{
in_layout.AddGroup("Contribution");
if (in_is_skydome)
if (in_has_visibility)
{
item = in_layout.AddItem("camera", "Camera");
SetLabelPixelsAndPcg(item, lightLabelMinPixels, lightLabelPcg);
Expand Down Expand Up @@ -261,7 +264,7 @@ function ArnoldLightShaders_arnold_cylinder_light_1_0_Define(in_ctxt)

// INPUT
params = shaderDef.InputParamDefs;
LightCommonParams(params, true, false, false);
LightCommonParams(params, true, false, true, false);

// OUTPUT
h.AddOutputColor4(shaderDef.OutputParamDefs);
Expand All @@ -278,7 +281,7 @@ function arnold_cylinder_light_Layout(in_layout)
in_layout.SetAttribute(siUIHelpFile, "https://support.solidangle.com/display/A5SItoAUG/Cylinder+Light");

LightCommonLayoutColor(in_layout);
LightCommonLayoutContribution(in_layout, false);
LightCommonLayoutContribution(in_layout, true);
in_layout.AddGroup("Area");
LightCommonLayoutArea(in_layout);
in_layout.EndGroup();
Expand All @@ -304,7 +307,7 @@ function ArnoldLightShaders_arnold_disk_light_1_0_Define(in_ctxt)

// INPUT
params = shaderDef.InputParamDefs;
LightCommonParams(params, true, false, false);
LightCommonParams(params, true, false, true, false);
h.AddScalar(params, "spread", 1, 0, 1, 0, 1, true, false, true);

// OUTPUT
Expand All @@ -321,7 +324,7 @@ function arnold_disk_light_Layout(in_layout)
in_layout.Clear();
in_layout.SetAttribute(siUIHelpFile, "https://support.solidangle.com/display/A5SItoAUG/Disk+Light");
LightCommonLayoutColor(in_layout);
LightCommonLayoutContribution(in_layout, false);
LightCommonLayoutContribution(in_layout, true);
in_layout.AddGroup("Area");
LightCommonLayoutArea(in_layout);
item = in_layout.AddItem("spread", "Spread");
Expand Down Expand Up @@ -350,7 +353,7 @@ function ArnoldLightShaders_arnold_distant_light_1_0_Define(in_ctxt)

// INPUT
params = shaderDef.InputParamDefs;
LightCommonParams(params, true, false, false);
LightCommonParams(params, true, false, false, false);
h.AddScalar(params, "angle", 0, 0, 180, 0, 10, true, false, true);

// OUTPUT
Expand Down Expand Up @@ -395,7 +398,7 @@ function ArnoldLightShaders_arnold_mesh_light_1_0_Define(in_ctxt)

// INPUT
params = shaderDef.InputParamDefs;
LightCommonParams(params, true, true, false);
LightCommonParams(params, true, true, false, false);

// OUTPUT
h.AddOutputColor4(shaderDef.OutputParamDefs);
Expand Down Expand Up @@ -438,7 +441,7 @@ function ArnoldLightShaders_arnold_photometric_light_1_0_Define(in_ctxt)

// INPUT
params = shaderDef.InputParamDefs;
LightCommonParams(params, true, false, false);
LightCommonParams(params, true, false, false, false);
h.AddLightProfile(params, "filename");
h.AddScalar(params, "radius", 0, 0, 1000000, 0, 2, true, false, true);

Expand Down Expand Up @@ -490,7 +493,7 @@ function ArnoldLightShaders_arnold_point_light_1_0_Define(in_ctxt)

// INPUT
params = shaderDef.InputParamDefs;
LightCommonParams(params, true, false, false);
LightCommonParams(params, true, false, true, false);
h.AddScalar (params, "radius", 0, 0, 1000000, 0, 10, true, false, true);

// OUTPUT
Expand All @@ -508,7 +511,7 @@ function arnold_point_light_Layout(in_layout)
in_layout.SetAttribute(siUIHelpFile, "https://support.solidangle.com/display/A5SItoAUG/Point+Light");

LightCommonLayoutColor(in_layout);
LightCommonLayoutContribution(in_layout, false);
LightCommonLayoutContribution(in_layout, true);
in_layout.AddGroup("Area");
item = in_layout.AddItem("radius", "Radius");
SetLabelPixelsAndPcg(item, lightLabelMinPixels, lightLabelPcg);
Expand Down Expand Up @@ -536,7 +539,7 @@ function ArnoldLightShaders_arnold_quad_light_1_0_Define(in_ctxt)

// INPUT
params = shaderDef.InputParamDefs;
LightCommonParams(params, true, true, false);
LightCommonParams(params, true, true, true, false);
h.AddInteger(params, "resolution", 512, 1, 1000000, 1, 4096, true, false, true);
h.AddScalar(params, "spread", 1, 0, 1, 0, 1, true, false, true);
h.AddBoolean(params, "portal", false, true, false, true);
Expand All @@ -558,7 +561,7 @@ function arnold_quad_light_Layout(in_layout)
in_layout.SetAttribute(siUIHelpFile, "https://support.solidangle.com/display/A5SItoAUG/Quad+Light");

LightCommonLayoutColor(in_layout);
LightCommonLayoutContribution(in_layout, false);
LightCommonLayoutContribution(in_layout, true);
in_layout.AddGroup("Area");
item = in_layout.AddItem("portal", "Portal");
SetLabelPixelsAndPcg(item, lightLabelMinPixels, lightLabelPcg);
Expand Down Expand Up @@ -595,7 +598,7 @@ function ArnoldLightShaders_arnold_skydome_light_1_0_Define(in_ctxt)

// INPUT
params = shaderDef.InputParamDefs;
LightCommonParams(params, false, true, true); // no "normalize" param, yes texturable color, yes camera and transmission
LightCommonParams(params, false, true, true, true); // no "normalize" param, yes texturable color, yes camera and transmission, yes camera and transmission on by default
h.AddInteger(params, "resolution", 1000, 1, 1000000, 1, 4096, true, false, true);
h.AddInteger(params, "format", 1, 0, 2, 0, 2, true, false, true);
h.AddInteger(params, "portal_mode", 1, 0, 2, 0, 2, true, false, true);
Expand Down Expand Up @@ -655,7 +658,7 @@ function ArnoldLightShaders_arnold_spot_light_1_0_Define(in_ctxt)

// INPUT
params = shaderDef.InputParamDefs;
LightCommonParams(params, true, false, false);
LightCommonParams(params, true, false, false, false);
h.AddScalar(params, "radius", 0, 0, 1000000, 0, 10, true, false, true);
h.AddScalar(params, "lens_radius", 0, 0, 1000000, 0, 10);
h.AddScalar(params, "cone_angle", 65, 0, 1000000, 0, 100);
Expand Down
12 changes: 8 additions & 4 deletions plugins/helpers/ArnoldLights.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
Loading

0 comments on commit 46b7de8

Please sign in to comment.