Unrecognized colorspace should throw rather than warn to stderr#2954
Unrecognized colorspace should throw rather than warn to stderr#2954doug-walker wants to merge 7 commits into
Conversation
Signed-off-by: Doug Walker <doug.walker@autodesk.com>
Signed-off-by: Doug Walker <doug.walker@autodesk.com>
Signed-off-by: Doug Walker <doug.walker@autodesk.com>
Signed-off-by: Doug Walker <doug.walker@autodesk.com>
Signed-off-by: Doug Walker <doug.walker@autodesk.com>
|
Thanks for putting this together, @doug-walker! Moving from a One thing I'd like to work through before we merge: now that an unsupported transform throws, it reaches a spot in the Graph Editor that wasn't quite ready for it. For example, you could mirror the existing pattern as follows: catch (mx::ExceptionRenderError& e)
{
for (const std::string& error : e.errorLog())
{
std::cerr << error << std::endl;
}
}
catch (std::exception& e) // ExceptionShaderGenError, etc.
{
std::cerr << e.what() << std::endl;
}Let me know how this sounds to you, and I'm happy to help with the Graph Editor update as needed. |
|
Thank you @jstone-lucasfilm, I'll add a commit with your proposed changes! |
Currently, if an unrecognized colorspace string is encountered in MaterialXGenShader, it prints a warning to std::cerr. This is not ideal for several reasons:
This PR changes the behavior to raise ExceptionShaderGenError.
This change required omitting the test file ocio_color_management.mtlx from the MaterialXGenMdl tests. The test was previously succeeding (when compiled with MATERIALX_BUILD_OCIO=ON), although it should not have.
In addition, a change was made to improve the name of the color space conversion functions generated by the OcioColorManagementSystem. Previously the names only used the cacheIDs of the OCIO Processors, which was not very friendly to troubleshooting. Now the names are more similar to the "srcColorSpace_to_dstColorSpace" naming used by the DefaultColorManagmentSystem. This avoids a problem when MaterialX is compiled with the current OCIO main branch due to a change in the cacheID formatting.
While testing, I noticed that the MaterialX createValidName function sometimes creates names with double underscores. OCIO's shader generator avoids this since (although some drivers accept it) it is technically undefined behavior. I added a sanitizeName function locally to work around this.
As I worked further, I noticed that the GenShader tests were not actually testing color management, even though MaterialXTest/MaterialXGenShader/GenShaderUtil.cpp explicitly tries to enable color management. The problem was that it was not ensuring that a targetColorSpace was set (as the rendering tests do). If that is empty, the color management shaders are never generated or tested. I ensured that is now being set. As a result, I needed to make sure the ocio_color_management.mtlx test file was omitted from the GenShader tests when OCIO is not enabled.
Finally, I fixed a bug with the DefaultColorManagementSystem where the conversion from "lin_rec709_scene" to "lin_rec709" was not handled properly as a no-op. I added a test case for this in color_management.mtlx.
Claude Code was used during the creation of this PR.