Autodesk / Autodesk/maya-usd

[usdExport] "exportDisplayColor" results in black for materials with textures

Open
#1,705 3 comments 1 reaction 0 assignees View on GitHub
enhancement good first issue help wanted import-export materials
Dominant language
Wolfram Language
Stars
905
Forks
223
Avg merge
2d 9h
Merged PRs (30d)
17

Description

**Describe the bug**
When exporting display colors for a shape with an assigned material that is using a texture (file node), the result is black rather than the default color of the file node.

Basically the export code in `/lib/mayaUsd/utils/util.cpp::_getMayaShadersColor()` will ask the color attribute for its color, but if it's connected it will just return black. I propose that it would be more reasonable to lookup the default color of that file node so that artists would have some way to set a color (say "light brown" for a "sand" texture).

**Steps to reproduce**
Steps to reproduce the behavior:
1. Create a cube and assign a new lambert material
2. Connect a file node to the 'color' attribute and set file node default color to (1.0, 0.0, 0.0)
3. select your cube and Export Selected to `test.usd`
4. Witness `/root/pCube1.displayColor == (0.0, 0.0, 0.0)` in usdview.

**Expected behavior**
`pCube1.displayColor == (1.0, 0.0, 0.0)`

**Impact**
Since this is case, artists have no way to set the displayColor AND a preview shader texture (or just keep the maya shader they need for other workflows). They have to disconnect the texture, set the color, export, and then reconnect their texture to get the right behavior. We currently have a warning in place to notify artists, but it would be nice to be able to grab the more appropriate color and leave everything connected.

**Workaround**
Assign a new (lambert) material with the default color in "color" OR disconnect the texture, set the color, export, and then reconnect the texture.

**Specs:**
- OS & version [CentOS 7]
- Compiler & version [gcc 6.3.1]
- Maya version [Maya 2020]
- Maya USD commit SHA [dev at 0c906e8fd62fa83b57bad82638beabb855c7e7a5]

**Additional context**
Basically add the bold to the lookup for displayColor.
shape --> material --> surfaceShader.color **--> file1.defaultColor**

I'd like to at least start the conversation to see if this approach is agreeable to others. We don't quite rely on displayColor enough yet to jump on solving this, but I'd be happy to circle back when I have time and try to solve it if no one's done it yet.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in /lib/mayaUsd/utils/util.cpp at _getMayaShadersColor(), then reproduce the issue with the listed lambert, file node, and usdExport steps. Inspect how the connected color and file node defaultColor are handled, and verify the exported pCube1.displayColor in usdview. Done means the configured default color appears instead of black.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
computer-graphics
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.