summaryrefslogtreecommitdiff
path: root/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SimpleNodes/SimpleRemainderNode.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/SimpleNodes/SimpleRemainderNode.cs
parent917e9e0b320775634dc2e710f7deac74fd0822f0 (diff)
*移动amplify shader editor到third party目录
Diffstat (limited to 'Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SimpleNodes/SimpleRemainderNode.cs')
-rw-r--r--Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SimpleNodes/SimpleRemainderNode.cs62
1 files changed, 62 insertions, 0 deletions
diff --git a/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SimpleNodes/SimpleRemainderNode.cs b/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SimpleNodes/SimpleRemainderNode.cs
new file mode 100644
index 00000000..64da4fdf
--- /dev/null
+++ b/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/SimpleNodes/SimpleRemainderNode.cs
@@ -0,0 +1,62 @@
+// Amplify Shader Editor - Visual Shader Editing Tool
+// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
+
+using System;
+
+namespace AmplifyShaderEditor
+{
+ [Serializable]
+ [NodeAttributes( "Remainder", "Math Operators", "Remainder between two int variables",tags:"modulo fmod" )]
+ public sealed class SimpleRemainderNode : DynamicTypeNode
+ {
+ private const string VertexFragRemainder = "( {0} % {1} )";
+ private const string SurfaceRemainder = "fmod( {0} , {1} )";
+
+ protected override void CommonInit( int uniqueId )
+ {
+ base.CommonInit( uniqueId );
+ m_useInternalPortData = true;
+ m_textLabelWidth = 35;
+ ChangeInputType( WirePortDataType.INT, false );
+ ChangeOutputType( WirePortDataType.INT, false );
+ m_useInternalPortData = true;
+ m_previewShaderGUID = "8fdfc429d6b191c4985c9531364c1a95";
+ }
+
+ public override string BuildResults( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar )
+ {
+ if( m_outputPorts[ 0 ].IsLocalValue( dataCollector.PortCategory ) )
+ return m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory );
+
+ base.BuildResults( outputId, ref dataCollector, ignoreLocalvar );
+#if UNITY_2018_1_OR_NEWER
+ string opMode = VertexFragRemainder;
+#else
+ string opMode = dataCollector.IsTemplate ? VertexFragRemainder : SurfaceRemainder;
+#endif
+ string result = string.Empty;
+ switch( m_outputPorts[ 0 ].DataType )
+ {
+ case WirePortDataType.FLOAT:
+ case WirePortDataType.FLOAT2:
+ case WirePortDataType.FLOAT3:
+ case WirePortDataType.FLOAT4:
+ case WirePortDataType.INT:
+ case WirePortDataType.COLOR:
+ case WirePortDataType.OBJECT:
+ {
+ result = string.Format( opMode, m_inputA, m_inputB );
+ }
+ break;
+ case WirePortDataType.FLOAT3x3:
+ case WirePortDataType.FLOAT4x4:
+ {
+ result = UIUtils.InvalidParameter( this );
+ }
+ break;
+ }
+
+ return CreateOutputLocalVariable( 0, result, ref dataCollector );
+ }
+ }
+}