-
Notifications
You must be signed in to change notification settings - Fork 209
Add option to fallback to mayaDefaultStandardSurface shader fragment #3957
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
d6052ee
Add option to fallback to mayaDefaultStandardSurface shader fragment
kpolonski-atomic d060a77
Use standardSurface material by default
kpolonski-atomic 5787a0b
Rename function to better represent intentions
kpolonski-atomic 790f752
Run clang-format
kpolonski-atomic fca6c8a
Generate fallback shader fragment name arrays after maya intialization
kpolonski-atomic cec4cd0
Update license info for new files
kpolonski-atomic 3db2589
Skip standardSurface image test if maya version is less than 2024
kpolonski-atomic File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
130 changes: 130 additions & 0 deletions
130
lib/mayaUsd/render/vp2ShaderFragments/FallbackCPVShaderStandardSurface.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
<!-- | ||
======================================================================== | ||
Copyright 2019 Autodesk | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
======================================================================== | ||
--> | ||
<fragment_graph name="FallbackCPVShaderStandardSurface" ref="FallbackCPVShaderStandardSurface" class="FragmentGraph" version="1.0" feature_level="0" > | ||
<fragments> | ||
<fragment_ref name="mayaDefaultStandardSurface" ref="mayaDefaultStandardSurface" /> | ||
<fragment_ref name="FloatToFloat3" ref="FloatToFloat3" /> | ||
<fragment_ref name="Float4ToFloat3" ref="Float4ToFloat3" /> | ||
<fragment_ref name="Float4ToFloatW" ref="Float4ToFloatW" /> | ||
<fragment_ref name="mayaCPVPassing" ref="mayaCPVPassing" /> | ||
</fragments> | ||
<connections> | ||
<connect from="Float4ToFloat3.output" to="mayaDefaultStandardSurface.baseColor" name="color" /> | ||
<connect from="FloatToFloat3.output" to="mayaDefaultStandardSurface.opacity" name="opacity" /> | ||
<connect from="Float4ToFloatW.output" to="FloatToFloat3.input" name="alphavec" /> | ||
<connect from="mayaCPVPassing.C_4F" to="Float4ToFloat3.input" name="rgb" /> | ||
<connect from="mayaCPVPassing.C_4F" to="Float4ToFloatW.input" name="a" /> | ||
</connections> | ||
<properties> | ||
<float3 name="mayaTangentIn" ref="mayaDefaultStandardSurface.mayaTangentIn" semantic="tangent" flags="varyingInputParam" /> | ||
<float name="base" ref="mayaDefaultStandardSurface.base" /> | ||
<float name="diffuseRoughness" ref="mayaDefaultStandardSurface.diffuseRoughness" /> | ||
<float name="metalness" ref="mayaDefaultStandardSurface.metalness" /> | ||
<float name="specular" ref="mayaDefaultStandardSurface.specular" /> | ||
<float3 name="specularColor" ref="mayaDefaultStandardSurface.specularColor" /> | ||
<float name="specularIOR" ref="mayaDefaultStandardSurface.specularIOR" /> | ||
<float name="specularRoughness" ref="mayaDefaultStandardSurface.specularRoughness" /> | ||
<float name="specularAnisotropy" ref="mayaDefaultStandardSurface.specularAnisotropy" /> | ||
<float name="specularRotation" ref="mayaDefaultStandardSurface.specularRotation" /> | ||
<float name="transmission" ref="mayaDefaultStandardSurface.transmission" /> | ||
<float3 name="transmissionColor" ref="mayaDefaultStandardSurface.transmissionColor" /> | ||
<float name="subsurface" ref="mayaDefaultStandardSurface.subsurface" /> | ||
<float3 name="subsurfaceColor" ref="mayaDefaultStandardSurface.subsurfaceColor" /> | ||
<float name="coat" ref="mayaDefaultStandardSurface.coat" /> | ||
<float3 name="coatColor" ref="mayaDefaultStandardSurface.coatColor" /> | ||
<float name="coatIOR" ref="mayaDefaultStandardSurface.coatIOR" /> | ||
<float name="coatRoughness" ref="mayaDefaultStandardSurface.coatRoughness" /> | ||
<float name="coatAnisotropy" ref="mayaDefaultStandardSurface.coatAnisotropy" /> | ||
<float name="coatRotation" ref="mayaDefaultStandardSurface.coatRotation" /> | ||
<float name="coatAffectRoughness" ref="mayaDefaultStandardSurface.coatAffectRoughness" /> | ||
<float name="coatAffectColor" ref="mayaDefaultStandardSurface.coatAffectColor" /> | ||
<float name="sheen" ref="mayaDefaultStandardSurface.sheen" /> | ||
<float3 name="sheenColor" ref="mayaDefaultStandardSurface.sheenColor" /> | ||
<float name="sheenRoughness" ref="mayaDefaultStandardSurface.sheenRoughness" /> | ||
<float name="emission" ref="mayaDefaultStandardSurface.emission" /> | ||
<float3 name="emissionColor" ref="mayaDefaultStandardSurface.emissionColor" /> | ||
<float name="extraOpacity" ref="mayaDefaultStandardSurface.extraOpacity" /> | ||
<bool name="fogEnabled" ref="mayaDefaultStandardSurface.fogEnabled" /> | ||
<float3 name="Pw" ref="mayaDefaultStandardSurface.Pw" semantic="Pw" /> | ||
<float4x4 name="ViewProj" ref="mayaDefaultStandardSurface.ViewProj" semantic="viewprojection" /> | ||
<float name="fogStart" ref="mayaDefaultStandardSurface.fogStart" /> | ||
<float name="fogEnd" ref="mayaDefaultStandardSurface.fogEnd" /> | ||
<int name="fogMode" ref="mayaDefaultStandardSurface.fogMode" /> | ||
<float name="fogDensity" ref="mayaDefaultStandardSurface.fogDensity" /> | ||
<float4 name="fogColor" ref="mayaDefaultStandardSurface.fogColor" /> | ||
<float name="fogMultiplier" ref="mayaDefaultStandardSurface.fogMultiplier" /> | ||
<float3 name="IrradianceEnv" ref="mayaDefaultStandardSurface.IrradianceEnv" /> | ||
<float3 name="SpecularEnv" ref="mayaDefaultStandardSurface.SpecularEnv" /> | ||
<int name="selectionIndex" ref="mayaDefaultStandardSurface.selectionIndex" /> | ||
<struct name="light0" ref="mayaDefaultStandardSurface.light0" /> | ||
<struct name="light1" ref="mayaDefaultStandardSurface.light1" /> | ||
<struct name="light2" ref="mayaDefaultStandardSurface.light2" /> | ||
<struct name="light3" ref="mayaDefaultStandardSurface.light3" /> | ||
<struct name="light4" ref="mayaDefaultStandardSurface.light4" /> | ||
<struct name="light5" ref="mayaDefaultStandardSurface.light5" /> | ||
<struct name="light6" ref="mayaDefaultStandardSurface.light6" /> | ||
<struct name="light7" ref="mayaDefaultStandardSurface.light7" /> | ||
<struct name="light8" ref="mayaDefaultStandardSurface.light8" /> | ||
<struct name="light9" ref="mayaDefaultStandardSurface.light9" /> | ||
<struct name="light10" ref="mayaDefaultStandardSurface.light10" /> | ||
<struct name="light11" ref="mayaDefaultStandardSurface.light11" /> | ||
<struct name="light12" ref="mayaDefaultStandardSurface.light12" /> | ||
<struct name="light13" ref="mayaDefaultStandardSurface.light13" /> | ||
<struct name="light14" ref="mayaDefaultStandardSurface.light14" /> | ||
<struct name="light15" ref="mayaDefaultStandardSurface.light15" /> | ||
<float3 name="Nw" ref="mayaDefaultStandardSurface.N" flags="varyingInputParam" /> | ||
<float3 name="Vw" ref="mayaDefaultStandardSurface.V" flags="varyingInputParam" /> | ||
<string name="selector" ref="mayaDefaultStandardSurface.selector" /> | ||
<float3 name="ambientColor" ref="mayaDefaultStandardSurface.ambientColor" /> | ||
<float3 name="ambientIn" ref="mayaDefaultStandardSurface.input" /> | ||
<undefined name="GPUStage" ref="mayaDefaultStandardSurface.GPUStage" semantic="GPUStage" /> | ||
<float4 name="diffuseColor" ref="mayaCPVPassing.colorIn" flags="varyingInputParam" /> | ||
</properties> | ||
<values> | ||
<float name="base" value="1.000000" /> | ||
<float name="specular" value="1.000000" /> | ||
<float3 name="specularColor" value="1.000000,1.000000,1.000000" /> | ||
JGamache-autodesk marked this conversation as resolved.
Show resolved
Hide resolved
|
||
<float name="specularIOR" value="1.500000" /> | ||
<float name="specularRoughness" value="0.500000" /> | ||
<float3 name="transmissionColor" value="1.000000,1.000000,1.000000" /> | ||
<float3 name="subsurfaceColor" value="1.000000,1.000000,1.000000" /> | ||
<float3 name="coatColor" value="1.000000,1.000000,1.000000" /> | ||
<float name="coatIOR" value="1.500000" /> | ||
<float name="coatRoughness" value="0.100000" /> | ||
<float3 name="sheenColor" value="1.000000,1.000000,1.000000" /> | ||
<float name="sheenRoughness" value="0.300000" /> | ||
<float3 name="emissionColor" value="1.000000,1.000000,1.000000" /> | ||
<float name="extraOpacity" value="1.000000" /> | ||
<bool name="fogEnabled" value="false" /> | ||
<float name="fogStart" value="0.000000" /> | ||
<float name="fogEnd" value="92.000000" /> | ||
<int name="fogMode" value="0" /> | ||
<float name="fogDensity" value="0.100000" /> | ||
<float4 name="fogColor" value="0.500000,0.500000,0.500000,1.000000" /> | ||
<float name="fogMultiplier" value="1.000000" /> | ||
<float3 name="IrradianceEnv" value="0.000000,0.000000,0.000000" /> | ||
<float3 name="SpecularEnv" value="0.000000,0.000000,0.000000" /> | ||
<int name="selectionIndex" value="0" /> | ||
<string name="selector" value="mayaLightSelector16" /> | ||
<float3 name="ambientColor" value="0.000000,0.000000,0.000000" /> | ||
<float4 name="diffuseColor" value="0.18,0.18,0.18,1.0" /> | ||
</values> | ||
<outputs> | ||
<float4 name="outSurfaceFinal" ref="mayaDefaultStandardSurface.outSurfaceFinal" /> | ||
</outputs> | ||
</fragment_graph> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would say lets live in the future and not use an environment variable in this situation. There is a MEL call that will tell you what the default shader name is:
If you are curious or want to test that everything still works in a legacy universe, you can either open an old scene that was saved when Lambert was the default, or use the following env var to temporarily restore Lambert as the default:
set MAYA_DEFAULT_SURFACE_SHADER=lambert
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh. That brings back bad memories of PR #2049. The number of unit test results to update would be quite important if you modernize the code.
That would be asking a lot, so let's try a progressive solution: introduce an env var, but instead of having it introduce the new behavior, use it to get back to the previous one:
This way you can add that env var to
test\lib\mayaUsd\render\vp2RenderDelegate\CMakeLists.txt
to not have to update all results, and remove the env var for unit tests that would shine with your new code.One unit test I have in mind would be
test\lib\mayaUsd\render\vp2RenderDelegate\testVP2RenderDelegateDisplayColors.py
with a standardSurface-based scene whenmel.eval("defaultShaderName()") != "lambert1"
. Would require a different set of baseline images in the modern code path. Just add a _standardSurface suffix to them like we do in other modernization situations.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's a great idea to live in the future and have the env var work the other way around. Thanks for the hint of the mel command to get the default shader name, this is a good way to go.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MAYAUSD_VP2_USE_LAMBERT_FALLBACK
and comparison of the default shader name.