maya-usd
maya-usd copied to clipboard
Maya crashes when enabling "Hardware Texturing" after selecting material variant
Describe the bug
When selecting a material variant and subsequently enabling viewport "Hardware Texturing", maya crashes with some of our assets. The problem seems to arise if the variantSet is changed on an instance prim (w/ instanced materials) and if the chosen variant alters the material network topology. I've managed to replicate this issue on a relatively simple setup.
Steps to reproduce
- Ensure viewport's
Hardware Texturing
option is disabled, e.g. using modelEditor command:
maya.cmds.modelEditor("modelPanel4", e=True, displayTextures=False)
maya.cmds.refresh()
- Create a mayaUsd proxyShape with this setup
import maya.cmds
import mayaUsd.ufe
import mayaUsd_createStageWithNewLayer
maya.cmds.loadPlugin("mayaUsdPlugin", quiet=True)
proxyShape = mayaUsd_createStageWithNewLayer.createStageWithNewLayer()
shapeStage = mayaUsd.ufe.getStage(proxyShape)
shapeStage.GetRootLayer().ImportFromString('''#sdf 1
def Xform "Asset" (
prepend variantSets = "materialVariant"
)
{
def Sphere "Geo" (
prepend apiSchemas = ["MaterialBindingAPI"]
)
{
rel material:binding = </Asset/Mtl>
float3[] primvars:myColor = [(0, 1, 0)]
}
def Material "Mtl"
{
token outputs:surface.connect = </Asset/Mtl/Surf.outputs:surface>
def Shader "SurfBase"
{
uniform token info:id = "UsdPreviewSurface"
}
def "Surf" (
references = </Asset/Mtl/SurfBase>
)
{
token outputs:surface
}
def Shader "PrimColor"
{
uniform token info:id = "UsdPrimvarReader_float3"
string inputs:varname = "myColor"
float3 outputs:result
}
}
variantSet "materialVariant" = {
"PrimColor" {
over "Mtl"
{
over "Surf"
{
color3f inputs:diffuseColor.connect = </Asset/Mtl/PrimColor.outputs:result>
}
}
}
}
}
def "Instance" (
instanceable = true
references = </Asset>
)
{
}
''')
- Select the
PrimColor
variant on the instance prim. This will bring a connection on terminal node'sinputs:diffuseColor
shapeStage.GetPrimAtPath("/Instance").GetVariantSet("materialVariant").SetVariantSelection("PrimColor")
maya.cmds.refresh()
- Enable
Hardware Texturing
in the viewport
maya.cmds.modelEditor("modelPanel4", e=True, displayTextures=True)
maya.cmds.refresh()
- It should crash, we get this fatal error:
----------------------------- maya.bin terminated ------------------------------
maya.bin crashed. FATAL ERROR: Failed axiom: ' _primIndex '
in GetSourcePrimIndex at line 104 of build/sources/USD-22.11/pxr/usd/usd/primData.cpp
writing crash report to [ host:/usr/tmp/st_maya.bin.6890 ] ... done.
--------------------------------------------------------------------------------
Specs (if applicable):
- CentOS 7.8
- Maya 2023.3
- maya-usd 0.25
- USD 22.11
Just adding that we are frequently getting crashes with this same error, to do with toggling hardware texturing. Would be nice to get this sorted.