Skip to content

Usf changes

USF Changes#

If you are just making usf changes to your VF and not C++ changes, you can setup a simple test level, run it in the editor, then recompile just a single material applied to a single mesh (or whatever your vertex factory is). When you recompile a material in the material editor, it re-reads all the usf files from disk so you can quickly iterate that way.

When you are making a new vertex factory be sure not to just return true from the ShouldCache. That will make it compile the shaders everywhere on every material. Add a usage flag to the material, then artists have to opt-in to using it. Actually the editor will automatically set the flag when possible. Then only those flagged materials will compile your VF, which can cut down the shader combinations needed massively. Have a look at any other vertex factory for a working example (except local VF).


In this example, given a node in an Alembic Archive, we’ll figure out what the final xform is. We proceed from the leaf to the root. We’re going to change visitObject() slightly. Instead of checking the object’s name, we’re going to call a new function, getBounds(). This example is adapted from

gBounds = imath.Box3d()
kWrapExisting = alembic.Abc.WrapExistingFlag.kWrapExisting

def accumXform(xf, obj):
if IXform.matches(obj.getHeader()):
x = IXform(obj, kWrapExisting)
xs = x.getSchema().getValue()
xf *= xs.getMatrix()

def getFinalMatrix(obj):
xf = imath.M44d()
parent = obj.getParent()
while parent:
accumXform(xf, parent)
parent = parent.getParent()
return xf

def getBounds(obj):
bnds = imath.Box3d()
md = obj.getMetaData()
if IPolyMesh.matches(md) or ISubD.matches(md):
mesh = IPolyMesh(obj, kWrapExisting)
ms = mesh.getSchema()
positions = ms.getValue().getPositions()
numPoints = len(positions)
for i in range(numPoints):
bnds.extendBy(transform(bnds, xf))

def visitObject(obj):
md = obj.getMetaData()
if IPolyMesh.matches(md) or ISubD.matches(md):
for childObject in obj.children: