From b82da95b5181ac8bbae38efb13e950d5e88a4caa Mon Sep 17 00:00:00 2001 From: chai Date: Fri, 23 Oct 2020 13:08:43 +0800 Subject: =?UTF-8?q?*=E7=A7=BB=E5=8A=A8amplify=20shader=20editor=E5=88=B0th?= =?UTF-8?q?ird=20party=E7=9B=AE=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Editor/Nodes/Operators/ScaleAndOffsetNode.cs | 78 ---------------------- 1 file changed, 78 deletions(-) delete mode 100644 Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/ScaleAndOffsetNode.cs (limited to 'Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/ScaleAndOffsetNode.cs') diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/ScaleAndOffsetNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/ScaleAndOffsetNode.cs deleted file mode 100644 index 0d79fe81..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/ScaleAndOffsetNode.cs +++ /dev/null @@ -1,78 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda -using System; - -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Scale And Offset", "Math Operators", "Scales and offsets an input value\n( ( Value * Scale ) + Offset )" )] - public sealed class ScaleAndOffsetNode : ParentNode - { - private const string ScaleOffsetOpStr = "({0}*{1} + {2})"; - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - AddInputPort( WirePortDataType.FLOAT, false, Constants.EmptyPortValue ); - AddInputPort( WirePortDataType.FLOAT, false, "Scale" ); - m_inputPorts[ 1 ].FloatInternalData = 1; - AddInputPort( WirePortDataType.FLOAT, false, "Offset" ); - AddOutputPort( WirePortDataType.FLOAT, " " ); - m_useInternalPortData = true; - m_previewShaderGUID = "a1f1053d4d9c3be439e0382038b74771"; - } - - public override void OnInputPortConnected( int portId, int otherNodeId, int otherPortId, bool activateNode = true ) - { - base.OnInputPortConnected( portId, otherNodeId, otherPortId, activateNode ); - UpdateConnection( portId ); - } - - public override void OnConnectedOutputNodeChanges( int inputPortId, int otherNodeId, int otherPortId, string name, WirePortDataType type ) - { - base.OnConnectedOutputNodeChanges( inputPortId, otherNodeId, otherPortId, name, type ); - UpdateConnection( inputPortId ); - } - - public override void OnInputPortDisconnected( int portId ) - { - base.OnInputPortDisconnected( portId ); - m_inputPorts[ portId ].ChangeType( WirePortDataType.FLOAT, false ); - if( portId == 0 ) - { - m_outputPorts[ 0 ].ChangeType( WirePortDataType.FLOAT, false ); - } - } - - void UpdateConnection( int portId ) - { - if( portId == 0 ) - { - m_inputPorts[ 0 ].MatchPortToConnection(); - m_outputPorts[ 0 ].ChangeType( m_inputPorts[ 0 ].DataType, false ); - } - else - { - WirePortDataType newDataType = m_inputPorts[ portId ].ConnectionType() == WirePortDataType.FLOAT ? WirePortDataType.FLOAT : m_outputPorts[ 0 ].DataType; - m_inputPorts[ portId ].ChangeType( newDataType, false ); - } - } - - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { - if ( m_outputPorts[ 0 ].IsLocalValue( dataCollector.PortCategory ) ) - return m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ); - - string value = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ); - - // If scale or offset ports are floats then there's no need to cast them to any other type since they can be multiplied with everything - WirePortDataType scaleType = ( m_inputPorts[ 1 ].ConnectionType() == WirePortDataType.FLOAT ) ? WirePortDataType.FLOAT : m_outputPorts[ 0 ].DataType; - string scale = m_inputPorts[ 1 ].GenerateShaderForOutput( ref dataCollector, scaleType, ignoreLocalvar , true ); - - WirePortDataType offsetType = ( m_inputPorts[ 2 ].ConnectionType() == WirePortDataType.FLOAT ) ? WirePortDataType.FLOAT : m_outputPorts[ 0 ].DataType; - string offset = m_inputPorts[ 2 ].GenerateShaderForOutput( ref dataCollector, offsetType, ignoreLocalvar, true ); - - string result = string.Format( ScaleOffsetOpStr, value, scale, offset ); - return CreateOutputLocalVariable( 0, result, ref dataCollector ); - } - } -} -- cgit v1.1-26-g67d0