When I try to save the shader graph, I get an error that there is no `roughness`

When I try to save a shader graph, I get the following error
I do not have a ‘roughness’ parameter in the shader graph.
Does anyone know how to solve this problem?

[Worker0] KeyNotFoundException: The given key 'roughness' was not present in the dictionary.
System.Collections.Generic.Dictionary`2[TKey,TValue].get_Item (TKey key) (at <dcf6bec1c5764d29a37432d4b047f650>:0)
UnityEditor.ShaderGraph.MaterialX.MtlxNodeData.GetPort (System.String name) (at ./Library/PackageCache/com.unity.polyspatial@1.1.4/Editor/ShaderGraphConversion/System/MtlxGraphData.cs:190)
UnityEditor.ShaderGraph.MaterialX.ExternalEdgeMap.ResolveTypeConversions (UnityEditor.ShaderGraph.MaterialX.MtlxGraphData graph) (at ./Library/PackageCache/com.unity.polyspatial@1.1.4/Editor/ShaderGraphConversion/System/ExternalEdgeMap.cs:94)
UnityEditor.ShaderGraph.MaterialX.ExternalEdgeMap.ResolveExternals (UnityEditor.ShaderGraph.MaterialX.MtlxGraphData graph, System.Boolean flattenTypeConversions) (at ./Library/PackageCache/com.unity.polyspatial@1.1.4/Editor/ShaderGraphConversion/System/ExternalEdgeMap.cs:81)
UnityEditor.ShaderGraph.MaterialX.MtlxPostProcessor.ProcessGraph (UnityEditor.ShaderGraph.GraphData graphData, System.String filename, System.Boolean skipContext) (at ./Library/PackageCache/com.unity.polyspatial@1.1.4/Editor/ShaderGraphConversion/MtlxPostProcessor.cs:95)
UnityEditor.ShaderGraph.MaterialX.MtlxPostProcessor.ProcessFile (System.String assetPath, System.String dstRoot, System.String& filePathNoExtension) (at ./Library/PackageCache/com.unity.polyspatial@1.1.4/Editor/ShaderGraphConversion/MtlxPostProcessor.cs:74)
UnityEditor.ShaderGraph.MaterialX.MtlxPostProcessor.OnImportAsset (UnityEditor.AssetImporters.AssetImportContext context) (at ./Library/PackageCache/com.unity.polyspatial@1.1.4/Editor/ShaderGraphConversion/MtlxPostProcessor.cs:21)
Unity.PolySpatial.Internals.PolySpatialAssetImporter.OnImportAsset (UnityEditor.AssetImporters.AssetImportContext ctx) (at ./Library/PackageCache/com.unity.polyspatial@1.1.4/Editor/PolySpatialAssetImporter.cs:39)
UnityEditor.AssetImporters.ScriptedImporter.GenerateAssetData (UnityEditor.AssetImporters.AssetImportContext ctx) (at /Users/bokken/build/output/unity/unity/Modules/AssetPipelineEditor/Public/ScriptedImporter.cs:25)

I believe this error occurs when you have a “Smoothness” block (even if disabled) in a target that doesn’t support smoothness (such as an Unlit target). We have a fix for this issue in the pipeline, but in the meantime, I’d suggest disconnecting/removing the Smoothness block (you may have to set it to the default value of 0.5 to get it to disappear).

Thank you very much!
The bug was successfully fixed.
Am I correct in understanding that the ‘Smoothness’ in the shader graph is converted to ‘Roughness’ in MaterialX?

1 Like

That’s correct. We target the RealityKit PBR Surface node for lit shader graphs. The conversion is just Roughness = 1.0 - Smoothness.