0

Sampler2D output of Code node causes NullReferenceException

Will Preston 2 months ago • updated 2 months ago 2

Using: ShaderForge version , Unity version 5.6.4f1.


Two NullReferenceException errors occur, one is one-time and the other appears to be every editor Update().


One-time error:



Steps to reproduce:


  1. Create Code node.  Inputs do not matter, only the output matters.
  2. Select the Sampler 2D output type for the Code node.
  3. Enter any valid code, e.g. return 1; as a placeholder.
  4. Create a Texture 2D node.
  5. Try to connect the Code node's output to the Texture2D node's Tex input.
  6. Observe the console for the exceptions.

For some reason the report was submitted early.  ShaderForge is version 1.36.


The one-time error is: 

NullReferenceException: Object reference not set to an instance of an object
ShaderForge.SFN_Tex2d.IsNormalMap ()
ShaderForge.SFN_Tex2d.GetEvaluatedComponentCount ()
ShaderForge.SF_NodePreview.Combine ()
ShaderForge.SF_Node.RefreshValue (Int32 ia, Int32 ib)
ShaderForge.SFN_Tex2d.RefreshValue ()
ShaderForge.SF_Node.OnUpdateNode (NodeUpdateType updType, Boolean cascade)
ShaderForge.SF_NodeConnector.LinkTo (ShaderForge.SF_NodeConnector other, LinkingMethod linkMethod, Boolean registerUndo)
ShaderForge.SF_NodeConnector.LinkTo (ShaderForge.SF_NodeConnector other, LinkingMethod linkMethod, Boolean registerUndo)
ShaderForge.SF_NodeConnector.TryMakeConnection ()
ShaderForge.SF_NodeConnector.CheckConnection (ShaderForge.SF_Editor editor)
ShaderForge.SF_Node.DrawConnections ()
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)

The repeating error is:

NullReferenceException: Object reference not set to an instance of an object
ShaderForge.SFN_Tex2d.get_TextureAsset ()
ShaderForge.SFN_Tex2d.Draw ()
ShaderForge.SF_EditorNodeView.OnLocalGUI (Rect r)
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)


Please see this GIF demonstrating the bug in action: