Oculus-VR / Unity-Graphics

Unity Graphics - Including Scriptable Render Pipeline
Other
61 stars 50 forks source link

Enabling Alpha Clipping in Shader Graph raises an Error #12

Open nukadelic opened 2 years ago

nukadelic commented 2 years ago
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@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 Commit : 30e14a2 Unity Version : 2021.2.19f

nukadelic commented 2 years ago

here is a sample project to replicate the error : link

jnalbyon commented 1 year ago

Just add defines = new DefineCollection(), in Packages/com.unity.render-pipelines.universal/Editor/ShaderGraph/Targets/UniversalTarget.cs line 902 after // Conditionnal state

nukadelic commented 1 year ago

There is a similar issue for Allow Material Override in Shader Graph Inspector , fix: add this at after line 905 in the Editor/ShaderGraph/Targets/UniversalTarget.cs file :

keywords = new KeywordCollection(),

Both patches are included in my repo : link

luiginicastro commented 1 year ago

How exactly do I find those scripts in my Unity project to add those fixes?

nukadelic commented 1 year ago

@luiginicastro you would have to clone the repository and move the files into the Asset folder , then you will be able to edit the files.

Alternately I have created UPM packages ( already cloned it , added the changes and included that in my sample project ) - simply add the following url's into the Packages/manifest.json file ( make sure to remove any default key dependencies if you need ) :

    "com.unity.render-pipelines.core": "https://gin.g-node.org/FloppyDisk/asw-render-pipelines-core.git",
    "com.unity.render-pipelines.universal": "https://gin.g-node.org/FloppyDisk/asw-render-pipelines-universal.git",
    "com.unity.shadergraph": "https://gin.g-node.org/FloppyDisk/asw-shader-graph.git",
    "com.unity.visualeffectgraph": "https://gin.g-node.org/FloppyDisk/asw-visual-effect-graph.git",
luiginicastro commented 1 year ago

@nukadelic I got it! Thank you for the help :)

NoteMEdown commented 5 months ago

Just add defines = new DefineCollection(), in Packages/com.unity.render-pipelines.universal/Editor/ShaderGraph/Targets/UniversalTarget.cs line 902 after // Conditionnal state

You saved my life. How can i ever repay you