Installing aaOcean


Download
https://bitbucket.org/amaanakram/aaocean/downloads

Install for mental ray

  1. Extract the aaOcean download package.
  2. Create a new workgroup (or use the Softimage User location).
  3. Copy the aaOceanDataShader.dll and aaOceanShaderDefinition.dll from here:
    aaOceanRev255\aaOcean\MentalRay\Softimage2014

    to

    $MY_WORKGROUP\Application\Plugins
  4. Copy aaOceanDeformer.dll from here:
    aaOceanRev255\aaOcean\Softimage\Softimage2014\

    to

    $MY_WORKGROUP\Application\Plugins\

$MY_WORKGROUP is just my workgroup location. For example:
C:\Users\StephenBlair\Documents\softimage\workgroups\aaOcean

Did you notice that the mental ray version of aaOcean doesn’t have a SPDL file? That’s because it has a shader definition plugin instead.
aaOcean

Install for Arnold

  1. Copy
    aaOceanRev255\aaOcean\Arnold\Arnold-4.2.0.6-windows\Shader\aaOcean.dll 

    to

    $WORKGROUP\Addons\SItoA\Application\Plugins\bin\nt-x86-64
  2. Copy
    aaOcean\Arnold\Arnold-4.2.0.6-windows\SItoA\aaOcean.spdl

    to

    $WORKGROUP\Addons\SItoA\Application\spdl
  3. Copy
    aaOceanRev255\aaOcean\Softimage\Softimage2014\aaOceanDeformer.dll

    to

    $WORKGROUP\Addons\SItoA\Application\Plugins

$MY_WORKGROUP is just my workgroup location. For example:
C:\Users\StephenBlair\Documents\softimage\workgroups\sitoa-3.2.0-2014

Scripting: Finding all materials that contain a specific shader


Given a shader, it’s not too hard to find all materials that use (aka “own”) an instance of that shader. Here’s a Python snippet that does just that.

Note that I don’t check whether or not the shader is actually used. This snippet finds all instances, whether they are used or not (last week I posted another snippet for checking whether a shader instances was ultimately connected to the material).

from sipyutils import si			# win32com.client.Dispatch('XSI.Application')
from sipyutils import disp		# win32com.client.Dispatch
from sipyutils import C			# win32com.client.constants
si = si()

def get_materials_that_use_shader( s ):	
	mats = disp( "XSI.Collection" )	
	oShaderDef = si.GetShaderDef( s.ProgID )
	for i in oShaderDef.ShaderInstances:
		try:
			mats.Add( i.Owners(0) )
		except Exception:
			pass

	mats.Unique = True
	return mats

#
# Find all materials that use a specific shader
#
s = si.Selection(0)
if s.IsClassOf( C.siShaderID ):
	mats = get_materials_that_use_shader( s )
	for m in mats:
		print( "%s in %s" % (m.Name, m.Owners(0)) )
else:
	si.LogMessage( "Cannot find shader instances. Please select a shader." )

# Material in Sources.Materials.DefaultLib
# Material1 in Sources.Materials.DefaultLib
# Material2 in Sources.Materials.DefaultLib
# Material3 in Sources.Materials.DefaultLib
# Material7 in Sources.Materials.DefaultLib
# Material6 in Sources.Materials.DefaultLib
# Material5 in Sources.Materials.DefaultLib
# Material4 in Sources.Materials.DefaultLib

ERROR File not found in SPDL registry during render


A customer recently reported that random machines on the farm were reporting this error. They have custom shaders installed in a workgroup, and the workgroup lives on a network drive that is accessible to all machines on the farm.

So, what is this SPDL registry thing?

It’s a file named spdl.xsiindex, and it’s a cached index of all the shader spdl files. Softimage creates/updates this SPDL registry at startup (so you can delete it to force the recreation of a new file).

You can find the file in %XSI_USERHOME%\Application. Actually, the file is named “spdl.MACHINE.xsiindex”. We had to add the machine name to the file name to prevent issues with concurrent access. However, I would think that if you ran multiple instances of xsibatch on the one machine, you might still have problems.

There’s also a MTL2UA0150CWY.xsishaderdefcache file to deal with the new-fangled, non-SPDL shaders.

Overriding SPDL defaults



In the old days, if you didn’t like some default shader parameter setting, you had to edit a SPDL file and generate a new preset. As of 2011, you can use the ObjectModel (OM) to dynamically update the shader definition.

For example, if you run this Python snippet in the script editor, then the next time you create an Environment shader, it will have some different defaults:

  • Environment Mode will default to Cylinder
  • Transformation will have a connection icon
  • Background Intensity will default to 0.5
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.sib_environment.1.0"
oDef = si.GetShaderDef( "Softimage.sib_environment.1.0" )

# Get ShaderParamDef for the Tranformation parameter
oTransform = oDef.InputParamDefs.GetParamDefByName( "transform" )

# Make it texturable so it has a connection icon
oTransform.Texturable = True


# Make Cylinder the default Environment mode
oParam = oDef.InputParamDefs.GetParamDefByName( "mode" )
oParam.DefaultValue = 1

# Change the default background intensity to 0.5
oParam = oDef.InputParamDefs.GetParamDefByName( "background_intensity" )
oParam.DefaultValue = 0.5

So, that’s how you update a shader definition. Now, all you have to do is stick that code into a siOnCreateShaderDef event plugin, and every time you create an Environment shader, it will have the defaults you want

import win32com.client
from win32com.client import 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

# Callback for the CreateShaderDef event.
def CreateShaderDef_OnEvent( in_ctxt ):
	oDef = in_ctxt.GetAttribute("ShaderDef")
	sProgID = str(in_ctxt.GetAttribute("ProgID"))
	if "Softimage.sib_environment.1.0" in sProgID:
		oDef.InputParamDefs.GetParamDefByName( "transform" ).Texturable = True

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

Tip: Use the SDK Explorer (CTRL+SHIFT+4) to get the ProgID of a shader.

Animating the Environment shader Transformation parameter


We’ve had a couple of questions about this recently, so here goes…

In the 2011 release, parameters like the Environment shader’s Transformation parameter were changed to expose the raw transformation matrix instead of StaticKineState. This allows ICE attributes to plug directly in the shader input matrix ports and have texturable matrix ports.

A transformation matrix is a combination of the scaling, rotation, and translation, and when you start animating those values, you’re going to see some “weird” numbers 😉 For example, if I animate the Z rotation from 0 to 45 degrees, I’ll see this in the Animation Editor. Note that in the viewport I’m using ICE to show the transformation matrix for a cone that has the same Z rotation from 0 to 45 degrees: see how it matches up with the fcurves for the Environment transformation.

To make things more artist-friendly, you have to make the Transformation parameter texturable so you can plug in a Create_Transform node in the render tree.

To make the Transformation parameter texturable, install this addon.

Specifying the help file location in SPDL


In 2011 and later, you can’t use OriginPath to find the location of the inspected shader/texture. Instead, use ShaderDef.DefinitionPath.
ShaderDef.DefinitionPath will return something like:

' INFO : C:\Users\blairs\Autodesk\Softimage_2012_SP1\Addons\baVolume\Application\spdl\BA_fluid.spdl

So you could do something like this in your SPDL file to specify the location of your help:

	Sub OnInit()
		setAlpha_OnChanged()
		Set ppi =PPG.Inspected(0)
		s = ppi.ShaderDef.DefinitionPath
		sHelp = Left( s, InStr( 1, s, "spdl" ) - 1 ) + "../help/index.htm"
		PPG.PPGLayout.SetAttribute siUIHelpFile, sHelp
	End sub

Combining mental mill CgFX shaders with Softimage and ICE FX trees


This video demonstrates how to export a CgFX shader from mental mill to softimage and combine it with an Ice Effect tree.
It shows techniques to augment your exported CgFX code by hand editing the exported CgFX code and passing data that was generated by an ICE FX tree in softimage to the shader. This enables you to create a completely new type of effects.

Here’s the corresponding mentallmill.blogspot post.

FindObjects() and shaders in Softimage 2011


Update 10 Dec 2010: See this post about finding shaders using the ProgID.

In Softimage 2011, all [factory] shaders have the same Class ID ({6495C5C1-FD18-474E-9703-
AEA66631F7A7}), so FindObjects returns a collection that contains shaders in the scene.

Note that the returned collection will include the soft_light shader, as well as several hidden Lambert shaders that are used under-the-covers by Softimage.

var x = FindObjects(null, "{6495C5C1-FD18-474E-9703-AEA66631F7A7}" );
LogMessage( x.Count );

oEnum = new Enumerator( x ) ;
for (;!oEnum.atEnd();oEnum.moveNext() )
{
	var oSelItem = oEnum.item() ;
	try {
		LogMessage( oSelItem.fullname );
		i++;
		
	}
	catch(e)
	{
		LogMessage(e.message);
		LogMessage( "\t" + ClassName(oSelItem) + ":" + oSelItem.name);
		LogMessage( "\t" + oSelItem.GetShaderContainer() );
	}
}

You could filter the returned collection for a specific type of shader. For example:

// Get all shaders
var x = FindObjects(null, "{6495C5C1-FD18-474E-9703-AEA66631F7A7}" );
LogMessage( x.Count );
var oShaderCollection = new ActiveXObject( "XSI.Collection" );

// Build up a collection of all Blinn shaders
oEnum = new Enumerator( x ) ;
for (;!oEnum.atEnd();oEnum.moveNext() )
{
	var oShader = oEnum.item() ;
	try {
		//LogMessage( oShader.ProgID );
		if ( oShader.ProgID == "Softimage.material-blinn.1.0" )
		{
			oShaderCollection.Add( oShader );
		}
		
	}
	catch(e)
	{
		LogMessage(e.message);
	}
}