Allow for 1-to-1 shader translation
- Dominant language
- Wolfram Language
- Stars
- 905
- Forks
- 223
- Avg merge
- 2d 9h
- Merged PRs (30d)
- 17
Description
**Is your feature request related to a problem? Please describe.**
Maya-USD has a few different shading modes that supports multiple portable material definitions, but there are times where you don't care about portability. Maybe you want to use USD, but you keep everything in Maya anyways, maybe you have an external program that generates a scene and you want to use USD to get it into Maya and need Maya materials, or maybe you have a render engine where Maya-USD doesn't have a shading mode for it, but the node types do match.
In any case, sometimes you just want Maya-USD to do a 1-to-1 translation of materials.
**Describe the solution you'd like**
Looking at the source code trying to figure out if a 1-to-1 translation is possible, I noticed that the pxrRIS shading node already does a 1-to-1 translation, except for swapping out the node type names. So, I propose to duplicate the pxrRIS shading node, rename it the relevant parts from "pxrRIS" to "maya", and then make the following adjustments in the code:
* _GetShadingPlugs(): Have it just return the Maya plugs ([Link](https://github.com/Autodesk/maya-usd/blob/cfcbd08e188faea0e9e356109ec0c223f984003f/lib/mayaUsd/fileio/shading/shadingModePxrRis.cpp#L87))
* _GetShaderTypeName(const MFnDependencyNode& depNode): Directly return the maya type name ([Link](https://github.com/Autodesk/maya-usd/blob/cfcbd08e188faea0e9e356109ec0c223f984003f/lib/mayaUsd/fileio/shading/shadingModePxrRis.cpp#L113))
* _ExportShadingNodeHelper: Get rid of the check that makes it only export out Pxr* nodes ([Link](https://github.com/Autodesk/maya-usd/blob/cfcbd08e188faea0e9e356109ec0c223f984003f/lib/mayaUsd/fileio/shading/shadingModePxrRis.cpp#L152))
* Export: Have it bind the exported shading mode to the normal interface and not the "ri" interface ([Link](https://github.com/Autodesk/maya-usd/blob/cfcbd08e188faea0e9e356109ec0c223f984003f/lib/mayaUsd/fileio/shading/shadingModePxrRis.cpp#L291))
* _GetMayaTypeNameForShaderId: Directly return the shader id, regardless of the value of defaultToMayaNodes (best to remove that attribute as well, since it would be unnecessary) ([Link](https://github.com/Autodesk/maya-usd/blob/cfcbd08e188faea0e9e356109ec0c223f984003f/lib/mayaUsd/fileio/shading/shadingModePxrRis.cpp#L346))
* _GetOrCreateShaderObject: Remove check causing it to only import in Pxr* nodes ([Link](https://github.com/Autodesk/maya-usd/blob/cfcbd08e188faea0e9e356109ec0c223f984003f/lib/mayaUsd/fileio/shading/shadingModePxrRis.cpp#L379))
And that should be it to get a minimally viable shading mode that does 1-to-1 translation. Of course there are a few other places that might need to have a few changes.
I would say that this 1-to-1 shading mode should not be enabled by default for export, but I do think it can be enabled by default for import.
It would be nice if we could have a simple 1-to-1 shading mode right now, while a more permanent solution can be worked on. I think the biggest hurdle for materials is that the different shading modes have to be written in C++, which makes it impractical for most users to be able to export out materials for render engines unsupported by Maya-USD. A shading mode where the translation can be specified by a JSON file could be nice.
**Additional context**
I'm aware that this sort of backseat-programming isn't always appreciated, and I do apologise for that. Normally I would add in it myself and send in a pull request, but I currently don't have the time to clone Maya-USD, get it to compile, figure out the important details related to adding this feature in, then actually add in the feature, test it, and send it in. So, I'm putting it in here, in the hopes that somebody else does have the time, and to see if others also have ideas regarding this feature.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with lib/mayaUsd/fileio/shading/shadingModePxrRis.cpp, especially the referenced methods, and trace how shading modes are registered and selected. Determine the additional integration points needed for a Maya one-to-one mode. Done means Maya shader type names and plugs translate directly during import/export through the normal interface, without the Pxr* restrictions.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- computer-graphics
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100