I am currently using the 2022.2 URP fork for motion vectors. After much troubleshooting, I found that enabling Alpha Clipping or Allow Material Override in a shader graph return an error, and do not work.
The error is :
NullReferenceException: Object reference not set to an instance of an object
UnityEditor.Rendering.Universal.ShaderGraph.CorePasses.AddAlphaClipControlToPass (UnityEditor.ShaderGraph.PassDescriptor& pass, UnityEditor.Rendering.Universal.ShaderGraph.UniversalTarget target) (at ./Library/PackageCache/com.unity.render-pipelines.universal@428604577a/Editor/ShaderGraph/Targets/UniversalTarget.cs:858)
UnityEditor.Rendering.Universal.ShaderGraph.CorePasses.MotionVectors (UnityEditor.Rendering.Universal.ShaderGraph.UniversalTarget target) (at ./Library/PackageCache/com.unity.render-pipelines.universal@428604577a/Editor/ShaderGraph/Targets/UniversalTarget.cs:1090)
UnityEditor.Rendering.Universal.ShaderGraph.UniversalLitSubTarget+SubShaders.LitComputeDotsSubShader (UnityEditor.Rendering.Universal.ShaderGraph.UniversalTarget target, UnityEditor.Rendering.Universal.ShaderGraph.WorkflowMode workflowMode, System.String renderType, System.String renderQueue, System.String disableBatchingTag, System.Boolean complexLit, System.Boolean blendModePreserveSpecular) (at ./Library/PackageCache/com.unity.render-pipelines.universal@428604577a/Editor/ShaderGraph/Targets/UniversalLitSubTarget.cs:370)
UnityEditor.Rendering.Universal.ShaderGraph.UniversalLitSubTarget.Setup (UnityEditor.ShaderGraph.TargetSetupContext& context) (at ./Library/PackageCache/com.unity.render-pipelines.universal@428604577a/Editor/ShaderGraph/Targets/UniversalLitSubTarget.cs:93)
UnityEditor.Rendering.Universal.ShaderGraph.UniversalTarget.Setup (UnityEditor.ShaderGraph.TargetSetupContext& context) (at ./Library/PackageCache/com.unity.render-pipelines.universal@428604577a/Editor/ShaderGraph/Targets/UniversalTarget.cs:360)
UnityEditor.ShaderGraph.Generator..ctor (UnityEditor.ShaderGraph.GraphData graphData, UnityEditor.ShaderGraph.AbstractMaterialNode outputNode, UnityEditor.ShaderGraph.GenerationMode mode, System.String primaryShaderName, UnityEditor.ShaderGraph.Target[] targets, UnityEditor.ShaderGraph.AssetCollection assetCollection, System.Boolean humanReadable) (at ./Library/PackageCache/com.unity.shadergraph@428604577a/Editor/Generation/Processors/Generator.cs:111)
UnityEditor.ShaderGraph.Drawing.PreviewManager.CompileMasterNodeShader () (at ./Library/PackageCache/com.unity.shadergraph@428604577a/Editor/Drawing/PreviewManager.cs:1251)
UnityEditor.ShaderGraph.Drawing.PreviewManager.KickOffShaderCompilations () (at ./Library/PackageCache/com.unity.shadergraph@428604577a/Editor/Drawing/PreviewManager.cs:828)
UnityEditor.ShaderGraph.Drawing.PreviewManager.UpdateShaders () (at ./Library/PackageCache/com.unity.shadergraph@428604577a/Editor/Drawing/PreviewManager.cs:882)
UnityEditor.ShaderGraph.Drawing.PreviewManager.RenderPreviews (UnityEditor.EditorWindow editorWindow, System.Boolean requestShaders) (at ./Library/PackageCache/com.unity.shadergraph@428604577a/Editor/Drawing/PreviewManager.cs:534)
UnityEditor.ShaderGraph.Drawing.GraphEditorView.HandleGraphChanges (System.Boolean wasUndoRedoPerformed) (at ./Library/PackageCache/com.unity.shadergraph@428604577a/Editor/Drawing/Views/GraphEditorView.cs:685)
UnityEditor.ShaderGraph.Drawing.MaterialGraphEditWindow.Update () (at ./Library/PackageCache/com.unity.shadergraph@428604577a/Editor/Drawing/MaterialGraphEditWindow.cs:384)
UnityEditor.HostView.SendUpdate () (at <ae93fefe62eb49e6b9ef3807ffd33dc7>:0)
UnityEditor.EditorApplication.Internal_CallUpdateFunctions () (at <ae93fefe62eb49e6b9ef3807ffd33dc7>:0)
Which ends at the function:
internal static void AddAlphaClipControlToPass(ref PassDescriptor pass, UniversalTarget target)
{
if (target.allowMaterialOverride)
pass.keywords.Add(CoreKeywordDescriptors.AlphaTestOn);
else if (target.alphaClip)
pass.defines.Add(CoreKeywordDescriptors.AlphaTestOn, 1);
}
Any help in resolving this would be life saving.
Found this issue that fixed my problem:
opened 09:46PM - 17 Apr 22 UTC
```
NullReferenceException: Object reference not set to an instance of an objec… t
UnityEditor.Rendering.Universal.ShaderGraph.CorePasses.AddAlphaClipControlToPass (UnityEditor.ShaderGraph.PassDescriptor& pass, UnityEditor.Rendering.Universal.ShaderGraph.UniversalTarget target) (at Library/PackageCache/com.unity.render-pipelines.universal@f21c66817f/Editor/ShaderGraph/Targets/UniversalTarget.cs:697)
UnityEditor.Rendering.Universal.ShaderGraph.CorePasses.MotionVectors (UnityEditor.Rendering.Universal.ShaderGraph.UniversalTarget target) (at Library/PackageCache/com.unity.render-pipelines.universal@f21c66817f/Editor/ShaderGraph/Targets/UniversalTarget.cs:907)
UnityEditor.Rendering.Universal.ShaderGraph.UniversalUnlitSubTarget+SubShaders.Unlit (UnityEditor.Rendering.Universal.ShaderGraph.UniversalTarget target, System.String renderType, System.String renderQueue) (at Library/PackageCache/com.unity.render-pipelines.universal@f21c66817f/Editor/ShaderGraph/Targets/UniversalUnlitSubTarget.cs:164)
UnityEditor.Rendering.Universal.ShaderGraph.UniversalUnlitSubTarget.Setup (UnityEditor.ShaderGraph.TargetSetupContext& context) (at Library/PackageCache/com.unity.render-pipelines.universal@f21c66817f/Editor/ShaderGraph/Targets/UniversalUnlitSubTarget.cs:41)
UnityEditor.Rendering.Universal.ShaderGraph.UniversalTarget.Setup (UnityEditor.ShaderGraph.TargetSetupContext& context) (at Library/PackageCache/com.unity.render-pipelines.universal@f21c66817f/Editor/ShaderGraph/Targets/UniversalTarget.cs:303)
UnityEditor.ShaderGraph.Generator.BuildShader () (at Library/PackageCache/com.unity.shadergraph@292ae099c5/Editor/Generation/Processors/Generator.cs:196)
UnityEditor.ShaderGraph.Generator.Generate (UnityEditor.ShaderGraph.GenerationMode mode, System.String name, UnityEditor.ShaderGraph.AssetCollection assetCollection, UnityEditor.ShaderGraph.Target[] targets, System.Boolean humanReadable) (at Library/PackageCache/com.unity.shadergraph@292ae099c5/Editor/Generation/Processors/Generator.cs:65)
UnityEditor.ShaderGraph.Generator..ctor (UnityEditor.ShaderGraph.GraphData graphData, UnityEditor.ShaderGraph.AbstractMaterialNode outputNode, UnityEditor.ShaderGraph.GenerationMode mode, System.String name, UnityEditor.ShaderGraph.AssetCollection assetCollection, System.Boolean humanReadable) (at Library/PackageCache/com.unity.shadergraph@292ae099c5/Editor/Generation/Processors/Generator.cs:41)
UnityEditor.ShaderGraph.Drawing.PreviewManager.CompileMasterNodeShader () (at Library/PackageCache/com.unity.shadergraph@292ae099c5/Editor/Drawing/PreviewManager.cs:1215)
UnityEditor.ShaderGraph.Drawing.PreviewManager.KickOffShaderCompilations () (at Library/PackageCache/com.unity.shadergraph@292ae099c5/Editor/Drawing/PreviewManager.cs:792)
UnityEditor.ShaderGraph.Drawing.PreviewManager.UpdateShaders () (at Library/PackageCache/com.unity.shadergraph@292ae099c5/Editor/Drawing/PreviewManager.cs:846)
UnityEditor.ShaderGraph.Drawing.PreviewManager.RenderPreviews (UnityEditor.EditorWindow editorWindow, System.Boolean requestShaders) (at Library/PackageCache/com.unity.shadergraph@292ae099c5/Editor/Drawing/PreviewManager.cs:498)
UnityEditor.ShaderGraph.Drawing.GraphEditorView.HandleGraphChanges (System.Boolean wasUndoRedoPerformed) (at Library/PackageCache/com.unity.shadergraph@292ae099c5/Editor/Drawing/Views/GraphEditorView.cs:685)
UnityEditor.ShaderGraph.Drawing.MaterialGraphEditWindow.Update () (at
Library/PackageCache/com.unity.shadergraph@292ae099c5/Editor/Drawing/MaterialGraphEditWindow.cs:361)
UnityEditor.EditorApplication:Internal_CallUpdateFunctions()
and
Library/PackageCache/com.unity.shadergraph@292ae099c5/Editor/Drawing/MaterialGraphEditWindow.cs:373)
UnityEditor.HostView.SendUpdate () (at <780782bc035845f9909cebbd4c983ae3>:0)
UnityEditor.EditorApplication.Internal_CallUpdateFunctions () (at <780782bc035845f9909cebbd4c983ae3>:0)
```
This is true for Universal active target ( both Lit and Unlit ) there is no issue when the shader graph is VIsual Effect
Branch : [2021.2/oculus-appsw-particles](https://github.com/Oculus-VR/Unity-Graphics/tree/2021.2/oculus-appsw-particles)
Commit : [30e14a2](https://github.com/Oculus-VR/Unity-Graphics/commit/30e14a2ca18f7c4c9903767895c1ca15d1af6c76)
Unity Version : 2021.2.19f
This seems like an easy fix to add Oculus peoples.
KevinXR
January 19, 2024, 10:49pm
3
Thanks for identifying this @NoteMEdown . I’ll make sure it gets routed to the right team here at Unity.