+2
Under review

Cannot open shader anymore (Null Reference Exception)

Julian Allescher 8 years ago updated by Demian Ford 2 years ago 13

Cannot open my shader file anymore. Shader is working ingame, but Shaderforge refuses to open the file. Unfortunately I haven't made any BackUp of the shader...

This is the message I get:

NullReferenceException: Object reference not set to an instance of an object
ShaderForge.SF_Node.GetInputData (System.String id)
ShaderForge.SFN_Lerp.IsUniformOutput ()
ShaderForge.SFN_If.IsUniformOutput ()
ShaderForge.SF_NodePreview.Combine ()
ShaderForge.SF_Node.RefreshValue (Int32 ia, Int32 ib)
ShaderForge.SF_Node_Arithmetic.RefreshValue ()
ShaderForge.SF_Node.OnUpdateNode (NodeUpdateType updType, Boolean cascade)
ShaderForge.SF_NodeConnector.SetValueType (ValueType vt)
ShaderForge.SFNCG_Arithmetic.SetOutputValueType (ValueType vt)
ShaderForge.SFNCG_Arithmetic.Refresh ()
ShaderForge.SF_NodeConnector.LinkTo (ShaderForge.SF_NodeConnector other, LinkingMethod linkMethod, Boolean registerUndo)
ShaderForge.SF_Link.Establish (ShaderForge.SF_Editor editor, LinkingMethod linkMethod)
ShaderForge.SF_Parser.LoadFromNodeData (System.String data, Single version, System.String& missingNode)
ShaderForge.SF_Parser.ParseNodeDataFromShader (ShaderForge.SF_Editor editor, UnityEngine.Shader s)
ShaderForge.SF_Editor.InitializeInstance (UnityEngine.Shader initShader)
ShaderForge.SF_Editor.Init (UnityEngine.Shader initShader)
UnityEditor.ShaderForgeInspector.OnInspectorGUI () (at Assets/ShaderForge/Editor/InternalResources/Inspectors/ShaderForgeInspector.cs:172)
UnityEditor.InspectorWindow.DrawEditor (UnityEditor.Editor editor, Int32 editorIndex, Boolean forceDirty, System.Boolean& showImportedObjectBarNext, UnityEngine.Rect& importedObjectBarRect, Boolean eyeDropperDirty) (at C:/buildslave/unity/build/Editor/Mono/Inspector/InspectorWindow.cs:1211)
UnityEditor.DockArea:OnGUI()

Under review

Hard to tell what went wrong here. And you don't have the shader left anywhere?

+1

I seem to be getting the same error.


NullReferenceException: Object reference not set to an instance of an object

ShaderForge.SF_Link.Establish (ShaderForge.SF_Editor editor, LinkingMethod linkMethod)
ShaderForge.SF_Parser.LoadFromNodeData (System.String data, Single version, System.String& missingNode)
ShaderForge.SF_Parser.ParseNodeDataFromShader (ShaderForge.SF_Editor editor, UnityEngine.Shader s)
ShaderForge.SF_Editor.InitializeInstance (UnityEngine.Shader initShader)
ShaderForge.SF_Editor.Init (UnityEngine.Shader initShader)
ShaderForgeMaterialInspector.OnInspectorGUI () (at Assets/Libraries/ShaderForge/Editor/InternalResources/Inspectors/ShaderForgeMaterialInspector.cs:85)
UnityEditor.InspectorWindow.DrawEditor (UnityEditor.Editor editor, Int32 editorIndex, Boolean rebuildOptimizedGUIBlock, System.Boolean& showImportedObjectBarNext, UnityEngine.Rect& importedObjectBarRect) (at /Users/builduser/buildslave/unity/build/Editor/Mono/Inspector/InspectorWindow.cs:1235)
UnityEditor.DockArea:OnGUI()


Any idea what the issue could be? What other information might be useful to track down the bug?

This "Bug" or whatever it is, happened once again to me, luckily my last backup was 2 hours ago, but it's still annoying not knowing whether you will be able to open your shader ever again once you close the shaderforge window, though...!
Whenever i try to open the shader, the shaderforge windows just stays grey and I get the following:

NullReferenceException: Object reference not set to an instance of an object
ShaderForge.SF_Node.GetInputData (System.String id)
ShaderForge.SFN_Lerp.IsUniformOutput ()
ShaderForge.SFN_If.IsUniformOutput ()
ShaderForge.SFN_If.IsUniformOutput ()
ShaderForge.SF_NodePreview.Combine ()
ShaderForge.SF_Node.RefreshValue (Int32 ia, Int32 ib)
ShaderForge.SF_Node_Arithmetic.RefreshValue ()
ShaderForge.SF_Node.OnUpdateNode (NodeUpdateType updType, Boolean cascade)
ShaderForge.SF_NodeConnector.SetValueType (ValueType vt)
ShaderForge.SFNCG_Arithmetic.SetOutputValueType (ValueType vt)
ShaderForge.SFNCG_Arithmetic.Refresh ()
ShaderForge.SF_NodeConnector.LinkTo (ShaderForge.SF_NodeConnector other, LinkingMethod linkMethod, Boolean registerUndo)
ShaderForge.SF_Link.Establish (ShaderForge.SF_Editor editor, LinkingMethod linkMethod)
ShaderForge.SF_Parser.LoadFromNodeData (System.String data, Single version, System.String& missingNode)
ShaderForge.SF_Parser.ParseNodeDataFromShader (ShaderForge.SF_Editor editor, UnityEngine.Shader s)
ShaderForge.SF_Editor.InitializeInstance (UnityEngine.Shader initShader)
ShaderForge.SF_Editor.Init (UnityEngine.Shader initShader)
ShaderForgeMaterialInspector.OnInspectorGUI () (at Assets/ShaderForge/Editor/InternalResources/Inspectors/ShaderForgeMaterialInspector.cs:85)
UnityEditor.InspectorWindow.DrawEditor (UnityEditor.Editor editor, Int32 editorIndex, Boolean rebuildOptimizedGUIBlock, System.Boolean& showImportedObjectBarNext, UnityEngine.Rect& importedObjectBarRect) (at C:/buildslave/unity/build/Editor/Mono/Inspector/InspectorWindow.cs:1235)
UnityEditor.DockArea:OnGUI()

Getting the same issue today in Unity 5.4.0f3 with SF 1.28


Spent all day working on a shader, closed Unity, and now when attempting to reopen shader for editing, I get this exception. Here's the code: http://pastebin.com/dNGRxcCH


From the Unity Console:


NullReferenceException: Object reference not set to an instance of an object

ShaderForge.SF_Node.GetInputData (System.String id)
ShaderForge.SFN_Lerp.IsUniformOutput ()
ShaderForge.SFN_If.IsUniformOutput ()
ShaderForge.SF_NodePreview.Combine ()
ShaderForge.SF_Node.RefreshValue (Int32 ia, Int32 ib)
ShaderForge.SF_Node_Arithmetic.RefreshValue ()
ShaderForge.SF_Node.OnUpdateNode (NodeUpdateType updType, Boolean cascade)
ShaderForge.SF_NodeConnector.SetValueType (ValueType vt)
ShaderForge.SFNCG_Arithmetic.SetOutputValueType (ValueType vt)
ShaderForge.SFNCG_Arithmetic.Refresh ()
ShaderForge.SF_NodeConnector.LinkTo (ShaderForge.SF_NodeConnector other, LinkingMethod linkMethod, Boolean registerUndo)
ShaderForge.SF_Link.Establish (ShaderForge.SF_Editor editor, LinkingMethod linkMethod)
ShaderForge.SF_Parser.LoadFromNodeData (System.String data, Single version, System.String& missingNode)
ShaderForge.SF_Parser.ParseNodeDataFromShader (ShaderForge.SF_Editor editor, UnityEngine.Shader s)
ShaderForge.SF_Editor.InitializeInstance (UnityEngine.Shader initShader)
ShaderForge.SF_Editor.Init (UnityEngine.Shader initShader)
ShaderForge.SF_Editor.OpenLoadDialog ()
ShaderForge.SF_Editor.<DrawPrimaryMainMenuGUI>b__32 ()
ShaderForge.SF_Editor.FlexHorizontal (System.Action func)
ShaderForge.SF_Editor.DrawPrimaryMainMenuGUI ()
ShaderForge.SF_Editor.DrawMainMenu ()
ShaderForge.SF_Editor.OnGUI ()
System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222)

Michael, in case you still can't open your shader, here's your shader working again: http://pastebin.com/tVMkFqvN

I couldn't find what the problem was but I got it working by breaking all the connections to the IF node. I replaced all the connections to the IF node with a dummy input. You can delete that dummy input and try to link that IF node back up again the way you had it, and see if it breaks again.

Michael, i can confirm that the OneMinus node is causing the problem. It's the OneMinus that's connected to the Snowiness slider. Just delete that node, and recreate it, and the problem seems to be fixed.

Michael, here's it again but fully fixed: http://pastebin.com/w3EgX6gc

Works in Unity 5.3.5 / SF 1.28


Thanks for the fix :) How did you troubleshoot?

Just read the error message, last error (near the top) listed a lerp. Tried messing with the lerp, nothing happened. So I tried the next line, the IF. Messed with that, and got it working. All the data is at the top of the shader. Just used a text editor to remove the | character and everything after it for the IF node, and that broke all the links going into the IF node, and that got it working again.

Sorry I know this is kinda old post but I have the same problem and I can't find what's wrong with my shader .. it's kinda complicated one.

Here is a link to it https://drive.google.com/open?id=0B88RRqRkmaeUWUpnUDAwbVlaRVU

and thanks in advance!

+1

Hello I get the same problem with SH 1.38 on unity 2017.0.0f3, I don't know if this as been solved somewhere else.


The message is:


NullReferenceException: Object reference not set to an instance of an object
ShaderForge.SF_Node.GetInputData (System.String id)
ShaderForge.SFN_Lerp.IsUniformOutput ()
ShaderForge.SFN_If.IsUniformOutput ()
ShaderForge.SF_NodePreview.Combine ()
ShaderForge.SF_Node.RefreshValue (Int32 ia, Int32 ib)
ShaderForge.SF_Node_Arithmetic.RefreshValue ()
ShaderForge.SF_Node.OnUpdateNode (NodeUpdateType updType, Boolean cascade)
ShaderForge.SF_Node.CheckIfDirty ()
ShaderForge.SF_Editor.Update ()
System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222)
Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:232)
System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MethodBase.cs:115)
UnityEditor.HostView.Invoke (System.String methodName, System.Object obj) (at C:/buildslave/unity/build/Editor/Mono/HostView.cs:272)
UnityEditor.HostView.Invoke (System.String methodName) (at C:/buildslave/unity/build/Editor/Mono/HostView.cs:265)
UnityEditor.HostView.SendUpdate () (at C:/buildslave/unity/build/Editor/Mono/HostView.cs:341)
UnityEditor.EditorApplication.Internal_CallUpdateFunctions () (at C:/buildslave/unity/build/Editor/Mono/EditorApplication.cs:109)


if I try to open it on Unity 5.6.1f1 i d'ont don't get the sema thing, I get:


ArgumentException: The requested value 'glcore' was not found.
System.Enum.Parse (System.Type enumType, System.String value, Boolean ignoreCase) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System/Enum.cs:692)
System.Enum.Parse (System.Type enumType, System.String value) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System/Enum.cs:547)
ShaderForge.SF_Parser.ParseRenderer (System.String[] arr, Boolean only)
ShaderForge.SF_Parser.ExtractShaderForgeData (UnityEngine.Shader s, System.Single& version, Boolean setPath, Boolean findRenderers, Boolean findLOD)
ShaderForge.SF_Parser.ParseNodeDataFromShader (ShaderForge.SF_Editor editor, UnityEngine.Shader s)
ShaderForge.SF_Editor.InitializeInstance (UnityEngine.Shader initShader)
ShaderForge.SF_Editor.Init (UnityEngine.Shader initShader)
ShaderForgeMaterialInspector.OnInspectorGUI () (at Assets/ShaderForge/Editor/InternalResources/Inspectors/ShaderForgeMaterialInspector.cs:85)
UnityEditor.InspectorWindow.DrawEditor (UnityEditor.Editor editor, Int32 editorIndex, Boolean rebuildOptimizedGUIBlock, System.Boolean& showImportedObjectBarNext, UnityEngine.Rect& importedObjectBarRect) (at C:/buildslave/unity/build/Editor/Mono/Inspector/InspectorWindow.cs:1229)
UnityEditor.DockArea:OnGUI()


I put the shader code if this can be usefull.


https://drive.google.com/file/d/1S2-zvuD_YzuOi_xp5QLnJayPmQacs7VQ/view?usp=sharing





 

I've always dreamt of winning BIG in the lottery. I surfed the internet for help to win the lottery massively and I was directed to the DR Amber website. I had a chat with him about what I needed and he assured me that his spell will make me become a lottery winner. He got back to me after 3 days with the numbers that I needed to play the lottery and told me to believe in myself. I felt enveloped by the control of the spell. I took his words and played the Mega Millions Lottery. Two days later, I was sent an email that I've won the sum of 107 Million Dollars. I was shocked and couldn't believe what my eyes were seeing. Immediately I was given the cash prize, I stopped working. I want to say a very big thank you to DR Amber for helping people like us who really need help. Now I know that there's absolutely nothing too hard for DR Amber to do. To get in touch with him, email : [ amberlottotemple@yahoo.com ] or click his webpage URL___ amberlottotemple.com