Maya crashes when enabling "Hardware Texturing" after selecting material variant
- Dominant language
- Wolfram Language
- Stars
- 905
- Forks
- 223
- Avg merge
- 2d 9h
- Merged PRs (30d)
- 17
Description
**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**
1. Ensure viewport's `Hardware Texturing` option is disabled, e.g. using modelEditor command:
```python
maya.cmds.modelEditor("modelPanel4", e=True, displayTextures=False)
maya.cmds.refresh()
```
2. Create a mayaUsd proxyShape with this setup
```python
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 =
float3[] primvars:myColor = [(0, 1, 0)]
}
def Material "Mtl"
{
token outputs:surface.connect =
def Shader "SurfBase"
{
uniform token info:id = "UsdPreviewSurface"
}
def "Surf" (
references =
)
{
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 =
}
}
}
}
}
def "Instance" (
instanceable = true
references =
)
{
}
''')
```
3. Select the `PrimColor` variant on the instance prim. This will bring a connection on terminal node's `inputs:diffuseColor`
```python
shapeStage.GetPrimAtPath("/Instance").GetVariantSet("materialVariant").SetVariantSelection("PrimColor")
maya.cmds.refresh()
```
4. Enable `Hardware Texturing` in the viewport
```python
maya.cmds.modelEditor("modelPanel4", e=True, displayTextures=True)
maya.cmds.refresh()
```
5. 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
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.