Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mayaUSD export results in incorrectly determined UV set names due to Maya bug #1079

Closed
ysiewappl opened this issue Jan 14, 2021 · 4 comments · Fixed by #1188
Closed

mayaUSD export results in incorrectly determined UV set names due to Maya bug #1079

ysiewappl opened this issue Jan 14, 2021 · 4 comments · Fixed by #1188
Assignees
Labels
bug Something isn't working

Comments

@ysiewappl
Copy link
Contributor

ysiewappl commented Jan 14, 2021

Describe the bug
Hi:

There is an issue we're running into where if a Maya scene has a mesh shape that is named exactly the same as its parent transform, Maya interprets it as a string array attribute rather than a single string.
There also doesn't seem to be any way to "fix" this through OpenMaya or the GUI.

cmds.getAttr('testmesh.uvSet[0].uvSetName', type=1)
# Result: [u'string', u'string'] # 

cmds.getAttr('testmesh.uvSet[0].uvSetName')
# Result: [u'map1', u'map1'] # 

This is a problem, because mayaUsd (and many things regardless) expect the UV set name to be a basic string attribute, not a string array.

From maya-usd/lib/mayaUsd/fileio/shading/shadingModeExporterContext.cpp:468:


                MString getAttrCmd;
                getAttrCmd.format("getAttr \"^1s\";", uvSetRef.c_str());
                TfToken getAttrResult(MGlobal::executeCommandStringResult(getAttrCmd).asChar());

                // Check if map1 should export as st:
                if (getAttrResult == _tokens->map1 && UsdMayaWriteUtil::WriteMap1AsST()) {
                    getAttrResult = UsdUtilsGetPrimaryUVSetName();
                }

Steps to reproduce

An example maya scene is provided below that demonstrates this issue. If you rename the mesh node to any other name other than the transform name and query the attribute again, you'll get the expected map1 string instead of an array of strings.

//Maya ASCII 2020 scene
//Name: test_mesh.ma
//Last modified: Thu, Jan 14, 2021 02:22:27 PM
//Codeset: UTF-8
requires maya "2020";
currentUnit -l centimeter -a degree -t film;
fileInfo "application" "maya";
fileInfo "product" "Maya 2020";
fileInfo "version" "2020";
fileInfo "cutIdentifier" "202009141615-87c40af620";
fileInfo "osv" "Mac OS X 10.16";
fileInfo "UUID" "7D91E8EA-0F4D-9A5C-BE0B-B0A67C0C4191";
createNode transform -s -n "persp";
	rename -uid "5D0AC5F0-5C4E-D3E6-59FA-D18EE04E4A1B";
	setAttr ".v" no;
	setAttr ".t" -type "double3" 21.567564127622571 187.61532620068942 168.98663677004686 ;
	setAttr ".r" -type "double3" -19.538352729611454 -353.80000000001377 0 ;
createNode camera -s -n "perspShape" -p "persp";
	rename -uid "15DB6B4D-3248-4103-741A-81848CBD85AC";
	setAttr -k off ".v" no;
	setAttr ".fl" 34.999999999999986;
	setAttr ".coi" 188.18830489823623;
	setAttr ".imn" -type "string" "persp";
	setAttr ".den" -type "string" "persp_depth";
	setAttr ".man" -type "string" "persp_mask";
	setAttr ".hc" -type "string" "viewSet -p %camera";
createNode transform -s -n "top";
	rename -uid "CBABE2E6-1F49-3C16-DFF9-0D9D142040F7";
	setAttr ".v" no;
	setAttr ".t" -type "double3" 0 1000.1 0 ;
	setAttr ".r" -type "double3" -89.999999999999986 0 0 ;
createNode camera -s -n "topShape" -p "top";
	rename -uid "D397CE6A-F04A-BC25-D980-1BA5C255DE83";
	setAttr -k off ".v" no;
	setAttr ".rnd" no;
	setAttr ".coi" 1000.1;
	setAttr ".ow" 30;
	setAttr ".imn" -type "string" "top";
	setAttr ".den" -type "string" "top_depth";
	setAttr ".man" -type "string" "top_mask";
	setAttr ".hc" -type "string" "viewSet -t %camera";
	setAttr ".o" yes;
createNode transform -s -n "front";
	rename -uid "67961068-254F-0B52-1C61-BB973D258A64";
	setAttr ".v" no;
	setAttr ".t" -type "double3" 0 0 1000.1 ;
createNode camera -s -n "frontShape" -p "front";
	rename -uid "BA52098D-7C49-0DDF-3B4F-B89C477295C6";
	setAttr -k off ".v" no;
	setAttr ".rnd" no;
	setAttr ".coi" 1000.1;
	setAttr ".ow" 30;
	setAttr ".imn" -type "string" "front";
	setAttr ".den" -type "string" "front_depth";
	setAttr ".man" -type "string" "front_mask";
	setAttr ".hc" -type "string" "viewSet -f %camera";
	setAttr ".o" yes;
createNode transform -s -n "side";
	rename -uid "59E7B6DC-3948-2E75-A074-B790036B9637";
	setAttr ".v" no;
	setAttr ".t" -type "double3" 1000.1 0 0 ;
	setAttr ".r" -type "double3" 0 89.999999999999986 0 ;
createNode camera -s -n "sideShape" -p "side";
	rename -uid "9BDA8C52-DB47-8D02-5A56-D28D43987833";
	setAttr -k off ".v" no;
	setAttr ".rnd" no;
	setAttr ".coi" 1000.1;
	setAttr ".ow" 30;
	setAttr ".imn" -type "string" "side";
	setAttr ".den" -type "string" "side_depth";
	setAttr ".man" -type "string" "side_mask";
	setAttr ".hc" -type "string" "viewSet -s %camera";
	setAttr ".o" yes;
createNode transform -n "test";
createNode mesh -n "test" -p "test";
createNode lightLinker -s -n "lightLinker1";
	rename -uid "16E65C7A-374F-6019-6FF8-D3968272DB76";
	setAttr -s 3 ".lnk";
	setAttr -s 3 ".slnk";
createNode displayLayerManager -n "layerManager";
	rename -uid "E11F7F4C-B143-91AD-3BFB-5792311C682E";
createNode displayLayer -n "defaultLayer";
	rename -uid "0463E14D-7D40-18EB-6D70-3FB68925C6EC";
createNode renderLayerManager -n "renderLayerManager";
	rename -uid "CE7F73CB-FC40-DBEC-90B2-A89389DBF5D4";
createNode renderLayer -n "defaultRenderLayer";
	rename -uid "ED17A0AA-854A-FE33-1590-5C9387970B62";
	setAttr ".g" yes;
createNode shapeEditorManager -n "shapeEditorManager";
	rename -uid "01D84118-984D-00B6-20FC-83A858AE9A5A";
createNode poseInterpolatorManager -n "poseInterpolatorManager";
	rename -uid "F2B725B2-B641-6647-A50D-7D9DCF00EFE1";
createNode script -n "sceneConfigurationScriptNode";
	rename -uid "AD7A0557-8A41-2F18-023F-9EAB740D05D7";
	setAttr ".b" -type "string" "playbackOptions -min 1 -max 120 -ast 1 -aet 200 ";
	setAttr ".st" 6;
select -ne :time1;
	setAttr ".o" 1;
	setAttr ".unw" 1;
select -ne :hardwareRenderingGlobals;
	setAttr ".otfna" -type "stringArray" 22 "NURBS Curves" "NURBS Surfaces" "Polygons" "Subdiv Surface" "Particles" "Particle Instance" "Fluids" "Strokes" "Image Planes" "UI" "Lights" "Cameras" "Locators" "Joints" "IK Handles" "Deformers" "Motion Trails" "Components" "Hair Systems" "Follicles" "Misc. UI" "Ornaments"  ;
	setAttr ".otfva" -type "Int32Array" 22 0 1 1 1 1 1
		 1 1 1 0 0 0 0 0 0 0 0 0
		 0 0 0 0 ;
	setAttr ".etmr" no;
	setAttr ".tmr" 4096;
	setAttr ".fprt" yes;
select -ne :renderPartition;
	setAttr -s 3 ".st";
select -ne :renderGlobalsList1;
select -ne :defaultShaderList1;
	setAttr -s 6 ".s";
select -ne :postProcessList1;
	setAttr -s 2 ".p";
select -ne :defaultRenderUtilityList1;
	setAttr -s 5 ".u";
select -ne :defaultRenderingList1;
select -ne :defaultTextureList1;
	setAttr -s 5 ".tx";
select -ne :initialShadingGroup;
	setAttr ".ro" yes;
select -ne :initialParticleSE;
	setAttr ".ro" yes;
select -ne :defaultRenderGlobals;
	addAttr -ci true -sn "mtohEnableMotionSamples" -ln "mtohEnableMotionSamples" -min 
		0 -max 1 -at "bool";
	addAttr -ci true -sn "mtohTextureMemoryPerTexture" -ln "mtohTextureMemoryPerTexture" 
		-dv 4096 -min 1 -max 262144 -smn 16384 -at "long";
	addAttr -ci true -sn "mtohMaximumShadowMapResolution" -ln "mtohMaximumShadowMapResolution" 
		-dv 2048 -min 32 -max 8192 -at "long";
	addAttr -ci true -sn "mtohWireframeSelectionHighlight" -ln "mtohWireframeSelectionHighlight" 
		-dv 1 -min 0 -max 1 -at "bool";
	addAttr -ci true -sn "mtohColorSelectionHighlight" -ln "mtohColorSelectionHighlight" 
		-dv 1 -min 0 -max 1 -at "bool";
	addAttr -ci true -uac -sn "mtohColorSelectionHighlightColor" -ln "mtohColorSelectionHighlightColor" 
		-at "float3" -nc 3;
	addAttr -ci true -sn "mtohColorSelectionHighlightColorr" -ln "mtohColorSelectionHighlightColorR" 
		-dv 1 -at "float" -p "mtohColorSelectionHighlightColor";
	addAttr -ci true -sn "mtohColorSelectionHighlightColorg" -ln "mtohColorSelectionHighlightColorG" 
		-dv 1 -at "float" -p "mtohColorSelectionHighlightColor";
	addAttr -ci true -sn "mtohColorSelectionHighlightColorb" -ln "mtohColorSelectionHighlightColorB" 
		-at "float" -p "mtohColorSelectionHighlightColor";
	addAttr -ci true -sn "mtohColorSelectionHighlightColorA" -ln "mtohColorSelectionHighlightColorA" 
		-dv 0.5 -at "float";
	addAttr -ci true -sn "mtohSelectionOutline" -ln "mtohSelectionOutline" -dv 4 -at "float";
	addAttr -ci true -sn "HdStormRendererPluginenableTinyPrimCulling" -ln "HdStormRendererPluginenableTinyPrimCulling" 
		-min 0 -max 1 -at "bool";
	addAttr -ci true -sn "HdStormRendererPluginvolumeRaymarchingStepSize" -ln "HdStormRendererPluginvolumeRaymarchingStepSize" 
		-dv 1 -at "float";
	addAttr -ci true -sn "HdStormRendererPluginvolumeRaymarchingStepSizeLighting" -ln "HdStormRendererPluginvolumeRaymarchingStepSizeLighting" 
		-dv 2 -at "float";
	addAttr -ci true -h true -sn "dss" -ln "defaultSurfaceShader" -dt "string";
	setAttr ".dss" -type "string" "lambert1";
select -ne :defaultResolution;
	setAttr ".pa" 1;
select -ne :hardwareRenderGlobals;
	setAttr ".ctrs" 256;
	setAttr ".btrs" 512;
relationship "link" ":lightLinker1" ":initialShadingGroup.message" ":defaultLightSet.message";
relationship "link" ":lightLinker1" ":initialParticleSE.message" ":defaultLightSet.message";
relationship "shadowLink" ":lightLinker1" ":initialShadingGroup.message" ":defaultLightSet.message";
relationship "shadowLink" ":lightLinker1" ":initialParticleSE.message" ":defaultLightSet.message";
connectAttr "layerManager.dli[0]" "defaultLayer.id";
connectAttr "renderLayerManager.rlmi[0]" "defaultRenderLayer.rlid";
		;
// End of test_mesh.ma

Expected behavior

The attribute type should remain as a string attribute.

Attachments

Please see the embedded Maya sample scene above.

Specs (if applicable):

  • OS & version: macOS 11
  • Compiler & version: N/A
  • Maya version: Maya 2020.3
  • Maya USD commit SHA: N/A
  • Pixar USD commit SHA: N/A

Additional context

We could certainly update mayaUsd to account for this odd behaviour and parse the plug's value properly for export, but I'd like to ask if this is actually intended, since Maya generally doesn't allow for node class attributes to suddenly change attribute types between different nodes.

Thanks.

@ysiewappl ysiewappl added the bug Something isn't working label Jan 14, 2021
@ysiewappl
Copy link
Contributor Author

Hi, just bumping this because we continue to wonder if we should work around this in the Maya-USD exporter for now; could we get confirmation on this issue and if/when it might be addressed within Maya itself, or if this is expected behaviour for reasons I'm not aware of?

Thanks!

@kxl-adsk
Copy link

kxl-adsk commented Feb 3, 2021

In this case, you have to be explicit about the full path to the shape. Here is the code that will work as expected with your example

print(cmds.getAttr('|test|test.uvSet[0].uvSetName', type=1))
print(cmds.getAttr('|test|test.uvSet[0].uvSetName'))

I'm guessing what happens here is that Maya will find the transform and the shape. Then for each of them, we do an attribute query and receive an array of results. You may wonder why transform returned a value - it has to do with the fact that when we pick something in the viewport, we select transform and not the shape.

@kxl-adsk
Copy link

kxl-adsk commented Feb 8, 2021

@ysiewappl did the above solve your issue?

@ysiewappl
Copy link
Contributor Author

ysiewappl commented Feb 8, 2021

Hi; I'm not actually 100% I understand the reasoning for why a transform should return a value when queried for a non-existent (uvSet) attribute on itself. (I actually don't quite get why getAttr involves viewport selection at all). But regardless, we are planning to submit a future update to the exporter to work around this, so hopefully in a few weeks it will be a non-issue.

@kxl-adsk kxl-adsk linked a pull request Feb 19, 2021 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants