summaryrefslogtreecommitdiff
path: root/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/HelperParentNode.cs
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/HelperFuncs/HelperParentNode.cs
parent917e9e0b320775634dc2e710f7deac74fd0822f0 (diff)
*移动amplify shader editor到third party目录
Diffstat (limited to 'Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/HelperParentNode.cs')
-rw-r--r--Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/HelperParentNode.cs93
1 files changed, 93 insertions, 0 deletions
diff --git a/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/HelperParentNode.cs b/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/HelperParentNode.cs
new file mode 100644
index 00000000..79c18bb1
--- /dev/null
+++ b/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/HelperParentNode.cs
@@ -0,0 +1,93 @@
+// Amplify Shader Editor - Visual Shader Editing Tool
+// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
+
+//https://docs.unity3d.com/Manual/SL-BuiltinFunctions.html
+
+using System;
+using UnityEngine;
+namespace AmplifyShaderEditor
+{
+ [Serializable]
+ public class HelperParentNode : ParentNode
+ {
+ [SerializeField]
+ protected string m_funcType = string.Empty;
+
+ [SerializeField]
+ protected string m_funcLWFormatOverride = string.Empty;
+
+ [SerializeField]
+ protected string m_funcHDFormatOverride = string.Empty;
+
+ protected string m_localVarName = null;
+
+ protected override void CommonInit( int uniqueId )
+ {
+ base.CommonInit( uniqueId );
+ AddInputPort( WirePortDataType.FLOAT, false, Constants.EmptyPortValue );
+ AddOutputPort( WirePortDataType.FLOAT, Constants.EmptyPortValue );
+ m_useInternalPortData = true;
+ }
+
+ public override string GetIncludes()
+ {
+ return Constants.UnityCgLibFuncs;
+ }
+
+ 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 ) );
+
+ base.GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalvar );
+
+ if( !( dataCollector.IsTemplate && dataCollector.IsSRP ) )
+ dataCollector.AddToIncludes( UniqueId, Constants.UnityCgLibFuncs );
+
+ string concatResults = string.Empty;
+ bool first = true;
+ for( int i = 0; i < m_inputPorts.Count; i++ )
+ {
+ if( m_inputPorts[ i ].Visible )
+ {
+ if( !first )
+ {
+ concatResults += " , ";
+ }
+ else
+ {
+ first = false;
+ }
+
+ string result = string.Empty;
+ if( m_inputPorts[ i ].IsConnected )
+ {
+ result = m_inputPorts[ i ].GeneratePortInstructions( ref dataCollector );
+ }
+ else
+ {
+ result = m_inputPorts[ i ].WrappedInternalData;
+ }
+
+ concatResults += result;
+ }
+ }
+ string finalResult = m_funcType + "( " + concatResults + " )";
+ if( dataCollector.IsTemplate )
+ {
+ if( dataCollector.TemplateDataCollectorInstance.CurrentSRPType == TemplateSRPType.Lightweight && !string.IsNullOrEmpty( m_funcLWFormatOverride ) )
+ {
+ finalResult = string.Format( m_funcLWFormatOverride, concatResults );
+ }
+ else if( dataCollector.TemplateDataCollectorInstance.CurrentSRPType == TemplateSRPType.HD && !string.IsNullOrEmpty( m_funcHDFormatOverride ) )
+ {
+ finalResult = string.Format( m_funcHDFormatOverride, concatResults );
+ }
+
+ }
+
+ RegisterLocalVariable( 0, finalResult, ref dataCollector, m_localVarName );
+ return GetOutputVectorItem( 0, outputId, m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ) );
+ }
+ }
+}