summaryrefslogtreecommitdiff
path: root/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2020-10-23 13:08:43 +0800
committerchai <chaifix@163.com>2020-10-23 13:08:43 +0800
commitb82da95b5181ac8bbae38efb13e950d5e88a4caa (patch)
tree48a6f3269276484bbc7cfc95f0651f40a2176aa1 /Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs
parent917e9e0b320775634dc2e710f7deac74fd0822f0 (diff)
*移动amplify shader editor到third party目录
Diffstat (limited to 'Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs')
-rw-r--r--Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/ColorInputsNode.cs17
-rw-r--r--Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/ColorInputsNode.cs.meta12
-rw-r--r--Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/GrabScreenPosition.cs118
-rw-r--r--Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/GrabScreenPosition.cs.meta12
-rw-r--r--Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/LocalVertexPosNode.cs50
-rw-r--r--Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/LocalVertexPosNode.cs.meta12
-rw-r--r--Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/ScreenColorNode.cs678
-rw-r--r--Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/ScreenColorNode.cs.meta12
-rw-r--r--Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/ScreenDepthNode.cs173
-rw-r--r--Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/ScreenDepthNode.cs.meta12
-rw-r--r--Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/ScreenPosInputsNode.cs155
-rw-r--r--Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/ScreenPosInputsNode.cs.meta12
-rw-r--r--Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/SurfaceShaderINParentNode.cs122
-rw-r--r--Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/SurfaceShaderINParentNode.cs.meta12
-rw-r--r--Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/TexelSizeNode.cs304
-rw-r--r--Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/TexelSizeNode.cs.meta12
-rw-r--r--Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/UVCoordsParentNode.cs112
-rw-r--r--Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/UVCoordsParentNode.cs.meta12
-rw-r--r--Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/ViewDirInputsCoordNode.cs167
-rw-r--r--Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/ViewDirInputsCoordNode.cs.meta12
-rw-r--r--Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/WorldNormalInputsNode.cs119
-rw-r--r--Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/WorldNormalInputsNode.cs.meta12
-rw-r--r--Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/WorldNormalVector.cs178
-rw-r--r--Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/WorldNormalVector.cs.meta12
-rw-r--r--Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/WorldPosInputsNode.cs37
-rw-r--r--Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/WorldPosInputsNode.cs.meta12
-rw-r--r--Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/WorldReflInputsNode.cs18
-rw-r--r--Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/WorldReflInputsNode.cs.meta12
-rw-r--r--Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/WorldReflectionVector.cs213
-rw-r--r--Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/WorldReflectionVector.cs.meta12
30 files changed, 2641 insertions, 0 deletions
diff --git a/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/ColorInputsNode.cs b/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/ColorInputsNode.cs
new file mode 100644
index 00000000..e4223e1b
--- /dev/null
+++ b/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/ColorInputsNode.cs
@@ -0,0 +1,17 @@
+// Amplify Shader Editor - Visual Shader Editing Tool
+// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
+
+namespace AmplifyShaderEditor
+{
+ [System.Serializable]
+ [NodeAttributes( "Color", "Surface Data", "Interpolated per-vertex color", null, UnityEngine.KeyCode.None, true, true, "Vertex Color", typeof( VertexColorNode ) )]
+ public sealed class ColorInputsNode : SurfaceShaderINParentNode
+ {
+ protected override void CommonInit( int uniqueId )
+ {
+ base.CommonInit( uniqueId );
+ m_currentInput = SurfaceInputs.COLOR;
+ InitialSetup();
+ }
+ }
+}
diff --git a/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/ColorInputsNode.cs.meta b/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/ColorInputsNode.cs.meta
new file mode 100644
index 00000000..8f36faf6
--- /dev/null
+++ b/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/ColorInputsNode.cs.meta
@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: ee44f086d7aa7804ea035860c5735cfb
+timeCreated: 1481126960
+licenseType: Store
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/GrabScreenPosition.cs b/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/GrabScreenPosition.cs
new file mode 100644
index 00000000..3e2a5117
--- /dev/null
+++ b/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/GrabScreenPosition.cs
@@ -0,0 +1,118 @@
+// Amplify Shader Editor - Visual Shader Editing Tool
+// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
+
+using System;
+using UnityEditor;
+using UnityEngine;
+
+namespace AmplifyShaderEditor
+{
+ [Serializable]
+ [NodeAttributes( "Grab Screen Position", "Camera And Screen", "Screen position correctly transformed to be used with Grab Screen Color" )]
+ public sealed class GrabScreenPosition : ParentNode
+ {
+ private readonly string[] m_outputTypeStr = { "Normalized", "Screen" };
+
+ [SerializeField]
+ private int m_outputTypeInt = 0;
+
+ private UpperLeftWidgetHelper m_upperLeftWidget = new UpperLeftWidgetHelper();
+
+ protected override void CommonInit( int uniqueId )
+ {
+ base.CommonInit( uniqueId );
+ AddOutputVectorPorts( WirePortDataType.FLOAT4, "XYZW" );
+ m_autoWrapProperties = true;
+ m_hasLeftDropdown = true;
+ m_textLabelWidth = 65;
+ ConfigureHeader();
+ }
+
+ public override void AfterCommonInit()
+ {
+ base.AfterCommonInit();
+
+ if( PaddingTitleLeft == 0 )
+ {
+ PaddingTitleLeft = Constants.PropertyPickerWidth + Constants.IconsLeftRightMargin;
+ if( PaddingTitleRight == 0 )
+ PaddingTitleRight = Constants.PropertyPickerWidth + Constants.IconsLeftRightMargin;
+ }
+ }
+
+ public override void Destroy()
+ {
+ base.Destroy();
+ m_upperLeftWidget = null;
+ }
+
+ public override void Draw( DrawInfo drawInfo )
+ {
+ base.Draw( drawInfo );
+ EditorGUI.BeginChangeCheck();
+ m_outputTypeInt = m_upperLeftWidget.DrawWidget( this, m_outputTypeInt, m_outputTypeStr );
+ if( EditorGUI.EndChangeCheck() )
+ {
+ ConfigureHeader();
+ }
+ }
+
+ public override void DrawProperties()
+ {
+ base.DrawProperties();
+
+ EditorGUI.BeginChangeCheck();
+ m_outputTypeInt = EditorGUILayoutPopup( "Type", m_outputTypeInt, m_outputTypeStr );
+ if( EditorGUI.EndChangeCheck() )
+ {
+ ConfigureHeader();
+ }
+ }
+
+ void ConfigureHeader()
+ {
+ SetAdditonalTitleText( string.Format( Constants.SubTitleTypeFormatStr, m_outputTypeStr[ m_outputTypeInt ] ) );
+ }
+
+ public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalVar )
+ {
+ if( m_outputPorts[ 0 ].IsLocalValue( dataCollector.PortCategory ) )
+ return GetOutputColorItem( 0, outputId, m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ) );
+
+ string localVarName = string.Empty;
+
+ if( m_outputTypeInt == 0 )
+ localVarName = GeneratorUtils.GenerateGrabScreenPositionNormalized( ref dataCollector, UniqueId, CurrentPrecisionType, !dataCollector.UsingCustomScreenPos );
+ else
+ localVarName = GeneratorUtils.GenerateGrabScreenPosition( ref dataCollector, UniqueId, CurrentPrecisionType, !dataCollector.UsingCustomScreenPos );
+
+ m_outputPorts[ 0 ].SetLocalValue( localVarName, dataCollector.PortCategory );
+ return GetOutputColorItem( 0, outputId, localVarName );
+ }
+
+ public override void ReadFromString( ref string[] nodeParams )
+ {
+ base.ReadFromString( ref nodeParams );
+ if( UIUtils.CurrentShaderVersion() > 3108 )
+ {
+ if( UIUtils.CurrentShaderVersion() < 6102 )
+ {
+ bool project = Convert.ToBoolean( GetCurrentParam( ref nodeParams ) );
+ m_outputTypeInt = project ? 0 : 1;
+ }
+ else
+ {
+ m_outputTypeInt = Convert.ToInt32( GetCurrentParam( ref nodeParams ) );
+ }
+ }
+
+ ConfigureHeader();
+ }
+
+ public override void WriteToString( ref string nodeInfo, ref string connectionsInfo )
+ {
+ base.WriteToString( ref nodeInfo, ref connectionsInfo );
+ IOUtils.AddFieldValueToString( ref nodeInfo, m_outputTypeInt );
+ }
+ }
+}
diff --git a/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/GrabScreenPosition.cs.meta b/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/GrabScreenPosition.cs.meta
new file mode 100644
index 00000000..5a57543d
--- /dev/null
+++ b/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/GrabScreenPosition.cs.meta
@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: 47af62ad6a29d1b409d526d352b5e677
+timeCreated: 1485198163
+licenseType: Store
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/LocalVertexPosNode.cs b/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/LocalVertexPosNode.cs
new file mode 100644
index 00000000..785e39fa
--- /dev/null
+++ b/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/LocalVertexPosNode.cs
@@ -0,0 +1,50 @@
+// Amplify Shader Editor - Visual Shader Editing Tool
+// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
+
+using System;
+using UnityEngine;
+
+namespace AmplifyShaderEditor
+{
+ [Serializable]
+ [NodeAttributes( "[Deprecated] Local Position", "Surface Data", "Interpolated Vertex Position in Local Space", null, KeyCode.None, true, true, "Vertex Position", typeof( PosVertexDataNode ) )]
+ public sealed class LocalVertexPosNode : ParentNode
+ {
+ private const string VertexVarName = "localVertexPos";
+ private readonly string VertexOnFrag = Constants.InputVarStr + "." + VertexVarName;
+ private readonly string VertexOnVert = Constants.VertexShaderInputStr + ".vertex";
+
+
+ [SerializeField]
+ private bool m_addInstruction = false;
+
+ public override void Reset()
+ {
+ base.Reset();
+ m_addInstruction = true;
+ }
+ protected override void CommonInit( int uniqueId )
+ {
+ base.CommonInit( uniqueId );
+ AddOutputVectorPorts( WirePortDataType.FLOAT3, "XYZ" );
+ }
+ public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar )
+ {
+ if ( dataCollector.PortCategory == MasterNodePortCategory.Vertex || dataCollector.PortCategory == MasterNodePortCategory.Tessellation )
+ {
+ return GetOutputVectorItem( 0, outputId, VertexOnVert );
+ }
+ else
+ {
+ if ( m_addInstruction )
+ {
+ dataCollector.AddToInput( UniqueId, VertexVarName, WirePortDataType.FLOAT3 );
+ dataCollector.AddVertexInstruction( Constants.VertexShaderOutputStr + "." + VertexVarName + " = " + Constants.VertexShaderInputStr + ".vertex.xyz ", UniqueId );
+ m_addInstruction = false;
+ }
+
+ return GetOutputVectorItem( 0, outputId, VertexOnFrag );
+ }
+ }
+ }
+}
diff --git a/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/LocalVertexPosNode.cs.meta b/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/LocalVertexPosNode.cs.meta
new file mode 100644
index 00000000..91b6b542
--- /dev/null
+++ b/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/LocalVertexPosNode.cs.meta
@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: 2528fbf85b5823a4499871c2a6eecc0a
+timeCreated: 1481126954
+licenseType: Store
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/ScreenColorNode.cs b/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/ScreenColorNode.cs
new file mode 100644
index 00000000..60a7f230
--- /dev/null
+++ b/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/ScreenColorNode.cs
@@ -0,0 +1,678 @@
+// Amplify Shader Editor - Visual Shader Editing Tool
+// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
+
+using UnityEngine;
+using UnityEditor;
+using System;
+
+namespace AmplifyShaderEditor
+{
+
+ [Serializable]
+ [NodeAttributes( "Grab Screen Color", "Camera And Screen", "Grabed pixel color value from screen" )]
+ public sealed class ScreenColorNode : PropertyNode
+ {
+#if UNITY_5_6_OR_NEWER
+ private readonly string[] ASEDeclareMacro =
+ {
+ "#if defined(UNITY_STEREO_INSTANCING_ENABLED) || defined(UNITY_STEREO_MULTIVIEW_ENABLED)",
+ "#define ASE_DECLARE_SCREENSPACE_TEXTURE(tex) UNITY_DECLARE_SCREENSPACE_TEXTURE(tex);",
+ "#else",
+ "#define ASE_DECLARE_SCREENSPACE_TEXTURE(tex) UNITY_DECLARE_SCREENSPACE_TEXTURE(tex)",
+ "#endif"
+ };
+#endif
+ private readonly Color ReferenceHeaderColor = new Color( 0.6f, 3.0f, 1.25f, 1.0f );
+
+ private const string SamplerType = "tex2D";
+ private const string GrabTextureDefault = "_GrabTexture";
+ private const string ScreenColorStr = "screenColor";
+
+ [SerializeField]
+ private TexReferenceType m_referenceType = TexReferenceType.Object;
+
+ [SerializeField]
+ private int m_referenceArrayId = -1;
+
+ [SerializeField]
+ private int m_referenceNodeId = -1;
+
+ [SerializeField]
+ private GUIStyle m_referenceIconStyle = null;
+
+ private ScreenColorNode m_referenceNode = null;
+
+ [SerializeField]
+ private bool m_normalize = false;
+
+ [SerializeField]
+ private bool m_useCustomGrab = false;
+
+ [SerializeField]
+ private float m_referenceWidth = -1;
+
+ //SRP specific code
+ private const string OpaqueTextureDefine = "REQUIRE_OPAQUE_TEXTURE 1";
+ private const string FetchVarName = "fetchOpaqueVal";
+
+ //private string LWFetchOpaqueTexture = "SAMPLE_TEXTURE2D( _CameraOpaqueTexture, sampler_CameraOpaqueTexture, {0})";
+ private string LWFetchOpaqueTexture = "float4( SHADERGRAPH_SAMPLE_SCENE_COLOR( {0} ), 1.0 )";
+#if UNITY_2018_3_OR_NEWER
+ private const string HDSampleSceneColorHeader5 = "ASEHDSampleSceneColor({0}, {1}, {2})";
+ private readonly string[] HDSampleSceneColorFunc5 =
+ {
+ "float4 ASEHDSampleSceneColor(float2 uv, float lod, float exposureMultiplier)\n",
+ "{\n",
+ "\t#if defined(REQUIRE_OPAQUE_TEXTURE) && defined(_SURFACE_TYPE_TRANSPARENT) && defined(SHADERPASS) && (SHADERPASS != SHADERPASS_LIGHT_TRANSPORT)\n",
+ "\treturn float4( SampleCameraColor(uv, lod) * exposureMultiplier, 1.0 );\n",
+ "\t#endif\n",
+ "\treturn float4(0.0, 0.0, 0.0, 1.0);\n",
+ "}\n",
+ };
+
+ private const string HDSampleSceneColorHeader4 = "ASEHDSampleSceneColor({0})";
+ private readonly string[] HDSampleSceneColorFunc4 =
+ {
+ "float4 ASEHDSampleSceneColor( float2 uv )\n",
+ "{\n",
+ "\t#if defined(REQUIRE_OPAQUE_TEXTURE) && defined(_SURFACE_TYPE_TRANSPARENT) && defined(SHADERPASS) && (SHADERPASS != SHADERPASS_LIGHT_TRANSPORT)\n",
+ "\treturn float4( SampleCameraColor(uv), 1.0 );\n",
+ "\t#endif\n",
+ "\treturn float4(0.0, 0.0, 0.0, 1.0);\n",
+ "}\n",
+ };
+#endif
+
+#if !UNITY_2018_3_OR_NEWER
+ // Legacy SRP code
+ private const string DeclareOpaqueTextureObject = "TEXTURE2D( _CameraOpaqueTexture);";
+ private const string DeclareOpaqueTextureSampler = "SAMPLER( sampler_CameraOpaqueTexture);";
+#endif
+ public ScreenColorNode() : base() { }
+ public ScreenColorNode( int uniqueId, float x, float y, float width, float height ) : base( uniqueId, x, y, width, height ) { }
+
+ protected override void CommonInit( int uniqueId )
+ {
+ base.CommonInit( uniqueId );
+
+ AddInputPort( WirePortDataType.FLOAT2, false, "UV" );
+ AddOutputColorPorts( "RGBA" );
+
+ m_currentParameterType = PropertyType.Global;
+ m_underscoredGlobal = true;
+ m_useVarSubtitle = true;
+ m_customPrefix = "Grab Screen ";
+ m_freeType = false;
+ m_drawAttributes = false;
+ m_showTitleWhenNotEditing = false;
+ m_textLabelWidth = 125;
+ m_showAutoRegisterUI = true;
+ m_globalDefaultBehavior = false;
+ m_showVariableMode = true;
+ }
+
+ protected override void OnUniqueIDAssigned()
+ {
+ base.OnUniqueIDAssigned();
+ if( m_referenceType == TexReferenceType.Object )
+ UIUtils.RegisterScreenColorNode( this );
+
+ if( UniqueId > -1 )
+ ContainerGraph.ScreenColorNodes.OnReorderEventComplete += OnReorderEventComplete;
+
+ }
+
+ private void OnReorderEventComplete()
+ {
+ if( m_referenceType == TexReferenceType.Instance && m_referenceNode != null )
+ {
+ m_referenceArrayId = ContainerGraph.ScreenColorNodes.GetNodeRegisterIdx( m_referenceNode.UniqueId );
+ }
+ }
+
+ void UpdateHeaderColor()
+ {
+ m_headerColorModifier = ( m_referenceType == TexReferenceType.Object ) ? Color.white : ReferenceHeaderColor;
+ }
+
+ public override void OnNodeLogicUpdate( DrawInfo drawInfo )
+ {
+ base.OnNodeLogicUpdate( drawInfo );
+ if( m_referenceNodeId > -1 && m_referenceNode == null )
+ {
+ m_referenceNode = UIUtils.GetScreenColorNode( m_referenceNodeId ) as ScreenColorNode;
+ if( m_referenceNode == null )
+ {
+ m_referenceNodeId = -1;
+ m_referenceArrayId = -1;
+ m_sizeIsDirty = true;
+ }
+ }
+
+ if( m_showSubtitle == m_containerGraph.IsSRP )
+ {
+ m_showSubtitle = !m_containerGraph.IsSRP;
+ m_sizeIsDirty = true;
+ }
+ }
+
+ protected override void ChangeSizeFinished()
+ {
+ if( m_referenceType == TexReferenceType.Instance )
+ {
+ m_position.width += 20;
+ }
+ }
+
+ public override void Draw( DrawInfo drawInfo )
+ {
+ base.Draw( drawInfo );
+
+ CheckReference();
+
+ if( SoftValidReference )
+ {
+ m_content.text = m_referenceNode.TitleContent.text + Constants.InstancePostfixStr;
+ SetAdditonalTitleText( m_referenceNode.AdditonalTitleContent.text );
+
+ if( m_referenceIconStyle == null )
+ {
+ m_referenceIconStyle = UIUtils.GetCustomStyle( CustomStyle.SamplerTextureIcon );
+ }
+
+ Rect iconPos = m_globalPosition;
+ iconPos.width = 19 * drawInfo.InvertedZoom;
+ iconPos.height = 19 * drawInfo.InvertedZoom;
+
+ iconPos.y += 6 * drawInfo.InvertedZoom;
+ iconPos.x += m_globalPosition.width - iconPos.width - 7 * drawInfo.InvertedZoom;
+
+ if( GUI.Button( iconPos, string.Empty, m_referenceIconStyle ) )
+ {
+ UIUtils.FocusOnNode( m_referenceNode, 1, true );
+ }
+ }
+ }
+
+ void CheckReference()
+ {
+ if( m_referenceType != TexReferenceType.Instance )
+ {
+ return;
+ }
+
+ if( m_referenceArrayId > -1 )
+ {
+ ParentNode newNode = UIUtils.GetScreenColorNode( m_referenceArrayId );
+ if( newNode == null || newNode.UniqueId != m_referenceNodeId )
+ {
+ m_referenceNode = null;
+ int count = UIUtils.GetScreenColorNodeAmount();
+ for( int i = 0; i < count; i++ )
+ {
+ ParentNode node = UIUtils.GetScreenColorNode( i );
+ if( node.UniqueId == m_referenceNodeId )
+ {
+ m_referenceNode = node as ScreenColorNode;
+ m_referenceArrayId = i;
+ break;
+ }
+ }
+ }
+ }
+
+ if( m_referenceNode == null && m_referenceNodeId > -1 )
+ {
+ m_referenceNodeId = -1;
+ m_referenceArrayId = -1;
+ }
+ }
+
+ public override void DrawMainPropertyBlock()
+ {
+ EditorGUI.BeginChangeCheck();
+ m_referenceType = (TexReferenceType)EditorGUILayoutPopup( Constants.ReferenceTypeStr, (int)m_referenceType, Constants.ReferenceArrayLabels );
+ if( EditorGUI.EndChangeCheck() )
+ {
+ m_sizeIsDirty = true;
+ if( m_referenceType == TexReferenceType.Object )
+ {
+ UIUtils.RegisterScreenColorNode( this );
+ m_content.text = m_propertyInspectorName;
+ }
+ else
+ {
+ UIUtils.UnregisterScreenColorNode( this );
+ if( SoftValidReference )
+ {
+ m_content.text = m_referenceNode.TitleContent.text + Constants.InstancePostfixStr;
+ }
+ }
+ UpdateHeaderColor();
+ }
+
+ if( m_referenceType == TexReferenceType.Object )
+ {
+ EditorGUI.BeginDisabledGroup( m_containerGraph.IsSRP );
+ {
+ EditorGUI.BeginChangeCheck();
+ m_useCustomGrab = EditorGUILayoutToggle( "Custom Grab Pass", m_useCustomGrab );
+ EditorGUI.BeginDisabledGroup( !m_useCustomGrab );
+ DrawMainPropertyBlockNoPrecision();
+ EditorGUI.EndDisabledGroup();
+
+ m_normalize = EditorGUILayoutToggle( "Normalize", m_normalize );
+ if( EditorGUI.EndChangeCheck() )
+ {
+ UpdatePort();
+ if( m_useCustomGrab )
+ {
+ BeginPropertyFromInspectorCheck();
+ }
+ }
+ }
+ EditorGUI.EndDisabledGroup();
+ }
+ else
+ {
+ string[] arr = UIUtils.ScreenColorNodeArr();
+ bool guiEnabledBuffer = GUI.enabled;
+ if( arr != null && arr.Length > 0 )
+ {
+ GUI.enabled = true;
+ }
+ else
+ {
+ m_referenceArrayId = -1;
+ GUI.enabled = false;
+ }
+
+ m_referenceArrayId = EditorGUILayoutPopup( Constants.AvailableReferenceStr, m_referenceArrayId, arr );
+ GUI.enabled = guiEnabledBuffer;
+ EditorGUI.BeginDisabledGroup( m_containerGraph.IsSRP );
+ {
+ EditorGUI.BeginChangeCheck();
+ m_normalize = EditorGUILayoutToggle( "Normalize", m_normalize );
+ if( EditorGUI.EndChangeCheck() )
+ {
+ UpdatePort();
+ }
+ }
+ EditorGUI.EndDisabledGroup();
+ }
+ ShowVariableMode();
+ ShowAutoRegister();
+ }
+
+ private void UpdatePort()
+ {
+ if( m_normalize )
+ m_inputPorts[ 0 ].ChangeType( WirePortDataType.FLOAT4, false );
+ else
+ m_inputPorts[ 0 ].ChangeType( WirePortDataType.FLOAT2, false );
+ }
+
+ public override void DrawTitle( Rect titlePos )
+ {
+ if( !m_isEditing && ContainerGraph.LodLevel <= ParentGraph.NodeLOD.LOD3 )
+ {
+ GUI.Label( titlePos, "Grab Screen Color", UIUtils.GetCustomStyle( CustomStyle.NodeTitle ) );
+ }
+
+ if( m_useCustomGrab || SoftValidReference )
+ {
+ base.DrawTitle( titlePos );
+ m_previousAdditonalTitle = m_additionalContent.text;
+ }
+ else
+ if( ContainerGraph.LodLevel <= ParentGraph.NodeLOD.LOD3 )
+ {
+ SetAdditonalTitleTextOnCallback( GrabTextureDefault, ( instance, newSubTitle ) => instance.AdditonalTitleContent.text = string.Format( Constants.SubTitleVarNameFormatStr, newSubTitle ) );
+ //GUI.Label( titlePos, PropertyInspectorName, UIUtils.GetCustomStyle( CustomStyle.NodeTitle ) );
+ }
+ }
+
+ public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalVar )
+ {
+#if UNITY_5_6_OR_NEWER
+ if( !dataCollector.IsTemplate || dataCollector.CurrentSRPType == TemplateSRPType.BuiltIn )
+ {
+ for( int i = 0; i < ASEDeclareMacro.Length; i++ )
+ {
+ dataCollector.AddToDirectives( ASEDeclareMacro[ i ]);
+ }
+ }
+#endif
+
+#if !UNITY_2018_3_OR_NEWER
+ if( dataCollector.IsTemplate && dataCollector.CurrentSRPType == TemplateSRPType.HD )
+ {
+ UIUtils.ShowMessage( UniqueId, "GrabPasses are not supported on Unity HD Scriptable Rendering Pipeline old versions." );
+ return GetOutputColorItem( 0, outputId, "(0).xxxx" );
+ }
+#endif
+ if( m_outputPorts[ 0 ].IsLocalValue( dataCollector.PortCategory ) )
+ return GetOutputColorItem( 0, outputId, m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ) );
+
+ string valueName = string.Empty;
+ if( dataCollector.IsSRP )
+ {
+#if !UNITY_2018_3_OR_NEWER
+ dataCollector.AddToUniforms( UniqueId, DeclareOpaqueTextureObject );
+ dataCollector.AddToUniforms( UniqueId, DeclareOpaqueTextureSampler );
+#endif
+ valueName = FetchVarName + OutputId;
+ dataCollector.AddToDirectives( OpaqueTextureDefine, -1 , AdditionalLineType.Define);
+ string uvCoords = GetUVCoords( ref dataCollector, ignoreLocalVar, false );
+ if( dataCollector.TemplateDataCollectorInstance.IsLWRP )
+ {
+ dataCollector.AddLocalVariable( UniqueId, CurrentPrecisionType, WirePortDataType.FLOAT4, valueName, string.Format( LWFetchOpaqueTexture, uvCoords ) );
+ }
+ else
+ {
+#if UNITY_2018_3_OR_NEWER
+ if( ASEPackageManagerHelper.CurrentHDVersion >= ASESRPVersions.ASE_SRP_5_13_0 )
+ {
+ dataCollector.AddFunction( HDSampleSceneColorFunc5[ 0 ], HDSampleSceneColorFunc5, false );
+ dataCollector.AddLocalVariable( UniqueId, m_currentPrecisionType, WirePortDataType.FLOAT4, valueName, string.Format( HDSampleSceneColorHeader5, uvCoords, "0", "GetInverseCurrentExposureMultiplier()" ) );
+ }
+ else
+ {
+ dataCollector.AddFunction( HDSampleSceneColorFunc4[ 0 ], HDSampleSceneColorFunc4, false );
+ dataCollector.AddLocalVariable( UniqueId, m_currentPrecisionType, WirePortDataType.FLOAT4, valueName, string.Format( HDSampleSceneColorHeader4, uvCoords ) );
+ }
+#endif
+ }
+ }
+ else
+ {
+ base.GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalVar );
+ string propertyName = CurrentPropertyReference;
+ OnPropertyNameChanged();
+ //bool emptyName = string.IsNullOrEmpty( m_propertyInspectorName ) || propertyName == GrabTextureDefault;
+ bool emptyName = string.IsNullOrEmpty( m_propertyInspectorName ) || !m_useCustomGrab;
+ dataCollector.AddGrabPass( emptyName ? string.Empty : propertyName );
+ valueName = SetFetchedData( ref dataCollector, ignoreLocalVar );
+ }
+
+ m_outputPorts[ 0 ].SetLocalValue( valueName, dataCollector.PortCategory );
+ return GetOutputColorItem( 0, outputId, valueName );
+ }
+
+
+ public override void OnPropertyNameChanged()
+ {
+ base.OnPropertyNameChanged();
+ UIUtils.UpdateScreenColorDataNode( UniqueId, DataToArray );
+ }
+
+ public string SetFetchedData( ref MasterNodeDataCollector dataCollector, bool ignoreLocalVar )
+ {
+ string propertyName = CurrentPropertyReference;
+
+ bool isProjecting = m_normalize;
+
+ if( !m_inputPorts[ 0 ].IsConnected ) // to generate proper screen pos by itself
+ isProjecting = true;
+
+ if( ignoreLocalVar )
+ {
+ string samplerValue = SamplerType + ( isProjecting ? "proj" : "" ) + "( " + propertyName + ", " + GetUVCoords( ref dataCollector, ignoreLocalVar, isProjecting ) + " )";
+ return samplerValue;
+ }
+
+ if( m_outputPorts[ 0 ].IsLocalValue( dataCollector.PortCategory ) )
+ return m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory );
+
+ string uvValue = GetUVCoords( ref dataCollector, ignoreLocalVar, isProjecting );
+#if UNITY_5_6_OR_NEWER
+ if( isProjecting )
+ {
+ uvValue = string.Format( "{0}.xy/{0}.w", uvValue );
+ }
+ string samplerOp = string.Format( "UNITY_SAMPLE_SCREENSPACE_TEXTURE({0},{1})", propertyName, uvValue );
+#else
+ string samplerOp = SamplerType + ( isProjecting ? "proj" : "" ) + "( " + propertyName + ", " + uvValue + " )";
+#endif
+ dataCollector.AddLocalVariable( UniqueId, UIUtils.PrecisionWirePortToCgType( CurrentPrecisionType, m_outputPorts[ 0 ].DataType ) + " " + ScreenColorStr + OutputId + " = " + samplerOp + ";" );
+ return ScreenColorStr + OutputId;
+ }
+
+ private string GetUVCoords( ref MasterNodeDataCollector dataCollector, bool ignoreLocalVar, bool isProjecting )
+ {
+ string result = string.Empty;
+
+ if( m_inputPorts[ 0 ].IsConnected )
+ {
+ result = m_inputPorts[ 0 ].GenerateShaderForOutput( ref dataCollector, ( isProjecting ? WirePortDataType.FLOAT4 : WirePortDataType.FLOAT2 ), ignoreLocalVar, true );
+ }
+ else
+ {
+ string customScreenPos = null;
+
+ if( dataCollector.IsTemplate )
+ customScreenPos = dataCollector.TemplateDataCollectorInstance.GetScreenPos( CurrentPrecisionType );
+
+ if( isProjecting )
+ result = GeneratorUtils.GenerateGrabScreenPosition( ref dataCollector, UniqueId, CurrentPrecisionType, !dataCollector.UsingCustomScreenPos, customScreenPos );
+ else
+ result = GeneratorUtils.GenerateGrabScreenPositionNormalized( ref dataCollector, UniqueId, CurrentPrecisionType, !dataCollector.UsingCustomScreenPos, customScreenPos );
+ }
+
+ if( isProjecting && !dataCollector.IsSRP )
+#if UNITY_5_6_OR_NEWER
+ return result;
+#else
+ return "UNITY_PROJ_COORD( " + result + " )";
+#endif
+ else
+ return result;
+ }
+
+ public override void Destroy()
+ {
+ base.Destroy();
+ if( m_referenceType == TexReferenceType.Object )
+ {
+ UIUtils.UnregisterScreenColorNode( this );
+ }
+ if( UniqueId > -1 )
+ ContainerGraph.ScreenColorNodes.OnReorderEventComplete -= OnReorderEventComplete;
+ }
+
+ public bool SoftValidReference
+ {
+ get
+ {
+ if( m_referenceType == TexReferenceType.Instance && m_referenceArrayId > -1 )
+ {
+ m_referenceNode = UIUtils.GetScreenColorNode( m_referenceArrayId );
+ if( m_referenceNode == null )
+ {
+ m_referenceArrayId = -1;
+ m_referenceWidth = -1;
+ }
+ else if( m_referenceWidth != m_referenceNode.Position.width )
+ {
+ m_referenceWidth = m_referenceNode.Position.width;
+ m_sizeIsDirty = true;
+ }
+ return m_referenceNode != null;
+ }
+ return false;
+ }
+ }
+
+ public string CurrentPropertyReference
+ {
+ get
+ {
+ string propertyName = string.Empty;
+ if( m_referenceType == TexReferenceType.Instance && m_referenceArrayId > -1 )
+ {
+ ScreenColorNode node = UIUtils.GetScreenColorNode( m_referenceArrayId );
+ propertyName = ( node != null ) ? node.PropertyName : m_propertyName;
+ }
+ else if( !m_useCustomGrab )
+ {
+ propertyName = GrabTextureDefault;
+ }
+ else
+ {
+ propertyName = m_propertyName;
+ }
+ return propertyName;
+ }
+ }
+
+
+ public override void ReadFromString( ref string[] nodeParams )
+ {
+ base.ReadFromString( ref nodeParams );
+ if( UIUtils.CurrentShaderVersion() > 12 )
+ {
+ m_referenceType = (TexReferenceType)Enum.Parse( typeof( TexReferenceType ), GetCurrentParam( ref nodeParams ) );
+ if( UIUtils.CurrentShaderVersion() > 22 )
+ {
+ m_referenceNodeId = Convert.ToInt32( GetCurrentParam( ref nodeParams ) );
+ }
+ else
+ {
+ m_referenceArrayId = Convert.ToInt32( GetCurrentParam( ref nodeParams ) );
+ }
+
+ if( m_referenceType == TexReferenceType.Instance )
+ {
+ UIUtils.UnregisterScreenColorNode( this );
+ }
+
+ UpdateHeaderColor();
+ }
+
+ if( UIUtils.CurrentShaderVersion() > 12101 )
+ {
+ m_useCustomGrab = Convert.ToBoolean( GetCurrentParam( ref nodeParams ) );
+ }
+ else
+ {
+ m_useCustomGrab = true;
+ }
+
+ if( UIUtils.CurrentShaderVersion() > 14102 )
+ {
+ m_normalize = Convert.ToBoolean( GetCurrentParam( ref nodeParams ) );
+ }
+
+ if( !m_isNodeBeingCopied && m_referenceType == TexReferenceType.Object )
+ {
+ ContainerGraph.ScreenColorNodes.UpdateDataOnNode( UniqueId, DataToArray );
+ }
+ }
+
+ public override void WriteToString( ref string nodeInfo, ref string connectionsInfo )
+ {
+ base.WriteToString( ref nodeInfo, ref connectionsInfo );
+ IOUtils.AddFieldValueToString( ref nodeInfo, m_referenceType );
+ IOUtils.AddFieldValueToString( ref nodeInfo, ( ( m_referenceNode != null ) ? m_referenceNode.UniqueId : -1 ) );
+ IOUtils.AddFieldValueToString( ref nodeInfo, m_useCustomGrab );
+ IOUtils.AddFieldValueToString( ref nodeInfo, m_normalize );
+ }
+
+ public override void RefreshExternalReferences()
+ {
+ base.RefreshExternalReferences();
+ if( m_referenceType == TexReferenceType.Instance )
+ {
+ if( UIUtils.CurrentShaderVersion() > 22 )
+ {
+ m_referenceNode = UIUtils.GetNode( m_referenceNodeId ) as ScreenColorNode;
+ m_referenceArrayId = UIUtils.GetScreenColorNodeRegisterId( m_referenceNodeId );
+ }
+ else
+ {
+ m_referenceNode = UIUtils.GetScreenColorNode( m_referenceArrayId );
+ if( m_referenceNode != null )
+ {
+ m_referenceNodeId = m_referenceNode.UniqueId;
+ }
+ }
+ }
+
+ if( UIUtils.CurrentShaderVersion() <= 14102 )
+ {
+ if( m_inputPorts[ 0 ].DataType == WirePortDataType.FLOAT4 )
+ m_normalize = true;
+ else
+ m_normalize = false;
+ }
+ }
+
+ public override string PropertyName
+ {
+ get
+ {
+ if( m_useCustomGrab )
+ return base.PropertyName;
+ else
+ return GrabTextureDefault;
+ }
+ }
+
+ public override string GetPropertyValStr()
+ {
+ return PropertyName;
+ }
+
+ public override string DataToArray { get { return m_propertyName; } }
+
+ public override string GetUniformValue()
+ {
+ if( SoftValidReference )
+ {
+ if( m_referenceNode.IsConnected )
+ return string.Empty;
+
+ return m_referenceNode.GetUniformValue();
+ }
+#if UNITY_5_6_OR_NEWER
+ return "ASE_DECLARE_SCREENSPACE_TEXTURE( " + PropertyName + " )";
+#else
+ return "uniform sampler2D " + PropertyName + ";";
+#endif
+ }
+
+ public override bool GetUniformData( out string dataType, out string dataName, ref bool fullValue )
+ {
+ if( SoftValidReference )
+ {
+ //if ( m_referenceNode.IsConnected )
+ //{
+ // dataType = string.Empty;
+ // dataName = string.Empty;
+ //}
+
+ return m_referenceNode.GetUniformData( out dataType, out dataName, ref fullValue );
+ }
+#if UNITY_5_6_OR_NEWER
+ dataName = "ASE_DECLARE_SCREENSPACE_TEXTURE( " + PropertyName + " )";
+ dataType = string.Empty;
+ fullValue = true;
+#else
+ dataType = "sampler2D";
+ dataName = PropertyName;
+#endif
+ return true;
+ }
+
+ public override void CheckIfAutoRegister( ref MasterNodeDataCollector dataCollector )
+ {
+ if( m_autoRegister && m_connStatus != NodeConnectionStatus.Connected )
+ {
+ RegisterProperty( ref dataCollector );
+ string propertyName = CurrentPropertyReference;
+ bool emptyName = string.IsNullOrEmpty( m_propertyInspectorName ) || propertyName == GrabTextureDefault;
+ dataCollector.AddGrabPass( emptyName ? string.Empty : propertyName );
+ }
+ }
+ }
+}
diff --git a/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/ScreenColorNode.cs.meta b/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/ScreenColorNode.cs.meta
new file mode 100644
index 00000000..2012d503
--- /dev/null
+++ b/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/ScreenColorNode.cs.meta
@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: b266c7cca236bcb469d6d4f13df55df5
+timeCreated: 1481126958
+licenseType: Store
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/ScreenDepthNode.cs b/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/ScreenDepthNode.cs
new file mode 100644
index 00000000..d08d1c80
--- /dev/null
+++ b/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/ScreenDepthNode.cs
@@ -0,0 +1,173 @@
+// Amplify Shader Editor - Visual Shader Editing Tool
+// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
+
+using UnityEngine;
+using UnityEditor;
+
+using System;
+namespace AmplifyShaderEditor
+{
+ [Serializable]
+ [NodeAttributes( "Screen Depth", "Camera And Screen", "Given a screen position returns the depth of the scene to the object as seen by the camera" )]
+ public sealed class ScreenDepthNode : ParentNode
+ {
+ [SerializeField]
+ private bool m_convertToLinear = true;
+
+ [SerializeField]
+ private int m_viewSpaceInt = 0;
+
+ private const string ConvertToLinearStr = "Convert To Linear";
+
+ private readonly string[] m_viewSpaceStr = { "Eye Space", "0-1 Space" };
+
+ private readonly string[] m_vertexNameStr = { "eyeDepth", "clampDepth" };
+
+ private UpperLeftWidgetHelper m_upperLeftWidget = new UpperLeftWidgetHelper();
+
+ protected override void CommonInit( int uniqueId )
+ {
+ base.CommonInit( uniqueId );
+ AddInputPort( WirePortDataType.FLOAT4, false, "Pos" );
+ AddOutputPort( WirePortDataType.FLOAT, "Depth" );
+ m_autoWrapProperties = true;
+ m_hasLeftDropdown = true;
+ SetAdditonalTitleText( string.Format( Constants.SubTitleSpaceFormatStr, m_viewSpaceStr[ m_viewSpaceInt ] ) );
+ }
+
+ public override void AfterCommonInit()
+ {
+ base.AfterCommonInit();
+ if( PaddingTitleLeft == 0 )
+ {
+ PaddingTitleLeft = Constants.PropertyPickerWidth + Constants.IconsLeftRightMargin;
+ if( PaddingTitleRight == 0 )
+ PaddingTitleRight = Constants.PropertyPickerWidth + Constants.IconsLeftRightMargin;
+ }
+ }
+
+ public override void Destroy()
+ {
+ base.Destroy();
+ m_upperLeftWidget = null;
+ }
+
+ public override void Draw( DrawInfo drawInfo )
+ {
+ base.Draw( drawInfo );
+ EditorGUI.BeginChangeCheck();
+ m_viewSpaceInt = m_upperLeftWidget.DrawWidget( this, m_viewSpaceInt, m_viewSpaceStr );
+ if( EditorGUI.EndChangeCheck() )
+ {
+ SetAdditonalTitleText( string.Format( Constants.SubTitleSpaceFormatStr, m_viewSpaceStr[ m_viewSpaceInt ] ) );
+ }
+ }
+
+ public override void DrawProperties()
+ {
+ base.DrawProperties();
+ EditorGUI.BeginChangeCheck();
+ m_viewSpaceInt = EditorGUILayoutPopup( "View Space", m_viewSpaceInt, m_viewSpaceStr );
+ if( EditorGUI.EndChangeCheck() )
+ {
+ SetAdditonalTitleText( string.Format( Constants.SubTitleSpaceFormatStr, m_viewSpaceStr[ m_viewSpaceInt ] ) );
+ }
+
+ m_convertToLinear = EditorGUILayoutToggle( ConvertToLinearStr, m_convertToLinear );
+ }
+
+ public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar )
+ {
+ if( dataCollector.PortCategory == MasterNodePortCategory.Tessellation )
+ {
+ UIUtils.ShowNoVertexModeNodeMessage( this );
+ return "0";
+ }
+
+ if( m_outputPorts[ 0 ].IsLocalValue( dataCollector.PortCategory ) )
+ return GetOutputColorItem( 0, outputId, m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ) );
+
+ if( !( dataCollector.IsTemplate && dataCollector.IsSRP ) )
+ dataCollector.AddToIncludes( UniqueId, Constants.UnityCgLibFuncs );
+
+ if( !dataCollector.IsTemplate || dataCollector.TemplateDataCollectorInstance.CurrentSRPType != TemplateSRPType.HD )
+ {
+ if( dataCollector.IsTemplate && dataCollector.CurrentSRPType == TemplateSRPType.Lightweight )
+ {
+ //dataCollector.AddToUniforms( UniqueId, Constants.CameraDepthTextureSRPVar );
+ //dataCollector.AddToUniforms( UniqueId, Constants.CameraDepthTextureSRPSampler );
+ dataCollector.AddToDirectives( Constants.CameraDepthTextureLWEnabler, -1, AdditionalLineType.Define );
+ }
+ else
+ {
+ dataCollector.AddToUniforms( UniqueId, Constants.CameraDepthTextureValue );
+ }
+ dataCollector.AddToUniforms( UniqueId, Constants.CameraDepthTextureTexelSize );
+ }
+
+
+ string screenPosNorm = string.Empty;
+ if( m_inputPorts[ 0 ].IsConnected )
+ screenPosNorm = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector );
+ else
+ {
+ if( dataCollector.IsTemplate )
+ {
+ if( !dataCollector.TemplateDataCollectorInstance.GetCustomInterpolatedData( TemplateInfoOnSematics.SCREEN_POSITION_NORMALIZED, WirePortDataType.FLOAT4, PrecisionType.Float, ref screenPosNorm, true,MasterNodePortCategory.Fragment ) )
+ {
+ screenPosNorm = GeneratorUtils.GenerateScreenPositionNormalized( ref dataCollector, UniqueId, CurrentPrecisionType, !dataCollector.UsingCustomScreenPos );
+ }
+ }
+ else
+ {
+ screenPosNorm = GeneratorUtils.GenerateScreenPositionNormalized( ref dataCollector, UniqueId, CurrentPrecisionType, !dataCollector.UsingCustomScreenPos );
+ }
+ }
+
+ string screenDepthInstruction = TemplateHelperFunctions.CreateDepthFetch( dataCollector, screenPosNorm );
+
+ if( m_convertToLinear )
+ {
+ string viewSpace = m_viewSpaceInt == 0 ? "LinearEyeDepth" : "Linear01Depth";
+ string formatStr = string.Empty;
+ if( ( dataCollector.IsTemplate && dataCollector.IsSRP ) )
+ formatStr = "(" + screenDepthInstruction + ",_ZBufferParams)";
+ else
+ formatStr = "(" + screenDepthInstruction + ")";
+ screenDepthInstruction = viewSpace + formatStr;
+ }
+ else
+ {
+ if( m_viewSpaceInt == 0 )
+ {
+ screenDepthInstruction = string.Format( "({0}*( _ProjectionParams.z - _ProjectionParams.y ))", screenDepthInstruction );
+ }
+ }
+
+ dataCollector.AddLocalVariable( UniqueId, CurrentPrecisionType, WirePortDataType.FLOAT, m_vertexNameStr[ m_viewSpaceInt ] + OutputId, screenDepthInstruction );
+
+ m_outputPorts[ 0 ].SetLocalValue( m_vertexNameStr[ m_viewSpaceInt ] + OutputId, dataCollector.PortCategory );
+ return GetOutputColorItem( 0, outputId, m_vertexNameStr[ m_viewSpaceInt ] + OutputId );
+ }
+
+ public override void ReadFromString( ref string[] nodeParams )
+ {
+ base.ReadFromString( ref nodeParams );
+ m_viewSpaceInt = Convert.ToInt32( GetCurrentParam( ref nodeParams ) );
+ if( UIUtils.CurrentShaderVersion() >= 13901 )
+ {
+ m_convertToLinear = Convert.ToBoolean( GetCurrentParam( ref nodeParams ) );
+ }
+
+ SetAdditonalTitleText( string.Format( Constants.SubTitleSpaceFormatStr, m_viewSpaceStr[ m_viewSpaceInt ] ) );
+ }
+
+ public override void WriteToString( ref string nodeInfo, ref string connectionsInfo )
+ {
+ base.WriteToString( ref nodeInfo, ref connectionsInfo );
+ IOUtils.AddFieldValueToString( ref nodeInfo, m_viewSpaceInt );
+ IOUtils.AddFieldValueToString( ref nodeInfo, m_convertToLinear );
+ }
+ }
+
+}
diff --git a/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/ScreenDepthNode.cs.meta b/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/ScreenDepthNode.cs.meta
new file mode 100644
index 00000000..95f77777
--- /dev/null
+++ b/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/ScreenDepthNode.cs.meta
@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: 52266d8a6f7f4fe428dcee2ddb0514ac
+timeCreated: 1481126955
+licenseType: Store
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/ScreenPosInputsNode.cs b/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/ScreenPosInputsNode.cs
new file mode 100644
index 00000000..6acaa57f
--- /dev/null
+++ b/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/ScreenPosInputsNode.cs
@@ -0,0 +1,155 @@
+// Amplify Shader Editor - Visual Shader Editing Tool
+// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
+
+using UnityEngine;
+using UnityEditor;
+using System;
+
+namespace AmplifyShaderEditor
+{
+ [Serializable]
+ [NodeAttributes( "Screen Position", "Camera And Screen", "Screen space position, you can either get the <b>Screen</b> position as is or <b>Normalize</b> it to have it at the [0,1] range" )]
+ public sealed class ScreenPosInputsNode : SurfaceShaderINParentNode
+ {
+ private const string ProjectStr = "Project";
+ private const string UVInvertHack = "Scale and Offset";
+ private readonly string[] m_outputTypeStr = { "Normalized", "Screen" };
+
+ [SerializeField]
+ private int m_outputTypeInt = 0;
+
+ [SerializeField]
+ private bool m_scaleAndOffset = false;
+
+ private UpperLeftWidgetHelper m_upperLeftWidget = new UpperLeftWidgetHelper();
+
+ protected override void CommonInit( int uniqueId )
+ {
+ base.CommonInit( uniqueId );
+ m_currentInput = SurfaceInputs.SCREEN_POS;
+ InitialSetup();
+ m_textLabelWidth = 65;
+ m_autoWrapProperties = true;
+
+ m_hasLeftDropdown = true;
+ m_previewShaderGUID = "a5e7295278a404175b732f1516fb68a6";
+
+ if( UIUtils.CurrentWindow != null && UIUtils.CurrentWindow.CurrentGraph != null && UIUtils.CurrentShaderVersion() <= 2400 )
+ {
+ m_outputTypeInt = 1;
+ m_previewMaterialPassId = m_outputTypeInt;
+ }
+
+ ConfigureHeader();
+ }
+
+ public override void Draw( DrawInfo drawInfo )
+ {
+ base.Draw( drawInfo );
+ EditorGUI.BeginChangeCheck();
+ m_outputTypeInt = m_upperLeftWidget.DrawWidget( this, m_outputTypeInt, m_outputTypeStr );
+ if( EditorGUI.EndChangeCheck() )
+ {
+ ConfigureHeader();
+ }
+ }
+
+ public override void DrawProperties()
+ {
+ //base.DrawProperties();
+
+ EditorGUI.BeginChangeCheck();
+ m_outputTypeInt = EditorGUILayoutPopup( "Type", m_outputTypeInt, m_outputTypeStr );
+ if( EditorGUI.EndChangeCheck() )
+ {
+ ConfigureHeader();
+ }
+ }
+
+ void ConfigureHeader()
+ {
+ SetAdditonalTitleText( string.Format( Constants.SubTitleTypeFormatStr, m_outputTypeStr[ m_outputTypeInt ] ) );
+ m_previewMaterialPassId = m_outputTypeInt;
+ }
+
+ public override void Reset()
+ {
+ base.Reset();
+ }
+
+ public override void Destroy()
+ {
+ base.Destroy();
+ m_upperLeftWidget = null;
+ }
+
+ public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalVar )
+ {
+ if( m_outputPorts[ 0 ].IsLocalValue( dataCollector.PortCategory ) )
+ {
+ return GetOutputVectorItem( 0, outputId, m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ) );
+ }
+ m_currentPrecisionType = PrecisionType.Float;
+
+ string screenPos = string.Empty;
+ if( m_outputTypeInt == 0 )
+ {
+ if( dataCollector.IsTemplate )
+ {
+ screenPos = dataCollector.TemplateDataCollectorInstance.GetScreenPosNormalized( CurrentPrecisionType );
+ }
+ else
+ {
+ screenPos = GeneratorUtils.GenerateScreenPositionNormalized( ref dataCollector, UniqueId, CurrentPrecisionType);
+ }
+ }
+ else
+ {
+ if( dataCollector.IsTemplate )
+ {
+ screenPos = dataCollector.TemplateDataCollectorInstance.GetScreenPos( CurrentPrecisionType );
+ }
+ else
+ {
+ screenPos = GeneratorUtils.GenerateScreenPosition( ref dataCollector, UniqueId, CurrentPrecisionType );
+ }
+ }
+
+ m_outputPorts[ 0 ].SetLocalValue( screenPos, dataCollector.PortCategory );
+ return GetOutputVectorItem( 0, outputId, screenPos );
+
+ }
+
+ public override void ReadFromString( ref string[] nodeParams )
+ {
+ base.ReadFromString( ref nodeParams );
+ if( UIUtils.CurrentShaderVersion() > 2400 )
+ {
+ if( UIUtils.CurrentShaderVersion() < 6102 )
+ {
+ bool project = Convert.ToBoolean( GetCurrentParam( ref nodeParams ) );
+ m_outputTypeInt = project ? 0 : 1;
+ }
+ else
+ {
+ m_outputTypeInt = Convert.ToInt32( GetCurrentParam( ref nodeParams ) );
+ }
+ }
+
+ if( UIUtils.CurrentShaderVersion() > 3107 )
+ {
+ m_scaleAndOffset = Convert.ToBoolean( GetCurrentParam( ref nodeParams ) );
+ m_scaleAndOffset = false;
+ }
+
+ ConfigureHeader();
+ }
+
+ public override void WriteToString( ref string nodeInfo, ref string connectionsInfo )
+ {
+ base.WriteToString( ref nodeInfo, ref connectionsInfo );
+ IOUtils.AddFieldValueToString( ref nodeInfo, m_outputTypeInt );
+ IOUtils.AddFieldValueToString( ref nodeInfo, m_scaleAndOffset );
+ }
+ }
+}
diff --git a/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/ScreenPosInputsNode.cs.meta b/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/ScreenPosInputsNode.cs.meta
new file mode 100644
index 00000000..60d2abbd
--- /dev/null
+++ b/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/ScreenPosInputsNode.cs.meta
@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: 32cea8ff65efa3844a0047477ec789da
+timeCreated: 1481126954
+licenseType: Store
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/SurfaceShaderINParentNode.cs b/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/SurfaceShaderINParentNode.cs
new file mode 100644
index 00000000..e0f094b0
--- /dev/null
+++ b/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/SurfaceShaderINParentNode.cs
@@ -0,0 +1,122 @@
+// Amplify Shader Editor - Visual Shader Editing Tool
+// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
+
+using System;
+using UnityEngine;
+
+namespace AmplifyShaderEditor
+{
+ [Serializable]
+ public class SurfaceShaderINParentNode : ParentNode
+ {
+ [SerializeField]
+ protected SurfaceInputs m_currentInput;
+
+ [SerializeField]
+ protected string m_currentInputValueStr;
+
+ [SerializeField]
+ protected string m_currentInputDecStr;
+
+ protected override void CommonInit( int uniqueId )
+ {
+ base.CommonInit( uniqueId );
+ m_currentInput = SurfaceInputs.UV_COORDS;
+ m_textLabelWidth = 65;
+ m_customPrecision = true;
+ }
+
+ public override void DrawProperties()
+ {
+ base.DrawProperties();
+ DrawPrecisionProperty();
+ }
+ //This needs to be called on the end of the CommonInit on all children
+ protected void InitialSetup()
+ {
+ m_currentInputValueStr = Constants.InputVarStr + "." + UIUtils.GetInputValueFromType( m_currentInput );
+
+ string outputName = "Out";
+ switch ( m_currentInput )
+ {
+ case SurfaceInputs.DEPTH:
+ {
+ AddOutputPort( WirePortDataType.FLOAT, outputName );
+ }
+ break;
+ case SurfaceInputs.UV_COORDS:
+ {
+ outputName = "UV";
+ AddOutputVectorPorts( WirePortDataType.FLOAT2, outputName );
+ }
+ break;
+ case SurfaceInputs.UV2_COORDS:
+ {
+ outputName = "UV";
+ AddOutputVectorPorts( WirePortDataType.FLOAT2, outputName );
+ }
+ break;
+ case SurfaceInputs.VIEW_DIR:
+ {
+ outputName = "XYZ";
+ AddOutputVectorPorts( WirePortDataType.FLOAT3, outputName );
+ }
+ break;
+ case SurfaceInputs.COLOR:
+ {
+ outputName = "RGBA";
+ AddOutputVectorPorts( WirePortDataType.FLOAT4, outputName );
+ }
+ break;
+ case SurfaceInputs.SCREEN_POS:
+ {
+ outputName = "XYZW";
+ AddOutputVectorPorts( WirePortDataType.FLOAT4, outputName );
+ }
+ break;
+ case SurfaceInputs.WORLD_POS:
+ {
+ outputName = "XYZ";
+ AddOutputVectorPorts( WirePortDataType.FLOAT3, outputName );
+ }
+ break;
+ case SurfaceInputs.WORLD_REFL:
+ {
+ outputName = "XYZ";
+ AddOutputVectorPorts( WirePortDataType.FLOAT3, outputName );
+ }
+ break;
+ case SurfaceInputs.WORLD_NORMAL:
+ {
+ outputName = "XYZ";
+ AddOutputVectorPorts( WirePortDataType.FLOAT3, outputName );
+ }
+ break;
+ }
+ }
+
+ public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalVar )
+ {
+ dataCollector.AddToInput( UniqueId, m_currentInput, CurrentPrecisionType );
+ switch ( m_currentInput )
+ {
+ case SurfaceInputs.VIEW_DIR:
+ case SurfaceInputs.WORLD_REFL:
+ case SurfaceInputs.WORLD_NORMAL:
+ {
+ dataCollector.AddToInput( UniqueId, SurfaceInputs.INTERNALDATA, addSemiColon: false );
+ }
+ break;
+ case SurfaceInputs.WORLD_POS:
+ case SurfaceInputs.DEPTH:
+ case SurfaceInputs.UV_COORDS:
+ case SurfaceInputs.UV2_COORDS:
+ case SurfaceInputs.COLOR:
+ case SurfaceInputs.SCREEN_POS: break;
+ };
+
+ return GetOutputVectorItem( 0, outputId, m_currentInputValueStr );
+ }
+
+ }
+}
diff --git a/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/SurfaceShaderINParentNode.cs.meta b/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/SurfaceShaderINParentNode.cs.meta
new file mode 100644
index 00000000..92a1e5b1
--- /dev/null
+++ b/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/SurfaceShaderINParentNode.cs.meta
@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: 71628885b2fde0944bf7dd8e4eb2770f
+timeCreated: 1481126956
+licenseType: Store
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/TexelSizeNode.cs b/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/TexelSizeNode.cs
new file mode 100644
index 00000000..2659320f
--- /dev/null
+++ b/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/TexelSizeNode.cs
@@ -0,0 +1,304 @@
+using UnityEngine;
+using UnityEditor;
+using System.Collections.Generic;
+
+using System;
+namespace AmplifyShaderEditor
+{
+ [Serializable]
+ [NodeAttributes( "Texel Size", "Textures", "Texel Size for a given texture object" )]
+ public sealed class TexelSizeNode : ParentNode
+ {
+ private readonly string[] Dummy = { string.Empty };
+ [SerializeField]
+ private int m_referenceSamplerId = -1;
+
+ [SerializeField]
+ private int m_referenceNodeId = -1;
+
+ [SerializeField]
+ private TexturePropertyNode m_inputReferenceNode = null;
+
+ private TexturePropertyNode m_referenceNode = null;
+
+ private UpperLeftWidgetHelper m_upperLeftWidget = new UpperLeftWidgetHelper();
+
+ private int m_cachedSamplerId = -1;
+ private int m_cachedSamplerIdArray = -1;
+ private int m_cachedSamplerIdCube = -1;
+ private int m_cachedSamplerId3D = -1;
+
+ protected override void CommonInit( int uniqueId )
+ {
+ base.CommonInit( uniqueId );
+ AddInputPort( WirePortDataType.SAMPLER2D, false, "Tex" );
+ m_inputPorts[ 0 ].CreatePortRestrictions( WirePortDataType.SAMPLER1D, WirePortDataType.SAMPLER2D, WirePortDataType.SAMPLER3D, WirePortDataType.SAMPLERCUBE, WirePortDataType.OBJECT );
+ AddOutputVectorPorts( WirePortDataType.FLOAT4, Constants.EmptyPortValue );
+ ChangeOutputName( 1, "1/Width" );
+ ChangeOutputName( 2, "1/Height" );
+ ChangeOutputName( 3, "Width" );
+ ChangeOutputName( 4, "Height" );
+ m_textLabelWidth = 80;
+ m_autoWrapProperties = true;
+ m_hasLeftDropdown = true;
+ m_previewShaderGUID = "6b20226576a059443b58aa2d0b942276";
+ }
+
+ public override void AfterCommonInit()
+ {
+ base.AfterCommonInit();
+
+ if( PaddingTitleLeft == 0 )
+ {
+ PaddingTitleLeft = Constants.PropertyPickerWidth + Constants.IconsLeftRightMargin;
+ if( PaddingTitleRight == 0 )
+ PaddingTitleRight = Constants.PropertyPickerWidth + Constants.IconsLeftRightMargin;
+ }
+ }
+
+ public override void OnInputPortConnected( int portId, int otherNodeId, int otherPortId, bool activateNode = true )
+ {
+ base.OnInputPortConnected( portId, otherNodeId, otherPortId, activateNode );
+ m_inputReferenceNode = m_inputPorts[ 0 ].GetOutputNodeWhichIsNotRelay() as TexturePropertyNode;
+ UpdateTitle();
+ }
+
+ public override void OnInputPortDisconnected( int portId )
+ {
+ base.OnInputPortDisconnected( portId );
+ m_inputReferenceNode = null;
+ UpdateTitle();
+ }
+
+
+ void UpdateTitle()
+ {
+ if ( m_inputReferenceNode != null )
+ {
+ m_additionalContent.text = string.Format( Constants.PropertyValueLabel, m_inputReferenceNode.PropertyInspectorName );
+ }
+ else if ( m_referenceSamplerId > -1 && m_referenceNode != null )
+ {
+ m_additionalContent.text = string.Format( Constants.PropertyValueLabel, m_referenceNode.PropertyInspectorName );
+ }
+ else
+ {
+ m_additionalContent.text = string.Empty;
+ }
+ m_sizeIsDirty = true;
+ }
+
+ public override void DrawProperties()
+ {
+ base.DrawProperties();
+ bool guiEnabledBuffer = GUI.enabled;
+ EditorGUI.BeginChangeCheck();
+ List<string> arr = new List<string>( UIUtils.TexturePropertyNodeArr() );
+
+ if( arr != null && arr.Count > 0 )
+ {
+ arr.Insert( 0, "None" );
+ GUI.enabled = true && ( !m_inputPorts[ 0 ].IsConnected );
+ m_referenceSamplerId = EditorGUILayoutPopup( Constants.AvailableReferenceStr, m_referenceSamplerId + 1, arr.ToArray() ) - 1;
+ }
+ else
+ {
+ m_referenceSamplerId = -1;
+ GUI.enabled = false;
+ EditorGUILayoutPopup( Constants.AvailableReferenceStr, m_referenceSamplerId, Dummy );
+ }
+
+ GUI.enabled = guiEnabledBuffer;
+ if( EditorGUI.EndChangeCheck() )
+ {
+ m_referenceNode = UIUtils.GetTexturePropertyNode( m_referenceSamplerId );
+ if( m_referenceNode != null )
+ {
+ m_referenceNodeId = m_referenceNode.UniqueId;
+ }
+ else
+ {
+ m_referenceNodeId = -1;
+ m_referenceSamplerId = -1;
+ }
+ UpdateTitle();
+ }
+ }
+
+ public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar )
+ {
+ base.GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalvar );
+ string texelName = string.Empty;
+
+ if ( m_inputPorts[ 0 ].IsConnected )
+ {
+ texelName = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ) + "_TexelSize";
+ }
+ else if ( m_referenceNode != null )
+ {
+ m_referenceNode.BaseGenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalvar );
+ texelName = m_referenceNode.PropertyName + "_TexelSize";
+ }
+ else
+ {
+ texelName = "_TexelSize";
+ UIUtils.ShowMessage( UniqueId, "Please specify a texture sample on the Texel Size node", MessageSeverity.Warning );
+ }
+
+ dataCollector.AddToUniforms( UniqueId, "float4 " + texelName + ";", dataCollector.IsSRP );
+
+ switch ( outputId )
+ {
+ case 0: return texelName;
+ case 1: return ( texelName + ".x" );
+ case 2: return ( texelName + ".y" );
+ case 3: return ( texelName + ".z" );
+ case 4: return ( texelName + ".w" );
+ }
+
+ return string.Empty;
+ }
+
+ void SetPreviewTexture( Texture newValue )
+ {
+ if( newValue is Cubemap )
+ {
+ m_previewMaterialPassId = 3;
+ if( m_cachedSamplerIdCube == -1 )
+ m_cachedSamplerIdCube = Shader.PropertyToID( "_Cube" );
+
+ PreviewMaterial.SetTexture( m_cachedSamplerIdCube, newValue as Cubemap );
+ }
+ else if( newValue is Texture2DArray )
+ {
+
+ m_previewMaterialPassId = 2;
+ if( m_cachedSamplerIdArray == -1 )
+ m_cachedSamplerIdArray = Shader.PropertyToID( "_Array" );
+
+ PreviewMaterial.SetTexture( m_cachedSamplerIdArray, newValue as Texture2DArray );
+ }
+ else if( newValue is Texture3D )
+ {
+ m_previewMaterialPassId = 1;
+ if( m_cachedSamplerId3D == -1 )
+ m_cachedSamplerId3D = Shader.PropertyToID( "_Sampler3D" );
+
+ PreviewMaterial.SetTexture( m_cachedSamplerId3D, newValue as Texture3D );
+ }
+ else
+ {
+ m_previewMaterialPassId = 0;
+ if( m_cachedSamplerId == -1 )
+ m_cachedSamplerId = Shader.PropertyToID( "_Sampler" );
+
+ PreviewMaterial.SetTexture( m_cachedSamplerId, newValue );
+ }
+ }
+
+ public override void SetPreviewInputs()
+ {
+ base.SetPreviewInputs();
+ if( m_inputPorts[0].IsConnected )
+ {
+ SetPreviewTexture( m_inputPorts[ 0 ].InputPreviewTexture( ContainerGraph ) );
+ }
+ else if( m_referenceNode != null )
+ {
+ if( m_referenceNode.Value != null )
+ {
+ SetPreviewTexture( m_referenceNode.Value );
+ }
+ else
+ {
+ SetPreviewTexture( m_referenceNode.PreviewTexture );
+ }
+ }
+ }
+
+ public override void Draw( DrawInfo drawInfo )
+ {
+ base.Draw( drawInfo );
+
+ EditorGUI.BeginChangeCheck();
+ {
+ List<string> arr = new List<string>( UIUtils.TexturePropertyNodeArr() );
+ bool guiEnabledBuffer = GUI.enabled;
+
+ if( arr != null && arr.Count > 0 )
+ {
+ arr.Insert( 0, "None" );
+ GUI.enabled = true && ( !m_inputPorts[ 0 ].IsConnected );
+ m_referenceSamplerId = m_upperLeftWidget.DrawWidget( this, m_referenceSamplerId + 1, arr.ToArray() ) - 1;
+ }
+ else
+ {
+ m_referenceSamplerId = -1;
+ GUI.enabled = false;
+ m_upperLeftWidget.DrawWidget( this, m_referenceSamplerId, Dummy );
+ }
+ GUI.enabled = guiEnabledBuffer;
+ }
+ if( EditorGUI.EndChangeCheck() )
+ {
+ m_referenceNode = UIUtils.GetTexturePropertyNode( m_referenceSamplerId );
+ if( m_referenceNode != null )
+ {
+ m_referenceNodeId = m_referenceNode.UniqueId;
+ }
+ else
+ {
+ m_referenceNodeId = -1;
+ m_referenceSamplerId = -1;
+ }
+ UpdateTitle();
+ }
+ }
+
+ public override void RefreshExternalReferences()
+ {
+ base.RefreshExternalReferences();
+ if ( UIUtils.CurrentShaderVersion() > 2404 )
+ {
+ m_referenceNode = UIUtils.GetNode( m_referenceNodeId ) as TexturePropertyNode;
+ m_referenceSamplerId = UIUtils.GetTexturePropertyNodeRegisterId( m_referenceNodeId );
+ }
+ else
+ {
+ m_referenceNode = UIUtils.GetTexturePropertyNode( m_referenceSamplerId );
+ if ( m_referenceNode != null )
+ {
+ m_referenceNodeId = m_referenceNode.UniqueId;
+ }
+ }
+ UpdateTitle();
+ }
+
+ public override void ReadFromString( ref string[] nodeParams )
+ {
+ base.ReadFromString( ref nodeParams );
+ if ( UIUtils.CurrentShaderVersion() > 2404 )
+ {
+ m_referenceNodeId = Convert.ToInt32( GetCurrentParam( ref nodeParams ) );
+ }
+ else
+ {
+ m_referenceSamplerId = Convert.ToInt32( GetCurrentParam( ref nodeParams ) );
+ }
+ }
+
+ public override void WriteToString( ref string nodeInfo, ref string connectionsInfo )
+ {
+ base.WriteToString( ref nodeInfo, ref connectionsInfo );
+ IOUtils.AddFieldValueToString( ref nodeInfo, m_referenceNodeId );
+ }
+
+ public override void Destroy()
+ {
+ base.Destroy();
+ m_referenceNode = null;
+ m_inputReferenceNode = null;
+ m_upperLeftWidget = null;
+ }
+ }
+}
diff --git a/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/TexelSizeNode.cs.meta b/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/TexelSizeNode.cs.meta
new file mode 100644
index 00000000..1e6fa013
--- /dev/null
+++ b/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/TexelSizeNode.cs.meta
@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: 1a23decd88779d24f9af6ae30c3d5a5f
+timeCreated: 1481126953
+licenseType: Store
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/UVCoordsParentNode.cs b/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/UVCoordsParentNode.cs
new file mode 100644
index 00000000..b259d89f
--- /dev/null
+++ b/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/UVCoordsParentNode.cs
@@ -0,0 +1,112 @@
+//// Amplify Shader Editor - Visual Shader Editing Tool
+//// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
+
+//using UnityEngine;
+//using UnityEditor;
+//using System;
+
+//namespace AmplifyShaderEditor
+//{
+// [Serializable]
+// [NodeAttributes( "[Old]Texture Coordinates", "Surface Data", "Texture UV coordinates set", null, KeyCode.U, false )]
+// public sealed class UVCoordsParentNode : ParentNode
+// {
+// private const string TilingStr = "Tiling";
+
+// [SerializeField]
+// private int m_textureCoordChannel = 0;
+
+// [SerializeField]
+// private int m_textureCoordSet = 0;
+
+// [SerializeField]
+// private Vector2 m_tiling = new Vector2( 1, 1 );
+
+// protected override void CommonInit( int uniqueId )
+// {
+// base.CommonInit( uniqueId );
+// AddOutputVectorPorts( WirePortDataType.FLOAT2, Constants.EmptyPortValue );
+// m_textLabelWidth = 75;
+// }
+
+// public override void DrawProperties()
+// {
+// base.DrawProperties();
+// int newChannel = EditorGUILayoutIntPopup( Constants.AvailableUVChannelLabel, m_textureCoordChannel, Constants.AvailableUVChannelsStr, Constants.AvailableUVChannels );
+// if ( newChannel != m_textureCoordChannel )
+// {
+// if ( UIUtils.IsChannelAvailable( newChannel ) )
+// {
+// UIUtils.ShowMessage( "Attempting to use an unoccupied used texture channel" );
+// }
+// else
+// {
+// m_textureCoordChannel = newChannel;
+// }
+// }
+// else if ( m_textureCoordChannel > -1 && UIUtils.IsChannelAvailable( m_textureCoordChannel ) )
+// {
+// UIUtils.ShowMessage( "Texture Channel " + m_textureCoordChannel + " is unavailable for TextureCoordinate node" );
+// m_textureCoordChannel = -1;
+// }
+
+// m_textureCoordSet = EditorGUILayoutIntPopup( Constants.AvailableUVSetsLabel, m_textureCoordSet, Constants.AvailableUVSetsStr, Constants.AvailableUVSets );
+
+// m_tiling = EditorGUILayoutVector2Field( TilingStr, m_tiling );
+// }
+
+// public override void Draw( DrawInfo drawInfo )
+// {
+// base.Draw( drawInfo );
+// if ( m_isVisible )
+// {
+// m_propertyDrawPos.x = m_globalPosition.x + Constants.FLOAT_WIDTH_SPACING;
+// m_propertyDrawPos.y = m_outputPorts[ 1 ].Position.y;
+// m_propertyDrawPos.width = 2.7f * drawInfo.InvertedZoom * Constants.FLOAT_DRAW_WIDTH_FIELD_SIZE;
+// m_propertyDrawPos.height = drawInfo.InvertedZoom * Constants.FLOAT_DRAW_HEIGHT_FIELD_SIZE;
+
+// m_propertyDrawPos.y = m_outputPorts[ 1 ].Position.y;
+// UIUtils.DrawFloat( this, ref m_propertyDrawPos, ref m_tiling.x );
+
+// m_propertyDrawPos.y = m_outputPorts[ 2 ].Position.y;
+// UIUtils.DrawFloat( this, ref m_propertyDrawPos, ref m_tiling.y );
+// }
+// }
+
+// public override void ReadFromString( ref string[] nodeParams )
+// {
+// base.ReadFromString( ref nodeParams );
+// m_textureCoordChannel = Convert.ToInt32( GetCurrentParam( ref nodeParams ) );
+// m_tiling.x = Convert.ToSingle( GetCurrentParam( ref nodeParams ) );
+// m_tiling.y = Convert.ToSingle( GetCurrentParam( ref nodeParams ) );
+// }
+
+// public override void WriteToString( ref string nodeInfo, ref string connectionsInfo )
+// {
+// base.WriteToString( ref nodeInfo, ref connectionsInfo );
+// IOUtils.AddFieldValueToString( ref nodeInfo, m_textureCoordChannel );
+// IOUtils.AddFieldValueToString( ref nodeInfo, m_tiling.x );
+// IOUtils.AddFieldValueToString( ref nodeInfo, m_tiling.y );
+// }
+
+// public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalVar )
+// {
+// string uvChannelDeclaration = IOUtils.GetUVChannelDeclaration( UIUtils.GetChannelName( m_textureCoordChannel ), m_textureCoordChannel, m_textureCoordSet );
+// dataCollector.AddToInput( UniqueId, uvChannelDeclaration, true );
+
+// if ( dataCollector.GetChannelUsage( m_textureCoordChannel ) != TextureChannelUsage.Used )
+// dataCollector.SetChannelUsage( m_textureCoordChannel, TextureChannelUsage.Required );
+
+// string uvTileStr = string.Empty;
+// switch ( outputId )
+// {
+// case 0: { uvTileStr = "float2( " + m_tiling.x + " , " + m_tiling.y + " )"; } break;
+// case 1: { uvTileStr = m_tiling.x.ToString(); } break;
+// case 2: { uvTileStr = m_tiling.y.ToString(); } break;
+// }
+// string uvChannelName = IOUtils.GetUVChannelName( UIUtils.GetChannelName( m_textureCoordChannel ), m_textureCoordSet );
+// return ( uvTileStr + "*" + GetOutputVectorItem( 0, outputId, Constants.InputVarStr + "." + uvChannelName ) );
+// }
+
+// }
+//}
diff --git a/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/UVCoordsParentNode.cs.meta b/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/UVCoordsParentNode.cs.meta
new file mode 100644
index 00000000..eae8ca56
--- /dev/null
+++ b/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/UVCoordsParentNode.cs.meta
@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: 73fb18e7d547d514695cb0b83a29f80e
+timeCreated: 1481126956
+licenseType: Store
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/ViewDirInputsCoordNode.cs b/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/ViewDirInputsCoordNode.cs
new file mode 100644
index 00000000..e60a359f
--- /dev/null
+++ b/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/ViewDirInputsCoordNode.cs
@@ -0,0 +1,167 @@
+// Amplify Shader Editor - Visual Shader Editing Tool
+// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
+using System;
+using UnityEngine;
+using UnityEditor;
+
+namespace AmplifyShaderEditor
+{
+ public enum ViewSpace
+ {
+ Tangent,
+ World
+ }
+
+ [Serializable]
+ [NodeAttributes( "View Dir", "Camera And Screen", "View direction vector, you can select between <b>World</b> space or <b>Tangent</b> space" )]
+ public sealed class ViewDirInputsCoordNode : SurfaceShaderINParentNode
+ {
+ private const string SpaceStr = "Space";
+ private const string WorldDirVarStr = "worldViewDir";
+ private const string NormalizeOptionStr = "Safe Normalize";
+
+ [SerializeField]
+ private bool m_safeNormalize = false;
+
+ [SerializeField]
+ private ViewSpace m_viewDirSpace = ViewSpace.World;
+
+ private UpperLeftWidgetHelper m_upperLeftWidget = new UpperLeftWidgetHelper();
+
+ protected override void CommonInit( int uniqueId )
+ {
+ base.CommonInit( uniqueId );
+ m_currentInput = SurfaceInputs.VIEW_DIR;
+ InitialSetup();
+ m_textLabelWidth = 120;
+ m_autoWrapProperties = true;
+ m_drawPreviewAsSphere = true;
+ m_hasLeftDropdown = true;
+ UpdateTitle();
+ m_previewShaderGUID = "07b57d9823df4bd4d8fe6dcb29fca36a";
+ }
+
+ private void UpdateTitle()
+ {
+ m_additionalContent.text = string.Format( Constants.SubTitleSpaceFormatStr, m_viewDirSpace.ToString() );
+ m_sizeIsDirty = true;
+ }
+
+ public override void Draw( DrawInfo drawInfo )
+ {
+ base.Draw( drawInfo );
+ m_upperLeftWidget.DrawWidget<ViewSpace>( ref m_viewDirSpace, this, OnWidgetUpdate );
+ }
+
+ private readonly Action<ParentNode> OnWidgetUpdate = ( x ) =>
+ {
+ ( x as ViewDirInputsCoordNode ).UpdateTitle();
+ };
+
+ public override void DrawProperties()
+ {
+ //base.DrawProperties();
+ EditorGUI.BeginChangeCheck();
+ m_viewDirSpace = (ViewSpace)EditorGUILayoutEnumPopup( SpaceStr, m_viewDirSpace );
+ if( EditorGUI.EndChangeCheck() )
+ {
+ UpdateTitle();
+ }
+ m_safeNormalize = EditorGUILayoutToggle( NormalizeOptionStr, m_safeNormalize );
+ EditorGUILayout.HelpBox( "Having safe normalize ON makes sure your view vector is not zero even if you are using your shader with no cameras.", MessageType.None );
+ }
+
+ public override void SetPreviewInputs()
+ {
+ base.SetPreviewInputs();
+
+ if( m_viewDirSpace == ViewSpace.World )
+ m_previewMaterialPassId = 0;
+ else if( m_viewDirSpace == ViewSpace.Tangent )
+ m_previewMaterialPassId = 1;
+ }
+
+ public override void PropagateNodeData( NodeData nodeData, ref MasterNodeDataCollector dataCollector )
+ {
+ base.PropagateNodeData( nodeData, ref dataCollector );
+ if( m_viewDirSpace == ViewSpace.Tangent )
+ dataCollector.DirtyNormal = true;
+
+ if( m_safeNormalize )
+ dataCollector.SafeNormalizeViewDir = true;
+ }
+
+ public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalVar )
+ {
+ if( dataCollector.IsTemplate )
+ {
+ string varName = ( m_viewDirSpace == ViewSpace.World ) ? dataCollector.TemplateDataCollectorInstance.GetViewDir(true,MasterNodePortCategory.Fragment, m_safeNormalize?NormalizeType.Safe:NormalizeType.Regular) :
+ dataCollector.TemplateDataCollectorInstance.GetTangentViewDir( CurrentPrecisionType, true,MasterNodePortCategory.Fragment, m_safeNormalize ? NormalizeType.Safe : NormalizeType.Regular );
+ return GetOutputVectorItem( 0, outputId, varName );
+ }
+
+
+ if( dataCollector.PortCategory == MasterNodePortCategory.Vertex || dataCollector.PortCategory == MasterNodePortCategory.Tessellation )
+ {
+ string result = GeneratorUtils.GenerateViewDirection( ref dataCollector, UniqueId, m_viewDirSpace );
+ return GetOutputVectorItem( 0, outputId, result );
+ }
+ else
+ {
+ if( m_viewDirSpace == ViewSpace.World )
+ {
+ if( dataCollector.DirtyNormal || m_safeNormalize )
+ {
+ dataCollector.AddToInput( UniqueId, SurfaceInputs.WORLD_POS );
+ string result = GeneratorUtils.GenerateViewDirection( ref dataCollector, UniqueId );
+ return GetOutputVectorItem( 0, outputId, result );
+ }
+ else
+ {
+ dataCollector.AddToInput( UniqueId, SurfaceInputs.VIEW_DIR, PrecisionType.Float );
+ return GetOutputVectorItem( 0, outputId, m_currentInputValueStr );
+ //return base.GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalVar );
+ }
+ }
+ else
+ {
+ if( m_safeNormalize )
+ {
+ dataCollector.AddToInput( UniqueId, SurfaceInputs.WORLD_NORMAL, CurrentPrecisionType );
+ dataCollector.AddToInput( UniqueId, SurfaceInputs.INTERNALDATA, addSemiColon: false );
+ dataCollector.ForceNormal = true;
+ dataCollector.AddToInput( UniqueId, SurfaceInputs.WORLD_POS );
+ string result = GeneratorUtils.GenerateViewDirection( ref dataCollector, UniqueId, ViewSpace.Tangent );
+ return GetOutputVectorItem( 0, outputId, result );
+ }
+ else
+ {
+ dataCollector.ForceNormal = true;
+ return base.GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalVar );
+ }
+ }
+ }
+ }
+
+ public override void ReadFromString( ref string[] nodeParams )
+ {
+ base.ReadFromString( ref nodeParams );
+ if( UIUtils.CurrentShaderVersion() > 2402 )
+ m_viewDirSpace = (ViewSpace)Enum.Parse( typeof( ViewSpace ), GetCurrentParam( ref nodeParams ) );
+
+ if( UIUtils.CurrentShaderVersion() > 15201 )
+ {
+ m_safeNormalize = Convert.ToBoolean( GetCurrentParam( ref nodeParams ) );
+ }
+
+ UpdateTitle();
+ }
+
+ public override void WriteToString( ref string nodeInfo, ref string connectionsInfo )
+ {
+ base.WriteToString( ref nodeInfo, ref connectionsInfo );
+ IOUtils.AddFieldValueToString( ref nodeInfo, m_viewDirSpace );
+ IOUtils.AddFieldValueToString( ref nodeInfo, m_safeNormalize );
+ }
+ }
+}
diff --git a/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/ViewDirInputsCoordNode.cs.meta b/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/ViewDirInputsCoordNode.cs.meta
new file mode 100644
index 00000000..32985728
--- /dev/null
+++ b/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/ViewDirInputsCoordNode.cs.meta
@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: 4755b85e957e31d4b96d341070b156b5
+timeCreated: 1481126955
+licenseType: Store
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/WorldNormalInputsNode.cs b/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/WorldNormalInputsNode.cs
new file mode 100644
index 00000000..d179cddb
--- /dev/null
+++ b/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/WorldNormalInputsNode.cs
@@ -0,0 +1,119 @@
+// Amplify Shader Editor - Visual Shader Editing Tool
+// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
+
+using UnityEngine;
+using UnityEditor;
+using System;
+
+namespace AmplifyShaderEditor
+{
+ [Serializable]
+ [NodeAttributes( "[Deprecated] World Normal", "Surface Data", "Vertex Normal World", null, KeyCode.None, true, true, "World Normal", typeof( WorldNormalVector ) )]
+ public sealed class WorldNormalInputsNode : SurfaceShaderINParentNode
+ {
+ private const string PerPixelLabelStr = "Per Pixel";
+
+ [SerializeField]
+ private bool m_perPixel = true;
+
+ [SerializeField]
+ private string m_precisionString;
+
+ [SerializeField]
+ private bool m_addInstruction = false;
+
+ public override void Reset()
+ {
+ base.Reset();
+ m_addInstruction = true;
+ }
+
+ protected override void CommonInit( int uniqueId )
+ {
+ base.CommonInit( uniqueId );
+ m_currentInput = SurfaceInputs.WORLD_NORMAL;
+ InitialSetup();
+ //UIUtils.AddNormalDependentCount();
+ }
+
+ //public override void Destroy()
+ //{
+ // ContainerGraph.RemoveNormalDependentCount();
+ // base.Destroy();
+ //}
+
+ public override void DrawProperties()
+ {
+ base.DrawProperties();
+ m_perPixel = EditorGUILayoutToggleLeft( PerPixelLabelStr, m_perPixel );
+ }
+
+ public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalVar )
+ {
+ if ( dataCollector.PortCategory == MasterNodePortCategory.Vertex || dataCollector.PortCategory == MasterNodePortCategory.Tessellation )
+ {
+ if ( m_addInstruction )
+ {
+ string precision = UIUtils.PrecisionWirePortToCgType( CurrentPrecisionType, WirePortDataType.FLOAT3 );
+ dataCollector.AddVertexInstruction( precision + " worldNormal = UnityObjectToWorldNormal(" + Constants.VertexShaderInputStr + ".normal)", UniqueId );
+ m_addInstruction = false;
+ }
+
+ return GetOutputVectorItem( 0, outputId, "worldNormal" );
+ }
+ else
+ {
+ dataCollector.AddToInput( UniqueId, SurfaceInputs.WORLD_NORMAL, CurrentPrecisionType );
+ dataCollector.AddToInput( UniqueId, SurfaceInputs.INTERNALDATA, addSemiColon: false );
+ if ( dataCollector.PortCategory != MasterNodePortCategory.Debug && m_perPixel && dataCollector.DirtyNormal )
+ {
+ //string result = "WorldNormalVector( " + Constants.InputVarStr + " , float3( 0,0,1 ))";
+ m_precisionString = UIUtils.PrecisionWirePortToCgType( CurrentPrecisionType, WirePortDataType.FLOAT3 );
+ string result = string.Format( Constants.WorldNormalLocalDecStr, m_precisionString );
+ int count = 0;
+ for ( int i = 0; i < m_outputPorts.Count; i++ )
+ {
+ if ( m_outputPorts[ i ].IsConnected )
+ {
+ if ( m_outputPorts[ i ].ConnectionCount > 2 )
+ {
+ count = 2;
+ break;
+ }
+ count += 1;
+ if ( count > 1 )
+ break;
+ }
+ }
+ if ( count > 1 )
+ {
+ string localVarName = "WorldNormal" + OutputId;
+ dataCollector.AddToLocalVariables( UniqueId, CurrentPrecisionType, m_outputPorts[ 0 ].DataType, localVarName, result );
+ return GetOutputVectorItem( 0, outputId, localVarName );
+ }
+ else
+ {
+ return GetOutputVectorItem( 0, outputId, result );
+ }
+ }
+ else
+ {
+ return base.GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalVar );
+ }
+ }
+ }
+
+ public override void ReadFromString( ref string[] nodeParams )
+ {
+ base.ReadFromString( ref nodeParams );
+ if ( UIUtils.CurrentShaderVersion() > 2504 )
+ m_perPixel = Convert.ToBoolean( GetCurrentParam( ref nodeParams ) );
+ }
+
+ public override void WriteToString( ref string nodeInfo, ref string connectionsInfo )
+ {
+ base.WriteToString( ref nodeInfo, ref connectionsInfo );
+ IOUtils.AddFieldValueToString( ref nodeInfo, m_perPixel );
+ }
+ }
+}
diff --git a/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/WorldNormalInputsNode.cs.meta b/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/WorldNormalInputsNode.cs.meta
new file mode 100644
index 00000000..da99f65c
--- /dev/null
+++ b/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/WorldNormalInputsNode.cs.meta
@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: 891e3ffa10c12c54e83a1e40df03df2f
+timeCreated: 1481126957
+licenseType: Store
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/WorldNormalVector.cs b/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/WorldNormalVector.cs
new file mode 100644
index 00000000..861ee6d2
--- /dev/null
+++ b/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/WorldNormalVector.cs
@@ -0,0 +1,178 @@
+// Amplify Shader Editor - Visual Shader Editing Tool
+// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
+
+using System;
+using UnityEngine;
+
+namespace AmplifyShaderEditor
+{
+ [Serializable]
+ [NodeAttributes( "World Normal", "Surface Data", "Per pixel world normal vector, accepts a <b>Normal</b> vector in tangent space (ie: normalmap)" )]
+ public sealed class WorldNormalVector : ParentNode
+ {
+ private const string NormalVecValStr = "newWorldNormal";
+ private const string NormalVecDecStr = "float3 {0} = {1};";
+
+ private const string NormalizeOptionStr = "Normalize";
+ private const string NormalizeFunc = "normalize( {0} )";
+
+ [SerializeField]
+ private bool m_normalize = false;
+
+ protected override void CommonInit( int uniqueId )
+ {
+ base.CommonInit( uniqueId );
+ AddInputPort( WirePortDataType.FLOAT3, false, "Normal" );
+ AddOutputVectorPorts( WirePortDataType.FLOAT3, "XYZ" );
+ m_inputPorts[ 0 ].Vector3InternalData = Vector3.forward;
+ m_previewShaderGUID = "5f55f4841abb61e45967957788593a9d";
+ m_drawPreviewAsSphere = true;
+ m_autoWrapProperties = true;
+ m_textLabelWidth = 80;
+ }
+
+ public override void SetPreviewInputs()
+ {
+ base.SetPreviewInputs();
+
+ if( m_inputPorts[ 0 ].IsConnected )
+ m_previewMaterialPassId = 1;
+ else
+ m_previewMaterialPassId = 0;
+ }
+
+ public override void PropagateNodeData( NodeData nodeData, ref MasterNodeDataCollector dataCollector )
+ {
+ base.PropagateNodeData( nodeData, ref dataCollector );
+ if( m_inputPorts[ 0 ].IsConnected )
+ dataCollector.DirtyNormal = true;
+ }
+
+ public override void DrawProperties()
+ {
+ base.DrawProperties();
+ m_normalize = EditorGUILayoutToggle( NormalizeOptionStr, m_normalize );
+ }
+
+ public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar )
+ {
+ if( dataCollector.IsTemplate )
+ {
+ if( m_inputPorts[ 0 ].IsConnected )
+ {
+ if( m_outputPorts[ 0 ].IsLocalValue( dataCollector.PortCategory ) )
+ return GetOutputVectorItem( 0, outputId, m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ) );
+
+
+ string value = dataCollector.TemplateDataCollectorInstance.GetWorldNormal( UniqueId, CurrentPrecisionType, m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ), OutputId );
+ if( m_normalize )
+ {
+ value = string.Format( NormalizeFunc, value );
+ }
+ RegisterLocalVariable( 0, value, ref dataCollector, "worldNormal" + OutputId );
+ return GetOutputVectorItem( 0, outputId, m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ) );
+ }
+ else
+ {
+ string value = dataCollector.TemplateDataCollectorInstance.GetWorldNormal( CurrentPrecisionType );
+ string name;
+ if( m_normalize )
+ {
+ name = "normalizedWorldNormal";
+ value = string.Format( NormalizeFunc, value );
+ RegisterLocalVariable( 0, value, ref dataCollector, name );
+ }
+ else
+ {
+ name = value;
+ }
+ return GetOutputVectorItem( 0, outputId, name );
+ }
+ }
+
+ if( dataCollector.PortCategory == MasterNodePortCategory.Fragment || dataCollector.PortCategory == MasterNodePortCategory.Debug )
+ {
+ dataCollector.AddToInput( UniqueId, SurfaceInputs.WORLD_NORMAL, CurrentPrecisionType );
+
+ string result = string.Empty;
+ if( m_inputPorts[ 0 ].IsConnected )
+ {
+ dataCollector.AddToInput( UniqueId, SurfaceInputs.INTERNALDATA, addSemiColon: false );
+ dataCollector.ForceNormal = true;
+
+ result = "(WorldNormalVector( " + Constants.InputVarStr + " , " + m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ) + " ))";
+ if( m_normalize )
+ {
+ result = string.Format( NormalizeFunc, result );
+ }
+
+ int connCount = 0;
+ for( int i = 0; i < m_outputPorts.Count; i++ )
+ {
+ connCount += m_outputPorts[ i ].ConnectionCount;
+ }
+
+ if( connCount > 1 )
+ {
+ dataCollector.AddToLocalVariables( UniqueId, string.Format( NormalVecDecStr, NormalVecValStr + OutputId, result ) );
+ return GetOutputVectorItem( 0, outputId, NormalVecValStr + OutputId );
+ }
+ }
+ else
+ {
+ if( !dataCollector.DirtyNormal )
+ {
+ result = GeneratorUtils.GenerateWorldNormal( ref dataCollector, UniqueId, m_normalize );
+ }
+ else
+ {
+ dataCollector.AddToInput( UniqueId, SurfaceInputs.INTERNALDATA, addSemiColon: false );
+ result = GeneratorUtils.GenerateWorldNormal( ref dataCollector, UniqueId, m_normalize );
+ dataCollector.ForceNormal = true;
+ }
+ }
+
+ return GetOutputVectorItem( 0, outputId, result );
+ }
+ else
+ {
+ if( m_inputPorts[ 0 ].IsConnected )
+ {
+ string inputTangent = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector );
+
+ string normal = GeneratorUtils.GenerateWorldNormal( ref dataCollector, UniqueId );
+ string tangent = GeneratorUtils.GenerateWorldTangent( ref dataCollector, UniqueId );
+ dataCollector.AddToVertexLocalVariables( UniqueId, "float3x3 tangentToWorld = CreateTangentToWorldPerVertex( " + normal + ", " + tangent + ", " + Constants.VertexShaderInputStr + ".tangent.w );" );
+ dataCollector.AddToVertexLocalVariables( UniqueId, "float3 tangentNormal" + OutputId + " = " + inputTangent + ";" );
+ string result = "(tangentToWorld[0] * tangentNormal" + OutputId + ".x + tangentToWorld[1] * tangentNormal" + OutputId + ".y + tangentToWorld[2] * tangentNormal" + OutputId + ".z)";
+ if( m_normalize )
+ {
+ result = string.Format( NormalizeFunc, result );
+ }
+ dataCollector.AddToVertexLocalVariables( UniqueId, "float3 modWorldNormal" + OutputId + " = " + result + ";" );
+ return GetOutputVectorItem( 0, outputId, "modWorldNormal" + OutputId );
+ }
+ else
+ {
+ string result = GeneratorUtils.GenerateWorldNormal( ref dataCollector, UniqueId, m_normalize );
+ return GetOutputVectorItem( 0, outputId, result );
+ }
+ }
+ }
+
+ public override void ReadFromString( ref string[] nodeParams )
+ {
+ base.ReadFromString( ref nodeParams );
+ if( UIUtils.CurrentShaderVersion() > 14202 )
+ {
+ m_normalize = Convert.ToBoolean( GetCurrentParam( ref nodeParams ) );
+ }
+ }
+
+ public override void WriteToString( ref string nodeInfo, ref string connectionsInfo )
+ {
+ base.WriteToString( ref nodeInfo, ref connectionsInfo );
+ IOUtils.AddFieldValueToString( ref nodeInfo, m_normalize );
+ }
+ }
+}
diff --git a/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/WorldNormalVector.cs.meta b/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/WorldNormalVector.cs.meta
new file mode 100644
index 00000000..7646e491
--- /dev/null
+++ b/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/WorldNormalVector.cs.meta
@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: d61a084db19701c4fb3030ee953ac509
+timeCreated: 1481126959
+licenseType: Store
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/WorldPosInputsNode.cs b/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/WorldPosInputsNode.cs
new file mode 100644
index 00000000..15c0b29f
--- /dev/null
+++ b/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/WorldPosInputsNode.cs
@@ -0,0 +1,37 @@
+// Amplify Shader Editor - Visual Shader Editing Tool
+// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
+
+using System;
+using UnityEngine;
+
+namespace AmplifyShaderEditor
+{
+ [Serializable]
+ [NodeAttributes( "World Position", "Surface Data", "World space position" )]
+ public sealed class WorldPosInputsNode : SurfaceShaderINParentNode
+ {
+ protected override void CommonInit( int uniqueId )
+ {
+ base.CommonInit( uniqueId );
+ m_currentInput = SurfaceInputs.WORLD_POS;
+ m_drawPreviewAsSphere = true;
+ m_previewShaderGUID = "70d5405009b31a349a4d8285f30cf5d9";
+ InitialSetup();
+ }
+
+ public override void DrawProperties() { }
+
+ public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalVar )
+ {
+ if ( dataCollector.IsTemplate )
+ {
+ string varName = dataCollector.TemplateDataCollectorInstance.GetWorldPos();
+ return GetOutputVectorItem( 0, outputId, varName );
+ }
+
+ string worldPosition = GeneratorUtils.GenerateWorldPosition( ref dataCollector, UniqueId );
+
+ return GetOutputVectorItem( 0, outputId, worldPosition );
+ }
+ }
+}
diff --git a/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/WorldPosInputsNode.cs.meta b/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/WorldPosInputsNode.cs.meta
new file mode 100644
index 00000000..91f10c87
--- /dev/null
+++ b/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/WorldPosInputsNode.cs.meta
@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: 850bb0065928b7f499b869b8adc1ce5c
+timeCreated: 1481126957
+licenseType: Store
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/WorldReflInputsNode.cs b/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/WorldReflInputsNode.cs
new file mode 100644
index 00000000..99b49780
--- /dev/null
+++ b/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/WorldReflInputsNode.cs
@@ -0,0 +1,18 @@
+// Amplify Shader Editor - Visual Shader Editing Tool
+// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
+using UnityEngine;
+
+namespace AmplifyShaderEditor
+{
+ [System.Serializable]
+ [NodeAttributes( "[Deprecated] World Reflection", "Surface Data", "World reflection vector", null, KeyCode.None, true, true, "World Reflection", typeof( WorldReflectionVector ) )]
+ public sealed class WorldReflInputsNode : SurfaceShaderINParentNode
+ {
+ protected override void CommonInit( int uniqueId )
+ {
+ base.CommonInit( uniqueId );
+ m_currentInput = SurfaceInputs.WORLD_REFL;
+ InitialSetup();
+ }
+ }
+}
diff --git a/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/WorldReflInputsNode.cs.meta b/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/WorldReflInputsNode.cs.meta
new file mode 100644
index 00000000..8e4e079d
--- /dev/null
+++ b/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/WorldReflInputsNode.cs.meta
@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: e4f39f3a52f10644392decce9d1e6790
+timeCreated: 1481126959
+licenseType: Store
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/WorldReflectionVector.cs b/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/WorldReflectionVector.cs
new file mode 100644
index 00000000..30953218
--- /dev/null
+++ b/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/WorldReflectionVector.cs
@@ -0,0 +1,213 @@
+// Amplify Shader Editor - Visual Shader Editing Tool
+// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
+
+using System;
+using UnityEngine;
+namespace AmplifyShaderEditor
+{
+ [Serializable]
+ [NodeAttributes( "World Reflection", "Surface Data", "Per pixel world reflection vector, accepts a <b>Normal</b> vector in tangent space (ie: normalmap)" )]
+ public sealed class WorldReflectionVector : ParentNode
+ {
+ private const string ReflectionVecValStr = "newWorldReflection";
+ private const string ReflectionVecDecStr = "float3 {0} = {1};";
+
+ private const string NormalizeOptionStr = "Normalize";
+ private const string NormalizeFunc = "normalize( {0} )";
+
+ [SerializeField]
+ private bool m_normalize = false;
+
+ protected override void CommonInit( int uniqueId )
+ {
+ base.CommonInit( uniqueId );
+ AddInputPort( WirePortDataType.FLOAT3, false, "Normal" );
+ AddOutputVectorPorts( WirePortDataType.FLOAT3, "XYZ" );
+ m_drawPreviewAsSphere = true;
+ m_previewShaderGUID = "8e267e9aa545eeb418585a730f50273e";
+ m_autoWrapProperties = true;
+ m_textLabelWidth = 80;
+ //UIUtils.AddNormalDependentCount();
+ }
+
+ public override void SetPreviewInputs()
+ {
+ base.SetPreviewInputs();
+
+ if( m_inputPorts[ 0 ].IsConnected )
+ m_previewMaterialPassId = 1;
+ else
+ m_previewMaterialPassId = 0;
+ }
+
+ public override void DrawProperties()
+ {
+ base.DrawProperties();
+ m_normalize = EditorGUILayoutToggle( NormalizeOptionStr, m_normalize );
+ }
+
+ //public override void Destroy()
+ //{
+ // ContainerGraph.RemoveNormalDependentCount();
+ // base.Destroy();
+ //}
+
+ public override void PropagateNodeData( NodeData nodeData, ref MasterNodeDataCollector dataCollector )
+ {
+ base.PropagateNodeData( nodeData, ref dataCollector );
+ if( m_inputPorts[ 0 ].IsConnected )
+ dataCollector.DirtyNormal = true;
+ }
+
+ public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalVar )
+ {
+ if( dataCollector.IsTemplate )
+ {
+ if( m_inputPorts[ 0 ].IsConnected )
+ {
+ if( m_outputPorts[ 0 ].IsLocalValue( dataCollector.PortCategory ) )
+ return GetOutputVectorItem( 0, outputId, m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ) );
+
+
+ string value = dataCollector.TemplateDataCollectorInstance.GetWorldReflection( CurrentPrecisionType, m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ) );
+ if( m_normalize )
+ {
+ value = string.Format( NormalizeFunc, value );
+ }
+ RegisterLocalVariable( 0, value, ref dataCollector, "worldRefl" + OutputId );
+ return GetOutputVectorItem( 0, outputId, m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ) );
+ }
+ else
+ {
+ string name;
+ string value = dataCollector.TemplateDataCollectorInstance.GetWorldReflection( CurrentPrecisionType );
+ if( m_normalize )
+ {
+ name = "normalizedWorldRefl";
+ value = string.Format( NormalizeFunc, value );
+ RegisterLocalVariable( 0, value, ref dataCollector, name );
+ }
+ else
+ {
+ name = value;
+ }
+ return GetOutputVectorItem( 0, outputId, name );
+ }
+ }
+
+ bool isVertex = ( dataCollector.PortCategory == MasterNodePortCategory.Tessellation || dataCollector.PortCategory == MasterNodePortCategory.Vertex );
+ if( isVertex )
+ {
+ if( m_inputPorts[ 0 ].IsConnected )
+ {
+ if( m_outputPorts[ 0 ].IsLocalValue( dataCollector.PortCategory ) )
+ return GetOutputVectorItem( 0, outputId, m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ) );
+
+ string normal = GeneratorUtils.GenerateWorldNormal( ref dataCollector, UniqueId );
+ string tangent = GeneratorUtils.GenerateWorldTangent( ref dataCollector, UniqueId );
+ dataCollector.AddToVertexLocalVariables( UniqueId, "float3x3 tangentToWorld = CreateTangentToWorldPerVertex( " + normal + ", "+ tangent + ", "+ Constants.VertexShaderInputStr + ".tangent.w );" );
+ string inputTangent = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector );
+ dataCollector.AddToVertexLocalVariables( UniqueId, "float3 tangentNormal" + OutputId + " = " + inputTangent + ";" );
+
+ string viewDir = GeneratorUtils.GenerateViewDirection( ref dataCollector, UniqueId );
+ dataCollector.AddToVertexLocalVariables( UniqueId, "float3 modWorldNormal" + OutputId + " = ( tangentToWorld[0] * tangentNormal" + OutputId + ".x + tangentToWorld[1] * tangentNormal" + OutputId + ".y + tangentToWorld[2] * tangentNormal" + OutputId + ".z);" );
+
+ string value = "reflect( -" + viewDir + ", modWorldNormal" + OutputId + " )";
+ if( m_normalize )
+ {
+ value = string.Format( NormalizeFunc, value );
+ }
+
+ RegisterLocalVariable( 0, value, ref dataCollector, "modReflection" + OutputId );
+ return GetOutputVectorItem( 0, outputId, m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ) );
+ }
+ else
+ {
+ if( m_outputPorts[ 0 ].IsLocalValue( dataCollector.PortCategory ) )
+ return GetOutputVectorItem( 0, outputId, m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ) );
+
+ string worldNormal = GeneratorUtils.GenerateWorldNormal( ref dataCollector, UniqueId );
+ string viewDir = GeneratorUtils.GenerateViewDirection( ref dataCollector, UniqueId );
+
+ string value = "reflect( -" + viewDir + ", " + worldNormal + " )";
+ if( m_normalize )
+ {
+ value = string.Format( NormalizeFunc, value );
+ }
+ RegisterLocalVariable( 0, value, ref dataCollector, ReflectionVecValStr + OutputId );
+ return GetOutputVectorItem( 0, outputId, m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ) );
+ }
+ }
+ else
+ {
+ if( m_outputPorts[ 0 ].IsLocalValue( dataCollector.PortCategory ) )
+ return GetOutputVectorItem( 0, outputId, m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ) );
+
+ dataCollector.AddToInput( UniqueId, SurfaceInputs.WORLD_REFL, CurrentPrecisionType );
+
+ string result = string.Empty;
+ if( m_inputPorts[ 0 ].IsConnected )
+ {
+ dataCollector.AddToInput( UniqueId, SurfaceInputs.INTERNALDATA, addSemiColon: false );
+ dataCollector.ForceNormal = true;
+
+ result = "WorldReflectionVector( " + Constants.InputVarStr + " , " + m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ) + " )";
+ if( m_normalize )
+ {
+ result = String.Format( NormalizeFunc, result );
+ }
+ int connCount = 0;
+ for( int i = 0; i < m_outputPorts.Count; i++ )
+ {
+ connCount += m_outputPorts[ i ].ConnectionCount;
+ }
+
+ if( connCount > 1 )
+ {
+ dataCollector.AddToLocalVariables( UniqueId, string.Format( ReflectionVecDecStr, ReflectionVecValStr + OutputId, result ) );
+ RegisterLocalVariable( 0, result, ref dataCollector, ReflectionVecValStr + OutputId );
+ return GetOutputVectorItem( 0, outputId, m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ) );
+ }
+ }
+ else
+ {
+ dataCollector.AddToInput( UniqueId, SurfaceInputs.INTERNALDATA, addSemiColon: false );
+ result = GeneratorUtils.GenerateWorldReflection( ref dataCollector, UniqueId , m_normalize );
+ if( dataCollector.DirtyNormal )
+ dataCollector.ForceNormal = true;
+ }
+
+ return GetOutputVectorItem( 0, outputId, result );
+ //RegisterLocalVariable( 0, result, ref dataCollector, "worldrefVec" + OutputId );
+ //return GetOutputVectorItem( 0, outputId, m_outputPorts[ 0 ].LocalValue );
+ }
+ }
+
+ public override void ReadFromString( ref string[] nodeParams )
+ {
+ base.ReadFromString( ref nodeParams );
+ if( UIUtils.CurrentShaderVersion() > 14202 )
+ {
+ m_normalize = Convert.ToBoolean( GetCurrentParam( ref nodeParams ) );
+ }
+ }
+
+ public override void WriteToString( ref string nodeInfo, ref string connectionsInfo )
+ {
+ base.WriteToString( ref nodeInfo, ref connectionsInfo );
+ IOUtils.AddFieldValueToString( ref nodeInfo, m_normalize );
+ }
+
+ public override void RefreshExternalReferences()
+ {
+ base.RefreshExternalReferences();
+ if( UIUtils.CurrentShaderVersion() <= 14202 )
+ {
+ if( !m_inputPorts[ 0 ].IsConnected )
+ {
+ m_normalize = true;
+ }
+ }
+ }
+ }
+}
diff --git a/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/WorldReflectionVector.cs.meta b/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/WorldReflectionVector.cs.meta
new file mode 100644
index 00000000..eb2bf472
--- /dev/null
+++ b/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/WorldReflectionVector.cs.meta
@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: bd82e1d90bd90fc4d924e97e5fdcc7de
+timeCreated: 1481126959
+licenseType: Store
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant: